delete_wx_card_user_logic.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package wxcarduser
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/zeromicro/go-zero/core/errorx"
  6. "wechat-api/ent/wxcarduser"
  7. "wechat-api/internal/utils/dberrorhandler"
  8. "wechat-api/internal/svc"
  9. "wechat-api/internal/types"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type DeleteWxCardUserLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewDeleteWxCardUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteWxCardUserLogic {
  18. return &DeleteWxCardUserLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx}
  22. }
  23. func (l *DeleteWxCardUserLogic) DeleteWxCardUser(req *types.IDsReq) (*types.BaseMsgResp, error) {
  24. if len(req.Ids) == 0 {
  25. return nil, errorx.NewInvalidArgumentError("Ids参数不能为空")
  26. }
  27. rows, err := l.svcCtx.DB.WxCardUser.Delete().Where(wxcarduser.IDIn(req.Ids...)).Exec(l.ctx)
  28. if err != nil {
  29. return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
  30. }
  31. msg := fmt.Sprintf("delete %d rows", rows)
  32. return &types.BaseMsgResp{Msg: msg}, nil
  33. }