package logic import ( service "app.yhyue.com/moapp/MessageCenter/rpc/internal/common" "app.yhyue.com/moapp/MessageCenter/rpc/internal/config" "app.yhyue.com/moapp/MessageCenter/rpc/internal/svc" "app.yhyue.com/moapp/MessageCenter/rpc/messageclient" "app.yhyue.com/moapp/MessageCenter/rpc/type/message" "context" "github.com/zeromicro/go-zero/core/logx" ) type MultipleSaveMsgLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewMultipleSaveMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MultipleSaveMsgLogic { return &MultipleSaveMsgLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // 批量保存消息 func (l *MultipleSaveMsgLogic) MultipleSaveMsg(in *messageclient.MultipleSaveMsgReq) (*messageclient.MultipleSaveMsgResp, error) { var ( code = 1 msg = "发送成功" ) msgLogId := service.InsertMsgSendLog(in) if msgLogId > 0 { var err error in.MsgLogId = msgLogId if in.Title == config.ConfigJson.NewUserMsgTitle { err = service.NewUserSendMsg(&message.NewUserInsertMsgReq{ UserIds: in.UserIds, Title: in.Title, Content: in.Content, MsgType: in.MsgType, Link: in.Link, Appid: in.Appid, MsgLogId: in.MsgLogId, PositionIds: in.PositionIds, Row4: in.Row4, ProductName: in.ProductName, OrderId: in.OrderId, OrderMoney: in.OrderMoney, Identity: in.Identity, AppPushUrl: in.AppPushUrl, WxPushUrl: in.WxPushUrl, IosPushUrl: in.IosPushUrl, }) } else { err = service.UpdateUserMsgSummary(in) } if err != nil { code = 0 msg = err.Error() } } else { code = 0 msg = "插入message_send_log表出错" } return &messageclient.MultipleSaveMsgResp{ Code: int64(code), Message: msg, }, nil }