Filte rProduct
This commit is contained in:
parent
b0a0b793bd
commit
8ac208e011
@ -54,12 +54,16 @@ func NewOrderService(
|
|||||||
|
|
||||||
func (s *OrderService) CreateOrder(ctx mycontext.Context, req *entity.OrderRequest) (*entity.OrderResponse, error) {
|
func (s *OrderService) CreateOrder(ctx mycontext.Context, req *entity.OrderRequest) (*entity.OrderResponse, error) {
|
||||||
productIDs := []int64{}
|
productIDs := []int64{}
|
||||||
|
var filteredItems []entity.OrderItemRequest
|
||||||
for _, item := range req.OrderItems {
|
for _, item := range req.OrderItems {
|
||||||
if item.Quantity != 0 {
|
if item.Quantity != 0 {
|
||||||
productIDs = append(productIDs, item.ProductID)
|
productIDs = append(productIDs, item.ProductID)
|
||||||
|
filteredItems = append(filteredItems, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.OrderItems = filteredItems
|
||||||
|
|
||||||
if len(productIDs) < 1 {
|
if len(productIDs) < 1 {
|
||||||
return nil, errors2.ErrorBadRequest
|
return nil, errors2.ErrorBadRequest
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user