newusersavemsglogic.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. )
  10. type NewUserSaveMsgLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewNewUserSaveMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NewUserSaveMsgLogic {
  16. return &NewUserSaveMsgLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *NewUserSaveMsgLogic) NewUserSaveMsg(req *types.NewUserSaveMsgReq) (resp *types.NewUserSaveMsgResp, err error) {
  23. lsi := l.svcCtx.MessageCenter
  24. msgInfo := req.MsgInfo
  25. /*msgLogId, err := (msgInfo["msgLogId"]).(json.Number).Int64()
  26. msgType, err := (msgInfo["msgType"]).(json.Number).Int64()
  27. fmt.Println("msgInfo:", msgInfo)*/
  28. _, err = lsi.NewUserMsg(l.ctx, &messageclient.NewUserInsertMsgReq{
  29. Appid: util.ObjToString(msgInfo["appid"]),
  30. Title: util.ObjToString(msgInfo["title"]),
  31. Content: util.ObjToString(msgInfo["content"]),
  32. MsgType: util.Int64All(msgInfo["msgType"]),
  33. Link: util.ObjToString(msgInfo["link"]),
  34. UserIds: req.UserIds,
  35. MsgLogId: util.Int64All(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. return &types.NewUserSaveMsgResp{
  47. Code: 1,
  48. Message: err.Error(),
  49. }, nil
  50. }
  51. return &types.NewUserSaveMsgResp{
  52. Code: 1,
  53. Message: "保存成功",
  54. }, nil
  55. }