dao.go 1000 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package thumbup
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-interface/conf"
  5. thumbup "go-common/app/service/main/thumbup/model"
  6. thumbuprpc "go-common/app/service/main/thumbup/rpc/client"
  7. "go-common/library/net/metadata"
  8. "github.com/pkg/errors"
  9. )
  10. // Dao is tag dao
  11. type Dao struct {
  12. thumbupRPC *thumbuprpc.Service
  13. }
  14. // New initial tag dao
  15. func New(c *conf.Config) (d *Dao) {
  16. d = &Dao{
  17. thumbupRPC: thumbuprpc.New(c.ThumbupRPC),
  18. }
  19. return
  20. }
  21. // UserLikes user likes list
  22. func (d *Dao) UserTotalLike(c context.Context, mid int64, business string, pn, ps int) (res []*thumbup.ItemLikeRecord, count int, err error) {
  23. var (
  24. likes *thumbup.UserTotalLike
  25. ip = metadata.String(c, metadata.RemoteIP)
  26. )
  27. arg := &thumbup.ArgUserLikes{Mid: mid, Business: business, Pn: pn, Ps: ps, RealIP: ip}
  28. if likes, err = d.thumbupRPC.UserTotalLike(c, arg); err != nil {
  29. err = errors.Wrapf(err, "%v", arg)
  30. return
  31. }
  32. if likes != nil {
  33. res = likes.List
  34. count = likes.Total
  35. }
  36. return
  37. }