lab 4 controllers done
This commit is contained in:
parent
5117a688fc
commit
f602164928
@ -14,31 +14,31 @@ public class ComponentController {
|
||||
this.componentService = productService;
|
||||
}
|
||||
@PostMapping
|
||||
public ComponentDTO addProduct(@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
public ComponentDTO addComponent(@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
return new ComponentDTO(componentService.addComponent(componentDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ComponentDTO updateProduct(@PathVariable Long id,@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
public ComponentDTO updateComponent(@PathVariable Long id,@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
return new ComponentDTO(componentService.updateComponent(id,componentDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ComponentDTO removeProduct(@PathVariable Long id) {
|
||||
public ComponentDTO removeComponent(@PathVariable Long id) {
|
||||
return new ComponentDTO(componentService.deleteComponent(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void removeAllProducts() {
|
||||
public void removeAllComponents() {
|
||||
componentService.deleteAllComponent();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ComponentDTO findProduct(@PathVariable Long id) {
|
||||
public ComponentDTO findComponent(@PathVariable Long id) {
|
||||
return new ComponentDTO(componentService.findComponent(id));
|
||||
}
|
||||
@GetMapping
|
||||
public List<ComponentDTO> findAllProduct() {
|
||||
public List<ComponentDTO> findAllComponents() {
|
||||
return componentService.findAllComponent()
|
||||
.stream()
|
||||
.map(ComponentDTO::new)
|
||||
|
@ -14,31 +14,31 @@ public class FavorController {
|
||||
this.favorService = favorService;
|
||||
}
|
||||
@PostMapping
|
||||
public FavorDTO addProduct(@RequestBody @Valid FavorDTO favorDTO) {
|
||||
public FavorDTO addFavor(@RequestBody @Valid FavorDTO favorDTO) {
|
||||
return new FavorDTO(favorService.addFavor(favorDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public FavorDTO updateProduct(@PathVariable Long id,@RequestBody @Valid FavorDTO favorDTO) {
|
||||
public FavorDTO updateFavor(@PathVariable Long id,@RequestBody @Valid FavorDTO favorDTO) {
|
||||
return new FavorDTO(favorService.updateFavor(id,favorDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public FavorDTO removeProduct(@PathVariable Long id) {
|
||||
public FavorDTO removeFavor(@PathVariable Long id) {
|
||||
return new FavorDTO(favorService.deleteFavor(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void removeAllProducts() {
|
||||
public void removeAllFavors() {
|
||||
favorService.deleteAllFavor();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public FavorDTO findProduct(@PathVariable Long id) {
|
||||
public FavorDTO findFavor(@PathVariable Long id) {
|
||||
return new FavorDTO(favorService.findFavor(id));
|
||||
}
|
||||
@GetMapping
|
||||
public List<FavorDTO> findAllProduct() {
|
||||
public List<FavorDTO> findAllFavors() {
|
||||
return favorService.findAllFavor()
|
||||
.stream()
|
||||
.map(FavorDTO::new)
|
||||
|
@ -1,4 +1,46 @@
|
||||
package ru.ulstu.is.sbapp.repair.controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.validation.Valid;
|
||||
import ru.ulstu.is.sbapp.repair.service.OrderService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/component")
|
||||
public class OrderController {
|
||||
private final OrderService orderService;
|
||||
public OrderController(OrderService productService){
|
||||
this.orderService = productService;
|
||||
}
|
||||
@PostMapping
|
||||
public OrderDTO addOrder(@RequestBody @Valid OrderDTO orderDTO) {
|
||||
return new OrderDTO(orderService.addOrder(orderDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public OrderDTO updateOrder(@PathVariable Long id,@RequestBody @Valid OrderDTO orderDTO) {
|
||||
return new OrderDTO(orderService.updateOrder(id,orderDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public OrderDTO removeOrder(@PathVariable Long id) {
|
||||
return new OrderDTO(orderService.deleteOrder(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void removeAllOrders() {
|
||||
orderService.deleteAllOrder();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public OrderDTO findOrder(@PathVariable Long id) {
|
||||
return new OrderDTO(orderService.findOrder(id));
|
||||
}
|
||||
@GetMapping
|
||||
public List<OrderDTO> findAllOrders() {
|
||||
return orderService.findAllOrders()
|
||||
.stream()
|
||||
.map(OrderDTO::new)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user