update_alloc_agent_logic.go 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package allocagent
  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 UpdateAllocAgentLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewUpdateAllocAgentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAllocAgentLogic {
  16. return &UpdateAllocAgentLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. func (l *UpdateAllocAgentLogic) UpdateAllocAgent(req *types.AllocAgentInfo) (*types.BaseMsgResp, error) {
  23. err := l.svcCtx.DB.AllocAgent.UpdateOneID(*req.Id).
  24. SetNotNilUserID(req.UserId).
  25. SetNotNilOrganizationID(req.OrganizationId).
  26. SetNotNilAgents(req.Agents).
  27. SetNotNilStatus(req.Status).
  28. Exec(l.ctx)
  29. if err != nil {
  30. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  31. }
  32. return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
  33. }