package wxcard import ( "context" "github.com/suyuan32/simple-admin-common/msg/errormsg" "wechat-api/internal/utils/dberrorhandler" "wechat-api/internal/svc" "wechat-api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type UpdateWxCardLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewUpdateWxCardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWxCardLogic { return &UpdateWxCardLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} } func (l *UpdateWxCardLogic) UpdateWxCard(req *types.WxCardInfo) (*types.BaseMsgResp, error) { err := l.svcCtx.DB.WxCard.UpdateOneID(*req.Id). SetNotNilUserID(req.UserId). SetNotNilWxUserID(req.WxUserId). SetNotNilAvatar(req.Avatar). SetNotNilLogo(req.Logo). SetNotNilName(req.Name). SetNotNilCompany(req.Company). SetNotNilAddress(req.Address). SetNotNilPhone(req.Phone). SetNotNilEmail(req.Email). SetNotNilOfficialAccount(req.OfficialAccount). SetNotNilWechatAccount(req.WechatAccount). SetNotNilIntro(req.Intro). SetNotNilAPIBase(req.ApiBase). SetNotNilAPIKey(req.ApiKey). SetNotNilAiInfo(req.AiInfo). Exec(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.Success}, nil }