dm.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package http
  2. import (
  3. apiv1 "go-common/app/interface/live/app-room/api/http/v1"
  4. v1index "go-common/app/interface/live/app-room/service/v1/dm"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func sendMsgSendMsg(ctx *bm.Context) {
  9. p := new(apiv1.SendDMReq)
  10. if err := ctx.Bind(p); err != nil {
  11. return
  12. }
  13. _, err := dmservice.SendMsg(ctx, p)
  14. res := map[string]interface{}{}
  15. if e, ok := err.(*ecode.Status); ok {
  16. res["msg"] = e.Message()
  17. res["message"] = e.Message()
  18. //验证返回
  19. if e.Code() == 1990000 {
  20. res["data"] = map[string]string{
  21. "verify_url": "https://live.bilibili.com/p/html/live-app-captcha/index.html?is_live_half_webview=1&hybrid_half_ui=1,5,290,332,0,0,30,0;2,5,290,332,0,0,30,0;3,5,290,332,0,0,30,0;4,5,290,332,0,0,30,0;5,5,290,332,0,0,30,0;6,5,290,332,0,0,30,0;7,5,290,332,0,0,30,0;8,5,290,332,0,0,30,0",
  22. }
  23. }
  24. ctx.JSONMap(res, err)
  25. return
  26. }
  27. res["msg"] = ""
  28. res["message"] = ""
  29. res["data"] = []string{}
  30. ctx.JSONMap(res, err)
  31. }
  32. func getHistory(ctx *bm.Context) {
  33. p := new(apiv1.HistoryReq)
  34. if err := ctx.Bind(p); err != nil {
  35. return
  36. }
  37. resp, err := dmservice.GetHistory(ctx, p)
  38. res := map[string]interface{}{}
  39. res["msg"] = ""
  40. res["message"] = ""
  41. empty := make(map[string][]string)
  42. empty["room"] = make([]string, 0)
  43. empty["admin"] = make([]string, 0)
  44. if err != nil {
  45. res["data"] = empty
  46. ctx.JSONMap(res, err)
  47. return
  48. }
  49. res["data"] = v1index.HistoryData(resp)
  50. ctx.JSONMap(res, err)
  51. }