mission.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package mission
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/job/main/videoup-report/model/mission"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. const (
  10. _msAllURL = "/activity/list/videoall"
  11. )
  12. // Missions get missions.
  13. func (d *Dao) Missions(c context.Context) (mm map[int]*mission.Mission, err error) {
  14. var res struct {
  15. Code int `json:"code"`
  16. Data []*struct {
  17. ID int `json:"id"`
  18. Name string `json:"name"`
  19. ETime string `json:"etime"`
  20. Tags string `json:"tags"`
  21. } `json:"data"`
  22. }
  23. if err = d.httpR.Get(c, d.missAllURL, "", nil, &res); err != nil {
  24. log.Error("videoup mission list error(%v) | missAllURL(%s)", err, d.missAllURL)
  25. return
  26. }
  27. if res.Code != 0 {
  28. log.Error("videoup mission list res.Code nq zero error(%v) | missAllURL(%s) res(%v)", res.Code, d.missAllURL, res)
  29. err = ecode.CreativeActivityErr
  30. return
  31. }
  32. mm = make(map[int]*mission.Mission, len(res.Data))
  33. for _, m := range res.Data {
  34. miss := &mission.Mission{}
  35. miss.ID = m.ID
  36. miss.Name = m.Name
  37. miss.ETime, _ = time.Parse("2006-01-02 15:04:05", m.ETime)
  38. miss.Tags = m.Tags
  39. mm[miss.ID] = miss
  40. }
  41. return
  42. }