api.go 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/interface/main/mcn/dao/mcndao"
  5. "go-common/app/interface/main/mcn/model/datamodel"
  6. "go-common/app/interface/main/mcn/model/mcnmodel"
  7. "go-common/library/log"
  8. )
  9. // McnGetRankArchiveLikesAPI get rank archive likes
  10. func (s *Service) McnGetRankArchiveLikesAPI(c context.Context, arg *mcnmodel.McnGetRankAPIReq) (res *mcnmodel.McnGetRankUpFansReply, err error) {
  11. res, err = s.getRankResultAPI(c, arg, s.mcndao.GetRankArchiveLikes)
  12. return
  13. }
  14. func (s *Service) getRankResultAPI(c context.Context, arg *mcnmodel.McnGetRankAPIReq, rankFunc mcndao.RankFunc) (res *mcnmodel.McnGetRankUpFansReply, err error) {
  15. v, err := rankFunc(arg.SignID)
  16. if err != nil || v == nil {
  17. log.Error("get rank fail, sign id=%d, err=%s", arg.SignID, err)
  18. return
  19. }
  20. res = new(mcnmodel.McnGetRankUpFansReply)
  21. res.Result = v.GetList(arg.Tid, arg.DataType)
  22. res.TypeList = v.GetTypeList(arg.DataType)
  23. return
  24. }
  25. // GetMcnSummaryAPI .
  26. func (s *Service) GetMcnSummaryAPI(c context.Context, arg *mcnmodel.McnGetDataSummaryReq) (res *mcnmodel.McnGetDataSummaryReply, err error) {
  27. return s.datadao.GetMcnSummaryCache(c, arg.SignID, datamodel.GetLastDay())
  28. }
  29. // GetIndexIncAPI .
  30. func (s *Service) GetIndexIncAPI(c context.Context, arg *mcnmodel.McnGetIndexIncReq) (res *mcnmodel.McnGetIndexIncReply, err error) {
  31. return s.datadao.GetIndexIncCache(c, arg.SignID, datamodel.GetLastDay(), arg.Type)
  32. }
  33. // GetIndexSourceAPI .
  34. func (s *Service) GetIndexSourceAPI(c context.Context, arg *mcnmodel.McnGetIndexSourceReq) (res *mcnmodel.McnGetIndexSourceReply, err error) {
  35. return s.datadao.GetIndexSourceCache(c, arg.SignID, datamodel.GetLastDay(), arg.Type)
  36. }
  37. // GetPlaySourceAPI .
  38. func (s *Service) GetPlaySourceAPI(c context.Context, arg *mcnmodel.McnGetPlaySourceReq) (res *mcnmodel.McnGetPlaySourceReply, err error) {
  39. return s.datadao.GetPlaySourceCache(c, arg.SignID, datamodel.GetLastDay())
  40. }
  41. // GetMcnFansAPI .
  42. func (s *Service) GetMcnFansAPI(c context.Context, arg *mcnmodel.McnGetMcnFansReq) (res *mcnmodel.McnGetMcnFansReply, err error) {
  43. return s.datadao.GetMcnFansCache(c, arg.SignID, datamodel.GetLastDay())
  44. }
  45. // GetMcnFansIncAPI .
  46. func (s *Service) GetMcnFansIncAPI(c context.Context, arg *mcnmodel.McnGetMcnFansIncReq) (res *mcnmodel.McnGetMcnFansIncReply, err error) {
  47. return s.datadao.GetMcnFansIncCache(c, arg.SignID, datamodel.GetLastDay())
  48. }
  49. // GetMcnFansDecAPI .
  50. func (s *Service) GetMcnFansDecAPI(c context.Context, arg *mcnmodel.McnGetMcnFansDecReq) (res *mcnmodel.McnGetMcnFansDecReply, err error) {
  51. return s.datadao.GetMcnFansDecCache(c, arg.SignID, datamodel.GetLastDay())
  52. }
  53. // GetMcnFansAttentionWayAPI .
  54. func (s *Service) GetMcnFansAttentionWayAPI(c context.Context, arg *mcnmodel.McnGetMcnFansAttentionWayReq) (res *mcnmodel.McnGetMcnFansAttentionWayReply, err error) {
  55. return s.datadao.GetMcnFansAttentionWayCache(c, arg.SignID, datamodel.GetLastDay())
  56. }
  57. // GetFansBaseFansAttrAPI .
  58. func (s *Service) GetFansBaseFansAttrAPI(c context.Context, arg *mcnmodel.McnGetBaseFansAttrReq) (res *mcnmodel.McnGetBaseFansAttrReply, err error) {
  59. return s.datadao.GetFansBaseFansAttrCache(c, arg.SignID, datamodel.GetLastWeek(), arg.UserType)
  60. }
  61. // GetFansAreaAPI .
  62. func (s *Service) GetFansAreaAPI(c context.Context, arg *mcnmodel.McnGetFansAreaReq) (res *mcnmodel.McnGetFansAreaReply, err error) {
  63. return s.datadao.GetFansAreaCache(c, arg.SignID, datamodel.GetLastWeek(), arg.UserType)
  64. }
  65. // GetFansTypeAPI .
  66. func (s *Service) GetFansTypeAPI(c context.Context, arg *mcnmodel.McnGetFansTypeReq) (res *mcnmodel.McnGetFansTypeReply, err error) {
  67. return s.datadao.GetFansTypeCache(c, arg.SignID, datamodel.GetLastWeek(), arg.UserType)
  68. }
  69. // GetFansTagAPI .
  70. func (s *Service) GetFansTagAPI(c context.Context, arg *mcnmodel.McnGetFansTagReq) (res *mcnmodel.McnGetFansTagReply, err error) {
  71. return s.datadao.GetFansTagCache(c, arg.SignID, datamodel.GetLastWeek(), arg.UserType)
  72. }