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 CreateWxCardLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewCreateWxCardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWxCardLogic { return &CreateWxCardLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} } func (l *CreateWxCardLogic) CreateWxCard(req *types.WxCardInfo) (*types.BaseMsgResp, error) { _, err := l.svcCtx.DB.WxCard.Create(). 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). SetNotNilAPIBase(req.ApiBase). SetNotNilAPIKey(req.ApiKey). SetNotNilAiInfo(req.AiInfo). SetNotNilOfficialAccount(req.OfficialAccount). SetNotNilWechatAccount(req.WechatAccount). SetNotNilIntro(req.Intro). Save(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.Success}, nil }