report.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package dao
  2. import (
  3. "context"
  4. "errors"
  5. "go-common/app/interface/bbq/app-bbq/model"
  6. "go-common/library/log"
  7. xhttp "net/http"
  8. "net/url"
  9. "strconv"
  10. )
  11. //ReportUser rType=0 face;rType=1 name;
  12. func (d *Dao) ReportUser(c context.Context, rType int, mid int64, rmid int64, reason string) (err error) {
  13. var (
  14. params url.Values
  15. req *xhttp.Request
  16. res model.HTTPRpcRes
  17. )
  18. params = url.Values{}
  19. params.Set("mid", strconv.FormatInt(mid, 10))
  20. params.Set("rmid", strconv.FormatInt(rmid, 10))
  21. params.Set("type", strconv.Itoa(rType))
  22. params.Set("reason", reason)
  23. if req, err = d.httpClient.NewRequest("POST", d.c.URLs["cms_report"], "", params); err != nil {
  24. log.Errorv(c, log.KV("event", "ReportUser d.httpClient.NewRequest failed"), log.KV("err", err))
  25. return
  26. }
  27. if err = d.httpClient.Do(c, req, &res); err != nil {
  28. log.Errorv(c, log.KV("event", "cms ReportUser http req failed"), log.KV("err", err), log.KV("req", req))
  29. return
  30. }
  31. if res.Code != 0 {
  32. log.Errorv(c, log.KV("event", "cms ReportUser res.code err"), log.KV("err", err))
  33. err = errors.New("cms ReportUser return err")
  34. return
  35. }
  36. return
  37. }
  38. //ReportDanmu ..
  39. func (d *Dao) ReportDanmu(c context.Context, danmu int64, mid int64, rmid int64, reason string) (err error) {
  40. var (
  41. params url.Values
  42. req *xhttp.Request
  43. res model.HTTPRpcRes
  44. )
  45. params = url.Values{}
  46. params.Set("mid", strconv.FormatInt(mid, 10))
  47. params.Set("rmid", strconv.FormatInt(rmid, 10))
  48. params.Set("bullet_id", strconv.FormatInt(danmu, 10))
  49. params.Set("reason", reason)
  50. if req, err = d.httpClient.NewRequest("POST", d.c.URLs["cms_report_bullet"], "", params); err != nil {
  51. log.Errorv(c, log.KV("event", "ReportDanmu d.httpClient.NewRequest failed"), log.KV("err", err))
  52. return
  53. }
  54. if err = d.httpClient.Do(c, req, &res); err != nil {
  55. log.Errorv(c, log.KV("event", "cms ReportDanmu http req failed"), log.KV("err", err), log.KV("req", req))
  56. return
  57. }
  58. if res.Code != 0 {
  59. log.Errorv(c, log.KV("event", "cms ReportDanmu res.code err"), log.KV("err", err))
  60. err = errors.New("cms ReportDanmu return err")
  61. return
  62. }
  63. return
  64. }
  65. //ReportVideo ..
  66. func (d *Dao) ReportVideo(c context.Context, svid int64, rmid int64, reason string) (err error) {
  67. var (
  68. params url.Values
  69. req *xhttp.Request
  70. res model.HTTPRpcRes
  71. )
  72. params = url.Values{}
  73. params.Set("rmid", strconv.FormatInt(rmid, 10))
  74. params.Set("svid", strconv.FormatInt(svid, 10))
  75. params.Set("reason", reason)
  76. if req, err = d.httpClient.NewRequest("POST", d.c.URLs["cms_report_video"], "", params); err != nil {
  77. log.Errorv(c, log.KV("event", "ReportVideo d.httpClient.NewRequest failed"), log.KV("err", err))
  78. return
  79. }
  80. if err = d.httpClient.Do(c, req, &res); err != nil {
  81. log.Errorv(c, log.KV("event", "cms ReportVideo http req failed"), log.KV("err", err), log.KV("req", req))
  82. return
  83. }
  84. if res.Code != 0 {
  85. log.Errorv(c, log.KV("event", "cms ReportVideo res.code err"), log.KV("err", err))
  86. err = errors.New("cms ReportVideo return err")
  87. return
  88. }
  89. return
  90. }