package batch_msg import ( "context" "wechat-api/internal/svc" "wechat-api/internal/types" "wechat-api/internal/utils/dberrorhandler" "github.com/suyuan32/simple-admin-common/msg/errormsg" "github.com/suyuan32/simple-admin-common/utils/pointy" "github.com/zeromicro/go-zero/core/logx" ) type CreateBatchMsgLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewCreateBatchMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateBatchMsgLogic { return &CreateBatchMsgLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *CreateBatchMsgLogic) CreateBatchMsg(req *types.BatchMsgInfo) (*types.BaseMsgResp, error) { _, err := l.svcCtx.DB.BatchMsg.Create(). SetNotNilStatus(req.Status). SetNotNilBatchNo(req.BatchNo). SetNotNilFromwxid(req.Fromwxid). SetNotNilMsg(req.Msg). SetNotNilTag(req.Tag). SetNotNilTotal(req.Total). SetNotNilSuccess(req.Success). SetNotNilFail(req.Fail). SetNotNilStartTime(pointy.GetTimeMilliPointer(req.StartTime)). SetNotNilStopTime(pointy.GetTimeMilliPointer(req.StopTime)). Save(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil }