report.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/interface/bbq/app-bbq/api/http/v1"
  5. "go-common/app/interface/bbq/app-bbq/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. "github.com/golang/protobuf/ptypes/empty"
  9. )
  10. //Report ..
  11. func (s *Service) Report(c context.Context, arg *v1.ReportRequest, mid int64, ak string) (res *empty.Empty, err error) {
  12. res = &empty.Empty{}
  13. switch arg.Type {
  14. case model.TypeVideo:
  15. if err = s.dao.ReportVideo(c, arg.SVID, mid, model.MapReasons[arg.Reason]); err != nil {
  16. log.Warnv(c, log.KV("event", "report video err"), log.KV("err", err), log.KV("req", arg))
  17. return
  18. }
  19. case model.TypeComment:
  20. reason := model.BiliReasonsMap[arg.Reason]
  21. content := ""
  22. if reason == 0 {
  23. content = "BBQ其他理由"
  24. }
  25. req := &v1.CommentReportReq{
  26. SvID: arg.SVID,
  27. RpID: arg.RpID,
  28. Reason: reason,
  29. Content: content,
  30. Type: model.DefaultCmType,
  31. AccessKey: ak,
  32. }
  33. if err = s.CommentReport(c, req); err != nil {
  34. log.Warnv(c, log.KV("event", "report comment err"), log.KV("err", err), log.KV("req", arg))
  35. return
  36. }
  37. case model.TypeDanmu:
  38. var (
  39. dm *model.Danmu
  40. )
  41. if dm, err = s.dao.RawBullet(c, arg.Danmu); err != nil {
  42. log.Errorw(c, "event", "query mid", "err", err)
  43. err = ecode.ReportDanmuError
  44. return
  45. }
  46. if err = s.dao.ReportDanmu(c, arg.Danmu, dm.MID, mid, model.MapReasons[arg.Reason]); err != nil {
  47. log.Warnv(c, log.KV("event", "report danmu err"), log.KV("err", err), log.KV("req", arg))
  48. return
  49. }
  50. case model.TypeUser:
  51. var rType int
  52. if arg.Reason == 5 {
  53. rType = 0
  54. } else {
  55. rType = 1
  56. }
  57. if err = s.dao.ReportUser(c, rType, arg.UpMID, mid, model.MapReasons[arg.Reason]); err != nil {
  58. log.Warnv(c, log.KV("event", "report user err"), log.KV("err", err), log.KV("req", arg))
  59. return
  60. }
  61. }
  62. return
  63. }