up.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package account
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. const (
  10. _picUpInfoURL = "/link_draw_ex/v0/doc/check"
  11. _blinkUpInfoURL = "/clip_ext/v0/video/have"
  12. _upInfoURL = "/x/internal/uper/info"
  13. )
  14. // Pic pic return value
  15. type Pic struct {
  16. Has int `json:"has_doc"`
  17. }
  18. // Blink blink return value
  19. type Blink struct {
  20. Has int `json:"has"`
  21. }
  22. // Pic get pic up info.
  23. func (d *Dao) Pic(c context.Context, mid int64, ip string) (has int, err error) {
  24. params := url.Values{}
  25. params.Set("uid", strconv.FormatInt(mid, 10))
  26. var res struct {
  27. Code int `json:"code"`
  28. Data Pic `json:"data"`
  29. }
  30. err = d.fastClient.Get(c, d.picUpInfoURL, ip, params, &res)
  31. if err != nil {
  32. log.Error("d.fastClient.Get(%s) error(%v)", d.picUpInfoURL+"?"+params.Encode(), err)
  33. return
  34. }
  35. if res.Code != 0 {
  36. log.Error("Pic url(%s) error(%v)", d.picUpInfoURL+"?"+params.Encode(), err)
  37. err = ecode.Int(res.Code)
  38. return
  39. }
  40. has = res.Data.Has
  41. return
  42. }
  43. // Blink get BLink up info.
  44. func (d *Dao) Blink(c context.Context, mid int64, ip string) (has int, err error) {
  45. params := url.Values{}
  46. params.Set("uid", strconv.FormatInt(mid, 10))
  47. var res struct {
  48. Code int `json:"code"`
  49. Data Blink `json:"data"`
  50. }
  51. err = d.fastClient.Get(c, d.blinkUpInfoURL, ip, params, &res)
  52. if err != nil {
  53. log.Error("d.fastClient.Get(%s) error(%v)", d.blinkUpInfoURL+"?"+params.Encode(), err)
  54. return
  55. }
  56. if res.Code != 0 {
  57. log.Error("Blink url(%s) error(%v)", d.blinkUpInfoURL+"?"+params.Encode(), err)
  58. err = ecode.Int(res.Code)
  59. return
  60. }
  61. has = res.Data.Has
  62. return
  63. }