service.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package medal
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/conf"
  5. "go-common/app/interface/main/creative/dao/medal"
  6. mdMdl "go-common/app/interface/main/creative/model/medal"
  7. "go-common/app/interface/main/creative/model/newcomer"
  8. "go-common/app/interface/main/creative/service"
  9. "go-common/library/log"
  10. )
  11. //Service struct
  12. type Service struct {
  13. c *conf.Config
  14. medal *medal.Dao
  15. //task
  16. p *service.Public
  17. }
  18. //New get service
  19. func New(c *conf.Config, rpcdaos *service.RPCDaos, p *service.Public) *Service {
  20. s := &Service{
  21. c: c,
  22. medal: medal.New(c),
  23. p: p,
  24. }
  25. return s
  26. }
  27. // Medal get medal.
  28. func (s *Service) Medal(c context.Context, mid int64) (t *mdMdl.Medal, err error) {
  29. t, err = s.medal.Medal(c, mid)
  30. return
  31. }
  32. // OpenMedal open medal.
  33. func (s *Service) OpenMedal(c context.Context, mid int64, name string) (err error) {
  34. if err = s.medal.OpenMedal(c, mid, name); err != nil {
  35. log.Error("s.medal.OpenMedal mid(%d) error(%v)", mid, err)
  36. return
  37. }
  38. s.p.TaskPub(mid, newcomer.MsgForOpenFansMedal, newcomer.MsgFinishedCount)
  39. return
  40. }
  41. // RecentFans get recent fans.
  42. func (s *Service) RecentFans(c context.Context, mid int64) (res []*mdMdl.RecentFans, err error) {
  43. res, err = s.medal.RecentFans(c, mid)
  44. return
  45. }
  46. // CheckMedal check medal name valid
  47. func (s *Service) CheckMedal(c context.Context, mid int64, name string) (valid int, err error) {
  48. valid, err = s.medal.CheckMedal(c, mid, name)
  49. return
  50. }
  51. // Rank get fans rank list
  52. func (s *Service) Rank(c context.Context, mid int64) (rank []*mdMdl.FansRank, err error) {
  53. rank, err = s.medal.Rank(c, mid)
  54. return
  55. }
  56. // Rename rename medal name
  57. func (s *Service) Rename(c context.Context, mid int64, name, ak, ck string) (err error) {
  58. err = s.medal.Rename(c, mid, name, ak, ck)
  59. return
  60. }