service.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package feedback
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/conf"
  5. "go-common/app/interface/main/creative/dao/feedback"
  6. fdMdl "go-common/app/interface/main/creative/model/feedback"
  7. "go-common/app/interface/main/creative/service"
  8. )
  9. //Service struct.
  10. type Service struct {
  11. c *conf.Config
  12. feedback *feedback.Dao
  13. }
  14. //New get service.
  15. func New(c *conf.Config, rpcdaos *service.RPCDaos) *Service {
  16. s := &Service{
  17. c: c,
  18. feedback: feedback.New(c),
  19. }
  20. return s
  21. }
  22. // Feedbacks get user feedback list.
  23. func (s *Service) Feedbacks(c context.Context, mid, ps, pn, tagID int64, state, start, end, platform, ip string) (data []*fdMdl.Feedback, count int64, err error) {
  24. data, count, err = s.feedback.Feedbacks(c, mid, ps, pn, tagID, state, start, end, platform, ip)
  25. return
  26. }
  27. // AddFeedback add feedback
  28. func (s *Service) AddFeedback(c context.Context, mid, tagID, sessionID int64, qq, content, aid, imgURL, browser, platform, ip string) (err error) {
  29. err = s.feedback.AddFeedback(c, mid, tagID, sessionID, qq, content, aid, browser, imgURL, platform, ip)
  30. return
  31. }
  32. // Tags get tags.
  33. func (s *Service) Tags(c context.Context, mid int64, ip string) (tags []*fdMdl.Tag, err error) {
  34. var tls *fdMdl.TagList
  35. if tls, err = s.feedback.Tags(c, mid, ip); err != nil {
  36. return
  37. }
  38. if tls == nil || len(tls.Platforms) == 0 {
  39. return
  40. }
  41. for _, v := range tls.Platforms {
  42. if v.EN == "ugc" {
  43. tags = v.Tags
  44. }
  45. }
  46. return
  47. }
  48. // NewTags get new tags.
  49. func (s *Service) NewTags(c context.Context, mid int64, ip string) (tags *fdMdl.TagList, err error) {
  50. tags, err = s.feedback.Tags(c, mid, ip)
  51. return
  52. }
  53. // Detail get feedback detail
  54. func (s *Service) Detail(c context.Context, mid, sessionID int64, ip string) (data []*fdMdl.Reply, err error) {
  55. data, err = s.feedback.Detail(c, mid, sessionID, ip)
  56. return
  57. }
  58. // CloseSession get feedback detail
  59. func (s *Service) CloseSession(c context.Context, sessionID int64, ip string) (err error) {
  60. err = s.feedback.CloseSession(c, sessionID, ip)
  61. return
  62. }