multiplesavemsglogic.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/MessageCenter/api/internal/svc"
  4. "app.yhyue.com/moapp/MessageCenter/api/internal/types"
  5. "app.yhyue.com/moapp/MessageCenter/rpc/messageclient"
  6. "app.yhyue.com/moapp/MessageCenter/util"
  7. "context"
  8. "github.com/tal-tech/go-zero/core/logx"
  9. "log"
  10. )
  11. type MultipleSaveMsgLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewMultipleSaveMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) MultipleSaveMsgLogic {
  17. return MultipleSaveMsgLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *MultipleSaveMsgLogic) MultipleSaveMsg(req types.MultipleSaveMsgReq) (*types.MultipleSaveMsgResp, error) {
  24. // todo: add your logic here and delete this line
  25. log.Println("请求参数:", req)
  26. //var reqData = []map[string]interface{}{}
  27. //err := json.Unmarshal([]byte(req.SaveData), reqData)
  28. //if err != nil {
  29. // return &types.MultipleSaveMsgResp{
  30. // Code: 0,
  31. // Message: "失败",
  32. // ErrCount: 0,
  33. // }, nil
  34. //}
  35. errCount := 0
  36. lsi := l.svcCtx.MessageCenter
  37. msgInfo := req.MsgInfo
  38. log.Println("###############", int64(util.IntAll(msgInfo["msgLogId"])))
  39. _, err := lsi.MultipleSaveMsg(l.ctx, &messageclient.MultipleSaveMsgReq{
  40. Appid: util.ObjToString(msgInfo["appid"]),
  41. SendUserId: util.ObjToString(msgInfo["sendUserId"]),
  42. SendName: util.ObjToString(msgInfo["sendName"]),
  43. Title: util.ObjToString(msgInfo["title"]),
  44. Content: util.ObjToString(msgInfo["content"]),
  45. MsgType: int64(util.IntAll(msgInfo["msgType"])),
  46. Link: util.ObjToString(msgInfo["link"]),
  47. CiteId: 0,
  48. UserIds: req.UserIds,
  49. UserNames: req.UserNames,
  50. MsgLogId: int64(util.IntAll(msgInfo["msgLogId"])),
  51. ShowBuoy: int64(util.IntAll(msgInfo["showBuoy"])),
  52. ShowContent: util.ObjToString(msgInfo["showContent"]),
  53. })
  54. if err != nil {
  55. errCount++
  56. }
  57. return &types.MultipleSaveMsgResp{
  58. Code: 1,
  59. Message: "保存成功",
  60. ErrCount: int64(errCount),
  61. }, nil
  62. }