lab_3
This commit is contained in:
parent
0f7b373fa2
commit
d47f50ba29
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user