package wxcardvisit import ( "context" "github.com/suyuan32/simple-admin-common/msg/errormsg" "github.com/zeromicro/go-zero/core/errorx" "wechat-api/internal/utils/dberrorhandler" "wechat-api/internal/svc" "wechat-api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type UpdateWxCardVisitLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewUpdateWxCardVisitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWxCardVisitLogic { return &UpdateWxCardVisitLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} } func (l *UpdateWxCardVisitLogic) UpdateWxCardVisit(req *types.WxCardVisitReq) (*types.BaseMsgResp, error) { if req.Id == nil || *req.Id <= 0 { return nil, errorx.NewInvalidArgumentError("id cannot be null") } err := l.svcCtx.DB.WxCardVisit.UpdateOneID(*req.Id). SetNotNilUserID(req.UserId). SetNotNilBotID(req.BotId). SetNotNilBotType(req.BotType). Exec(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.Success}, nil }