update_wx_logic.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package Wx
  2. import (
  3. "context"
  4. "wechat-api/internal/svc"
  5. "wechat-api/internal/types"
  6. "wechat-api/internal/utils/dberrorhandler"
  7. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type UpdateWxLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewUpdateWxLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWxLogic {
  16. return &UpdateWxLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. func (l *UpdateWxLogic) UpdateWx(req *types.WxInfo) (*types.BaseMsgResp, error) {
  23. err := l.svcCtx.DB.Wx.UpdateOneID(*req.Id).
  24. SetNotNilStatus(req.Status).
  25. SetNotNilServerID(req.ServerId).
  26. SetNotNilPort(req.Port).
  27. SetNotNilProcessID(req.ProcessId).
  28. SetNotNilCallback(req.Callback).
  29. SetNotNilWxid(req.Wxid).
  30. SetNotNilAccount(req.Account).
  31. SetNotNilNickname(req.Nickname).
  32. SetNotNilTel(req.Tel).
  33. SetNotNilHeadBig(req.HeadBig).
  34. Exec(l.ctx)
  35. if err != nil {
  36. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  37. }
  38. return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
  39. }