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 UpdateBatchMsgLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewUpdateBatchMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBatchMsgLogic { return &UpdateBatchMsgLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *UpdateBatchMsgLogic) UpdateBatchMsg(req *types.BatchMsgInfo) (*types.BaseMsgResp, error) { err := l.svcCtx.DB.BatchMsg.UpdateOneID(*req.Id). 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)). Exec(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil }