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

50 lines
1.1 KiB
Go
Raw Normal View History

2024-10-06 07:02:30 +00:00
package orderservicelogic
import (
"context"
2024-10-12 13:04:06 +00:00
ers "code.30cm.net/digimon/library-go/errs"
2024-10-06 07:02:30 +00:00
"app-cloudep-order-server/gen_result/pb/tweeting"
"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),
}
}
2024-10-12 09:49:58 +00:00
// 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 *tweeting.DeleteOrderReq) (*tweeting.OKResp, error) {
2024-10-12 09:49:58 +00:00
// 驗證資料
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 &tweeting.OKResp{}, nil
}