49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package orderservicelogic
|
|
|
|
import (
|
|
ers "code.30cm.net/digimon/library-go/errs"
|
|
"context"
|
|
|
|
"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),
|
|
}
|
|
}
|
|
|
|
// DeleteOrderQuery 刪除訂單(軟刪除)
|
|
type DeleteOrderQuery struct {
|
|
BusinessID string `json:"business_id" validate:"required"`
|
|
}
|
|
|
|
// DeleteOrder 刪除訂單(軟刪除)
|
|
func (l *DeleteOrderLogic) DeleteOrder(in *tweeting.DeleteOrderReq) (*tweeting.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 &tweeting.OKResp{}, nil
|
|
}
|