package orderservicelogic import ( "app-cloudep-order-server/gen_result/pb/order" "context" ers "code.30cm.net/digimon/library-go/errs" "app-cloudep-order-server/internal/svc" "github.com/zeromicro/go-zero/core/logx" ) type DeleteOrderLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewDeleteOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOrderLogic { return &DeleteOrderLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // DeleteOrderQuery 刪除訂單(軟刪除) type DeleteOrderQuery struct { BusinessID string `json:"business_id" validate:"required"` } // DeleteOrder 刪除訂單(軟刪除) func (l *DeleteOrderLogic) DeleteOrder(in *order.DeleteOrderReq) (*order.OKResp, error) { // 驗證資料 if err := l.svcCtx.Validate.ValidateAll(&DeleteOrderQuery{ BusinessID: in.GetBusinessId(), }); err != nil { // 錯誤代碼 06-011-00 return nil, ers.InvalidFormat(err.Error()) } _, err := l.svcCtx.OrderModel.DeleteByBusinessID(l.ctx, in.GetBusinessId()) if err != nil { return nil, err } return &order.OKResp{}, nil }