lab 4 component controller done
This commit is contained in:
parent
1170d7f691
commit
e57f9fc252
@ -0,0 +1,47 @@
|
||||
package ru.ulstu.is.sbapp.repair.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.validation.Valid;
|
||||
import ru.ulstu.is.sbapp.repair.service.ComponentService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/component")
|
||||
public class ComponentController {
|
||||
private final ComponentService componentService;
|
||||
public ComponentController(ComponentService productService){
|
||||
this.componentService = productService;
|
||||
}
|
||||
@PostMapping
|
||||
public ComponentDTO addProduct(@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
return new ComponentDTO(componentService.addComponent(componentDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ComponentDTO updateProduct(@PathVariable Long id,@RequestBody @Valid ComponentDTO componentDTO) {
|
||||
return new ComponentDTO(componentService.updateComponent(id,componentDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ComponentDTO removeProduct(@PathVariable Long id) {
|
||||
return new ComponentDTO(componentService.deleteComponent(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public void removeAllProducts() {
|
||||
componentService.deleteAllComponent();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ComponentDTO findProduct(@PathVariable Long id) {
|
||||
return new ComponentDTO(componentService.findComponent(id));
|
||||
}
|
||||
@GetMapping
|
||||
public List<ComponentDTO> findAllProduct() {
|
||||
return componentService.findAllComponent()
|
||||
.stream()
|
||||
.map(ComponentDTO::new)
|
||||
.toList();
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ru.ulstu.is.sbapp.repair.controller;
|
||||
|
||||
public class FavorController {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ru.ulstu.is.sbapp.repair.controller;
|
||||
|
||||
public class OrderController {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user