multiplesavemsglogic.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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/zeromicro/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. errCount := 0
  25. lsi := l.svcCtx.MessageCenter
  26. msgInfo := req.MsgInfo
  27. _, err := lsi.MultipleSaveMsg(l.ctx, &messageclient.MultipleSaveMsgReq{
  28. Appid: util.ObjToString(msgInfo["appid"]),
  29. SendUserId: util.ObjToString(msgInfo["sendUserId"]),
  30. Title: util.ObjToString(msgInfo["title"]),
  31. Content: util.ObjToString(msgInfo["content"]),
  32. MsgType: int64(util.IntAll(msgInfo["msgType"])),
  33. Link: util.ObjToString(msgInfo["link"]),
  34. UserIds: req.UserIds,
  35. MsgLogId: int64(util.IntAll(msgInfo["msgLogId"])),
  36. PositionIds: req.PositionIds,
  37. Row4: util.ObjToString(msgInfo["row4"]),
  38. ProductName: util.ObjToString(msgInfo["productName"]),
  39. OrderId: util.ObjToString(msgInfo["orderId"]),
  40. OrderMoney: util.ObjToString(msgInfo["orderMoney"]),
  41. AppPushUrl: util.ObjToString(msgInfo["appPushUrl"]),
  42. WxPushUrl: util.ObjToString(msgInfo["wxPushUrl"]),
  43. IosPushUrl: util.ObjToString(msgInfo["iosPushUrl"]),
  44. })
  45. if err != nil {
  46. log.Println("-------------", err)
  47. errCount++
  48. }
  49. return &types.MultipleSaveMsgResp{
  50. Code: 1,
  51. Message: "保存成功",
  52. ErrCount: int64(errCount),
  53. }, nil
  54. }