elec.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "time"
  7. "go-common/app/interface/main/web/model"
  8. "go-common/library/ecode"
  9. "go-common/library/log"
  10. "go-common/library/net/metadata"
  11. )
  12. // ElecShow elec show.
  13. func (d *Dao) ElecShow(c context.Context, mid, aid, loginID int64) (rs *model.ElecShow, err error) {
  14. var (
  15. params = url.Values{}
  16. remoteIP = metadata.String(c, metadata.RemoteIP)
  17. )
  18. params.Set("ts", strconv.FormatInt(time.Now().Unix(), 10))
  19. params.Set("mid", strconv.FormatInt(mid, 10))
  20. if loginID > 0 {
  21. params.Set("login_mid", strconv.FormatInt(loginID, 10))
  22. }
  23. params.Set("aid", strconv.FormatInt(aid, 10))
  24. params.Set("act", "appkey")
  25. var res struct {
  26. Code int `json:"code"`
  27. Data *model.ElecShow `json:"data"`
  28. }
  29. if err = d.httpR.Get(c, d.elecShowURL, remoteIP, params, &res); err != nil {
  30. log.Error("ElecShow url(%s) error(%v)", d.elecShowURL+"?"+params.Encode(), err)
  31. return
  32. }
  33. if res.Code != ecode.OK.Code() {
  34. err = ecode.Int(res.Code)
  35. return
  36. }
  37. rs = res.Data
  38. return
  39. }