dao.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package sp
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/app/interface/main/app-interface/conf"
  7. "go-common/app/interface/main/app-interface/model/sp"
  8. httpx "go-common/library/net/http/blademaster"
  9. "go-common/library/net/metadata"
  10. )
  11. const (
  12. _specil = "/sp/list"
  13. )
  14. // Dao is favorite dao
  15. type Dao struct {
  16. client *httpx.Client
  17. specil string
  18. }
  19. // New initial favorite dao
  20. func New(c *conf.Config) (d *Dao) {
  21. d = &Dao{
  22. client: httpx.NewClient(c.HTTPClient),
  23. specil: c.Host.APICo + _specil,
  24. }
  25. return
  26. }
  27. // Specil get specil from old BiliWEB api.
  28. func (d *Dao) Specil(c context.Context, accessKey, actionKey, device, mobiApp, platform string, build, pn, ps int) (res *sp.Specil, err error) {
  29. ip := metadata.String(c, metadata.RemoteIP)
  30. params := url.Values{}
  31. params.Set("access_key", accessKey)
  32. params.Set("actionKey", actionKey)
  33. params.Set("build", strconv.Itoa(build))
  34. params.Set("device", device)
  35. params.Set("mobi_app", mobiApp)
  36. params.Set("page", strconv.Itoa(pn))
  37. params.Set("pagesize", strconv.Itoa(ps))
  38. params.Set("platform", platform)
  39. err = d.client.Get(c, d.specil, ip, params, &res)
  40. return
  41. }