following.go 913 B

1234567891011121314151617181920212223242526272829303132333435
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "time"
  7. "go-common/app/job/main/relation/model"
  8. "go-common/library/log"
  9. )
  10. // UpdateFollowingCache update following cache.
  11. func (d *Dao) UpdateFollowingCache(r *model.Relation) (err error) {
  12. params := url.Values{}
  13. params.Set("mid", strconv.FormatInt(r.Mid, 10))
  14. params.Set("fid", strconv.FormatInt(r.Fid, 10))
  15. params.Set("attribute", strconv.FormatInt(int64(r.Attribute), 10))
  16. mt, err := time.Parse(time.RFC3339, r.MTime)
  17. if err != nil {
  18. mt = time.Now()
  19. }
  20. params.Set("mtime", strconv.FormatInt(mt.Unix(), 10))
  21. var res struct {
  22. Code int `json:"code"`
  23. }
  24. if err = d.client.Post(context.TODO(), d.clearFollowingPath, "", params, &res); err != nil {
  25. log.Error("d.client.Post error(%v)", err)
  26. return
  27. }
  28. if res.Code != 0 {
  29. log.Error("url(%s) res code(%d) or res.result(%v)", d.clearFollowingPath+"?"+params.Encode(), res.Code)
  30. }
  31. return
  32. }