бэк переделан не снова а опять
This commit is contained in:
parent
c787736c11
commit
4b12d6bd20
@ -1,13 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<script src="/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||
<title>Repair</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
8420
front/vue-project/package-lock.json
generated
8420
front/vue-project/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.3.6",
|
||||
"bootstrap": "^5.2.3",
|
||||
"bootstrap-vue": "^2.23.1",
|
||||
"sass-loader": "^13.2.2",
|
||||
"vue": "^3.2.47",
|
||||
|
@ -14,13 +14,13 @@ public class ComponentController {
|
||||
this.componentService = productService;
|
||||
}
|
||||
@PostMapping
|
||||
public ComponentDTO addComponent(@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
return new ComponentDTO(componentService.addComponent(componentDTO));
|
||||
public ComponentDTO addComponent(@RequestParam("name") String name, @RequestParam("amount") Integer amount) {
|
||||
return new ComponentDTO(componentService.addComponent(name, amount));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ComponentDTO updateComponent(@PathVariable Long id,@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
return new ComponentDTO(componentService.updateComponent(id,componentDTO));
|
||||
public ComponentDTO updateComponent(@PathVariable Long id,@RequestParam("name") String name, @RequestParam("amount") Integer amount) {
|
||||
return new ComponentDTO(componentService.updateComponent(id,name, amount));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
|
@ -14,13 +14,18 @@ public class FavorController {
|
||||
this.favorService = favorService;
|
||||
}
|
||||
@PostMapping
|
||||
public FavorDTO addFavor(@RequestBody @Valid FavorDTO favorDTO) {
|
||||
return new FavorDTO(favorService.addFavor(favorDTO));
|
||||
public FavorDTO addFavor(@RequestParam("name") String name, @RequestParam("price") Integer price) {
|
||||
return new FavorDTO(favorService.addFavor(name, price));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public FavorDTO updateFavor(@PathVariable Long id,@RequestBody @Valid FavorDTO favorDTO) {
|
||||
return new FavorDTO(favorService.updateFavor(id,favorDTO));
|
||||
public FavorDTO updateFavor(@PathVariable Long id,@RequestParam("name") String name, @RequestParam("price") Integer price) {
|
||||
return new FavorDTO(favorService.updateFavor(id,name, price));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/component")
|
||||
public FavorDTO putIntoFavor(@PathVariable Long id, @RequestParam("compId") Long compId){
|
||||
return new FavorDTO(favorService.addComponentToFavor(id, compId));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
|
@ -13,13 +13,18 @@ public class OrderController {
|
||||
this.orderService = productService;
|
||||
}
|
||||
@PostMapping
|
||||
public OrderDTO addOrder(@RequestBody @Valid OrderDTO orderDTO) {
|
||||
return new OrderDTO(orderService.addOrder(orderDTO));
|
||||
public OrderDTO addOrder(@RequestParam("date") String date) {
|
||||
return new OrderDTO(orderService.addOrder(date));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public OrderDTO updateOrder(@PathVariable Long id,@RequestBody @Valid OrderDTO orderDTO) {
|
||||
return new OrderDTO(orderService.updateOrder(id,orderDTO));
|
||||
public OrderDTO updateOrder(@PathVariable Long id,@RequestParam("date") String date) {
|
||||
return new OrderDTO(orderService.updateOrder(id,date));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/favor")
|
||||
public OrderDTO putIntoOrder(@PathVariable Long id, @RequestParam("favId") Long favId){
|
||||
return new OrderDTO(orderService.addFavorToOrder(id, favId));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
|
@ -32,8 +32,8 @@ public class ComponentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Component addComponent(ComponentDTO componentDTO) {
|
||||
final Component component = new Component(componentDTO.getComponentName(), componentDTO.getAmount());
|
||||
public Component addComponent(String name, int amount) {
|
||||
final Component component = new Component(name, amount);
|
||||
validatorUtil.validate(component);
|
||||
return componentRepository.save(component);
|
||||
}
|
||||
@ -50,10 +50,10 @@ public class ComponentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Component updateComponent(Long id, ComponentDTO componentDto) {
|
||||
public Component updateComponent(Long id, String name, int amount) {
|
||||
final Component currentComponent = findComponent(id);
|
||||
currentComponent.setComponentName(componentDto.getComponentName());
|
||||
currentComponent.setAmount(componentDto.getAmount());
|
||||
currentComponent.setComponentName(name);
|
||||
currentComponent.setAmount(amount);
|
||||
validatorUtil.validate(currentComponent);
|
||||
return componentRepository.save(currentComponent);
|
||||
}
|
||||
|
@ -22,15 +22,17 @@ import java.util.Optional;
|
||||
public class FavorService {
|
||||
private final FavorRepository favorRepository;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
public FavorService(FavorRepository favorRepository, ValidatorUtil validatorUtil){
|
||||
private final ComponentService componentService;
|
||||
public FavorService(FavorRepository favorRepository, ValidatorUtil validatorUtil, ComponentService componentService){
|
||||
this.favorRepository = favorRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
this.componentService = componentService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Favor addFavor(FavorDTO favorDTO) {
|
||||
public Favor addFavor(String name, int price) {
|
||||
|
||||
final Favor favor = new Favor(favorDTO.getFavorName(), favorDTO.getPrice());
|
||||
final Favor favor = new Favor(name, price);
|
||||
validatorUtil.validate(favor);
|
||||
return favorRepository.save(favor);
|
||||
}
|
||||
@ -47,10 +49,10 @@ public class FavorService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Favor updateFavor(Long id, FavorDTO favorDTO) {
|
||||
public Favor updateFavor(Long id, String name, int price) {
|
||||
final Favor currentFavor = findFavor(id);
|
||||
currentFavor.setFavorName(favorDTO.getFavorName());
|
||||
currentFavor.setPrice(favorDTO.getPrice());
|
||||
currentFavor.setFavorName(name);
|
||||
currentFavor.setPrice(price);
|
||||
validatorUtil.validate(currentFavor);
|
||||
return favorRepository.save(currentFavor);
|
||||
}
|
||||
@ -63,9 +65,10 @@ public class FavorService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Favor addComponentToFavor(FavorDTO favorDTO, Component component){
|
||||
final Favor currentFavor = findFavor(favorDTO.getId());
|
||||
currentFavor.addComponent(component);
|
||||
public Favor addComponentToFavor(Long FavorId, Long ComponentID){
|
||||
final Favor currentFavor = findFavor(FavorId);
|
||||
final Component currentComponent = componentService.findComponent(ComponentID);
|
||||
currentFavor.addComponent(currentComponent);
|
||||
return currentFavor;
|
||||
}
|
||||
|
||||
|
@ -23,15 +23,17 @@ import java.util.*;
|
||||
public class OrderService {
|
||||
private final OrderRepository orderRepository;
|
||||
private final ValidatorUtil validatorUtil;
|
||||
private final FavorService favorService;
|
||||
|
||||
public OrderService(OrderRepository orderRepository, ValidatorUtil validatorUtil){
|
||||
public OrderService(OrderRepository orderRepository, ValidatorUtil validatorUtil, FavorService favorService){
|
||||
this.orderRepository = orderRepository;
|
||||
this.validatorUtil = validatorUtil;
|
||||
this.favorService = favorService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Order addOrder(OrderDTO orderDTO) {
|
||||
final Order order = new Order(orderDTO.getDate());
|
||||
public Order addOrder(String date) {
|
||||
final Order order = new Order(getDate(date));
|
||||
validatorUtil.validate(order);
|
||||
return orderRepository.save(order);
|
||||
}
|
||||
@ -60,9 +62,9 @@ public class OrderService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Order updateOrder(Long id, OrderDTO orderDTO) {
|
||||
public Order updateOrder(Long id, String date) {
|
||||
final Order currentOrder = findOrder(id);
|
||||
currentOrder.setDate(orderDTO.getDate());
|
||||
currentOrder.setDate(getDate(date));
|
||||
validatorUtil.validate(currentOrder);
|
||||
return orderRepository.save(currentOrder);
|
||||
}
|
||||
@ -75,9 +77,10 @@ public class OrderService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Order addFavorToOrder(OrderDTO orderDTO, Favor favor){
|
||||
final Order currentOrder = findOrder(orderDTO.getId());
|
||||
currentOrder.addFavor(favor);
|
||||
public Order addFavorToOrder(Long orderId, Long favorId){
|
||||
final Order currentOrder = findOrder(orderId);
|
||||
final Favor currentFavor = favorService.findFavor(favorId);
|
||||
currentOrder.addFavor(currentFavor);
|
||||
validatorUtil.validate(currentOrder);
|
||||
orderRepository.save(currentOrder);
|
||||
return currentOrder;
|
||||
|
@ -6,6 +6,9 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import ru.ulstu.is.sbapp.repair.service.ComponentNotFoundException;
|
||||
import ru.ulstu.is.sbapp.repair.service.FavorNotFoundException;
|
||||
import ru.ulstu.is.sbapp.repair.service.OrderNotFoundException;
|
||||
import ru.ulstu.is.sbapp.repair.util.validation.ValidationException;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
@ -13,7 +16,10 @@ import java.util.stream.Collectors;
|
||||
@ControllerAdvice
|
||||
public class AdviceController {
|
||||
@ExceptionHandler({
|
||||
ValidationException.class
|
||||
ValidationException.class,
|
||||
ComponentNotFoundException.class,
|
||||
FavorNotFoundException.class,
|
||||
OrderNotFoundException.class
|
||||
})
|
||||
public ResponseEntity<Object> handleException(Throwable e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||
|
Loading…
Reference in New Issue
Block a user