Compare commits
No commits in common. "96377d8edb25f1987a06767c6d20ba730aee53a7" and "47a38526b1e0e1384c8686c2df94405cd1522480" have entirely different histories.
96377d8edb
...
47a38526b1
|
@ -5,9 +5,8 @@ import (
|
||||||
"app-cloudep-trade-service/internal/domain"
|
"app-cloudep-trade-service/internal/domain"
|
||||||
"app-cloudep-trade-service/internal/domain/usecase"
|
"app-cloudep-trade-service/internal/domain/usecase"
|
||||||
"app-cloudep-trade-service/internal/svc"
|
"app-cloudep-trade-service/internal/svc"
|
||||||
"context"
|
|
||||||
|
|
||||||
ers "code.30cm.net/digimon/library-go/errs"
|
ers "code.30cm.net/digimon/library-go/errs"
|
||||||
|
"context"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,8 +61,8 @@ type createOrderReq struct { // 訂單ID
|
||||||
OrderNote *string `json:"order_note,omitempty" validate:"omitempty"`
|
OrderNote *string `json:"order_note,omitempty" validate:"omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo,gocognit
|
||||||
func buildCreateOrderReq(in *trade.CreateOrderReq) *createOrderReq {
|
func buildCreateOrderReq(in *trade.CreateOrderReq) (*createOrderReq, error) {
|
||||||
createOrderReq := &createOrderReq{
|
createOrderReq := &createOrderReq{
|
||||||
BusinessID: in.BusinessId,
|
BusinessID: in.BusinessId,
|
||||||
OrderType: int8(in.OrderType),
|
OrderType: int8(in.OrderType),
|
||||||
|
@ -161,7 +160,7 @@ func buildCreateOrderReq(in *trade.CreateOrderReq) *createOrderReq {
|
||||||
createOrderReq.OrderNote = in.OrderNote
|
createOrderReq.OrderNote = in.OrderNote
|
||||||
}
|
}
|
||||||
|
|
||||||
return createOrderReq
|
return createOrderReq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// toCreateOrderReq 將 createOrderReq 轉換為 CreateOrderReq
|
// toCreateOrderReq 將 createOrderReq 轉換為 CreateOrderReq
|
||||||
|
@ -207,7 +206,12 @@ func toCreateOrderUseCase(req *createOrderReq) usecase.CreateOrderReq {
|
||||||
|
|
||||||
// CreateOrder 建立訂單
|
// CreateOrder 建立訂單
|
||||||
func (l *CreateOrderLogic) CreateOrder(in *trade.CreateOrderReq) (*trade.OKResp, error) {
|
func (l *CreateOrderLogic) CreateOrder(in *trade.CreateOrderReq) (*trade.OKResp, error) {
|
||||||
req := buildCreateOrderReq(in)
|
|
||||||
|
req, err := buildCreateOrderReq(in)
|
||||||
|
if err != nil {
|
||||||
|
// 錯誤代碼 06-011-00
|
||||||
|
return nil, ers.InvalidFormat(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// 驗證資料
|
// 驗證資料
|
||||||
if err := l.svcCtx.Validate.ValidateAll(req); err != nil {
|
if err := l.svcCtx.Validate.ValidateAll(req); err != nil {
|
||||||
|
@ -215,7 +219,7 @@ func (l *CreateOrderLogic) CreateOrder(in *trade.CreateOrderReq) (*trade.OKResp,
|
||||||
return nil, ers.InvalidFormat(err.Error())
|
return nil, ers.InvalidFormat(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
err := l.svcCtx.OrderUseCase.CreateOrder(l.ctx, toCreateOrderUseCase(req))
|
err = l.svcCtx.OrderUseCase.CreateOrder(l.ctx, toCreateOrderUseCase(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ func getInt64Value(val *int64) int64 {
|
||||||
if val == nil {
|
if val == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return *val
|
return *val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue