Не знаю

This commit is contained in:
dasha 2023-03-27 14:13:52 +04:00
parent 82dcfd163c
commit 77ce0752c1
6 changed files with 31 additions and 4788 deletions

View File

@ -7,6 +7,14 @@ plugins {
id "de.undercouch.download" version '5.3.1' id "de.undercouch.download" version '5.3.1'
} }
//task wrapper(type: Wrapper){
// gradleVersion = '7.2'
//}
//
//task prepareKotlinBuildScriptModel {
//
//}
node { node {
version = '18.15.0' version = '18.15.0'
download = true download = true

BIN
front/gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

4773
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,14 +13,9 @@ import java.util.List;
@RequestMapping("/order") @RequestMapping("/order")
public class OrderController { public class OrderController {
private final OrderService orderService; private final OrderService orderService;
private final CustomerService customerService;
private final TicketService ticketService;
public OrderController(OrderService orderService, public OrderController(OrderService orderService) {
CustomerService customerService, TicketService ticketService) {
this.orderService = orderService; this.orderService = orderService;
this.customerService = customerService;
this.ticketService = ticketService;
} }
@GetMapping("/{id}") @GetMapping("/{id}")
@ -35,23 +30,23 @@ public class OrderController {
.toList(); .toList();
} }
@PostMapping("/post") @PostMapping
public OrderDto createOrder(@RequestParam("post") String post) { public OrderDto createOrder(@RequestParam("customer") Long customer) {
return new OrderDto(orderService.addOrder()); return new OrderDto(orderService.addOrder(customer));
} }
@PutMapping("/{id}/updcustomer") /*@PutMapping("/{id}/updcustomer")
public OrderDto updateOrderCustomer(@PathVariable Long id, public OrderDto updateOrderCustomer(@PathVariable Long id,
@RequestParam("customer") Long customer) { @RequestParam("customer") Long customer) {
return new OrderDto(orderService.addCustomer(id, customer)); return new OrderDto(orderService.addCustomer(id, customer));
} }*/
@PutMapping("/{id}/updticket") /*@PutMapping("/{id}/updticket")
public OrderDto updateOrder(@PathVariable Long id, public OrderDto updateOrder(@PathVariable Long id,
@RequestParam("ticket") String ticket) { @RequestParam("ticket") String ticket) {
return new OrderDto(orderService.addTicket(id, return new OrderDto(orderService.addTicket(id,
ticketService.findTicket(Long.parseLong(ticket)))); ticketService.findTicket(Long.parseLong(ticket))));
} }*/
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public OrderDto deleteOrder(@PathVariable Long id) { public OrderDto deleteOrder(@PathVariable Long id) {

View File

@ -32,19 +32,27 @@ public class OrderService {
} }
@Transactional @Transactional
public Order addOrder() { public Order addOrder(Long customer_id) {
final Order order = new Order(new Date(System.currentTimeMillis())); final Order order = new Order(new Date(System.currentTimeMillis()));
final Customer customer = findCustomer(customer_id);
order.setCustomer(customer);
validatorUtil.validate(order); validatorUtil.validate(order);
return orderRepository.save(order); return orderRepository.save(order);
} }
@Transactional /*@Transactional
public Order addCustomer(Long id, Long customer_id) { public Order addCustomer(Long id, Long customer_id) {
final Order order = findOrder(id); final Order order = findOrder(id);
final Customer customer = customerRepository.findById(customer_id).get(); final Customer customer = customerRepository.findById(customer_id).get();
order.setCustomer(customer); order.setCustomer(customer);
validatorUtil.validate(order); validatorUtil.validate(order);
return order; return order;
}*/
@Transactional(readOnly = true)
Customer findCustomer(Long customer_id) {
final Optional<Customer> customer = customerRepository.findById(customer_id);
return customer.orElseThrow(() -> new CustomerNotFoundException(customer_id));
} }
@Transactional @Transactional