update_wx_card_logic.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package wxcard
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  5. "wechat-api/internal/utils/dberrorhandler"
  6. "wechat-api/internal/svc"
  7. "wechat-api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type UpdateWxCardLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewUpdateWxCardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWxCardLogic {
  16. return &UpdateWxCardLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx}
  20. }
  21. func (l *UpdateWxCardLogic) UpdateWxCard(req *types.WxCardInfo) (*types.BaseMsgResp, error) {
  22. err := l.svcCtx.DB.WxCard.UpdateOneID(*req.Id).
  23. SetNotNilUserID(req.UserId).
  24. SetNotNilWxUserID(req.WxUserId).
  25. SetNotNilAvatar(req.Avatar).
  26. SetNotNilLogo(req.Logo).
  27. SetNotNilName(req.Name).
  28. SetNotNilCompany(req.Company).
  29. SetNotNilAddress(req.Address).
  30. SetNotNilPhone(req.Phone).
  31. SetNotNilEmail(req.Email).
  32. SetNotNilOfficialAccount(req.OfficialAccount).
  33. SetNotNilWechatAccount(req.WechatAccount).
  34. SetNotNilIntro(req.Intro).
  35. SetNotNilAPIBase(req.ApiBase).
  36. SetNotNilAPIKey(req.ApiKey).
  37. SetNotNilAiInfo(req.AiInfo).
  38. Exec(l.ctx)
  39. if err != nil {
  40. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  41. }
  42. return &types.BaseMsgResp{Msg: errormsg.Success}, nil
  43. }