app-cloudep-order-server/internal/logic/orderservice/delete_order_logic.go

50 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-10-06 07:02:30 +00:00
package orderservicelogic
import (
"app-cloudep-order-server/gen_result/pb/order"
2024-10-06 07:02:30 +00:00
"context"
ers "code.30cm.net/digimon/library-go/errs"
2024-10-06 07:02:30 +00:00
"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"`
}
2024-10-06 07:02:30 +00:00
// 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
}
2024-10-06 07:02:30 +00:00
return &order.OKResp{}, nil
2024-10-06 07:02:30 +00:00
}