This commit is contained in:
Алексей Крюков 2024-05-11 20:08:02 +04:00
parent 0f7b373fa2
commit d47f50ba29
14 changed files with 2 additions and 9 deletions

Binary file not shown.

View File

@ -56,8 +56,8 @@ public class OrderController {
for (OrderLineDto lineDto : dto.getLines()) {
OrderLineEntity orderLineEntity = modelMapper.map(lineDto, OrderLineEntity.class);
orderLineEntity.setId(null);
// Здесь нужно установить ProductEntity для OrderLineEntity
ProductEntity product = productService.get(lineDto.getProductId()); // Получаем продукт по его ID
ProductEntity product = productService.get(lineDto.getProductId());
orderLineEntity.setProduct(product); // Устанавливаем продукт для строки заказа
entity.addOrderLine(orderLineEntity);
}

View File

@ -70,11 +70,4 @@ public class OrderEntity extends BaseEntity {
&& Objects.equals(other.getLines(), lines);
}
public Double calculateTotalOrderPrice() {
Double totalPrice = 0.0;
for (OrderLineEntity orderLine : lines) {
totalPrice += orderLine.getProduct().getPrice() * orderLine.getCount();
}
return totalPrice;
}
}