Compare commits

...

10 Commits

Author SHA1 Message Date
daniel.w 96377d8edb 解衝突 2024-10-28 01:57:14 +08:00
daniel.w af6b700f9b add order service logic 2024-10-28 01:54:05 +08:00
daniel.w ea419a9943 add order service logic 2024-10-28 01:27:25 +08:00
daniel.w 8596d56fc7 add order service logic 2024-10-28 00:07:24 +08:00
daniel.w 008f40a898 add order usecase 2024-10-28 00:01:55 +08:00
daniel.w 67ccb9433c add order usecase 2024-10-27 22:23:37 +08:00
daniel.w 799fc0bf9d add mongo model 2024-10-26 01:17:32 +08:00
daniel.w 495994708e init order status 2024-10-26 01:12:17 +08:00
daniel.w 9e667c83f3 init mongo 2024-10-26 00:42:58 +08:00
daniel.w 69746285ae generate service 2024-10-25 18:17:27 +08:00
2 changed files with 8 additions and 11 deletions

View File

@ -5,8 +5,9 @@ import (
"app-cloudep-trade-service/internal/domain"
"app-cloudep-trade-service/internal/domain/usecase"
"app-cloudep-trade-service/internal/svc"
ers "code.30cm.net/digimon/library-go/errs"
"context"
ers "code.30cm.net/digimon/library-go/errs"
"github.com/zeromicro/go-zero/core/logx"
)
@ -61,8 +62,8 @@ type createOrderReq struct { // 訂單ID
OrderNote *string `json:"order_note,omitempty" validate:"omitempty"`
}
//nolint:gocyclo,gocognit
func buildCreateOrderReq(in *trade.CreateOrderReq) (*createOrderReq, error) {
//nolint:gocyclo
func buildCreateOrderReq(in *trade.CreateOrderReq) *createOrderReq {
createOrderReq := &createOrderReq{
BusinessID: in.BusinessId,
OrderType: int8(in.OrderType),
@ -160,7 +161,7 @@ func buildCreateOrderReq(in *trade.CreateOrderReq) (*createOrderReq, error) {
createOrderReq.OrderNote = in.OrderNote
}
return createOrderReq, nil
return createOrderReq
}
// toCreateOrderReq 將 createOrderReq 轉換為 CreateOrderReq
@ -206,12 +207,7 @@ func toCreateOrderUseCase(req *createOrderReq) usecase.CreateOrderReq {
// CreateOrder 建立訂單
func (l *CreateOrderLogic) CreateOrder(in *trade.CreateOrderReq) (*trade.OKResp, error) {
req, err := buildCreateOrderReq(in)
if err != nil {
// 錯誤代碼 06-011-00
return nil, ers.InvalidFormat(err.Error())
}
req := buildCreateOrderReq(in)
// 驗證資料
if err := l.svcCtx.Validate.ValidateAll(req); err != nil {
@ -219,7 +215,7 @@ func (l *CreateOrderLogic) CreateOrder(in *trade.CreateOrderReq) (*trade.OKResp,
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 {
return nil, err
}

View File

@ -24,6 +24,7 @@ func getInt64Value(val *int64) int64 {
if val == nil {
return 0
}
return *val
}