|
20 | 20 | import org.springframework.web.bind.annotation.RequestMapping;
|
21 | 21 | import org.springframework.web.bind.annotation.RestController;
|
22 | 22 |
|
23 |
| -import JEstebanC.FastFoodApp.model.CategoryIngredient; |
| 23 | +import JEstebanC.FastFoodApp.model.CategoryAdditional; |
24 | 24 | import JEstebanC.FastFoodApp.model.Response;
|
25 |
| -import JEstebanC.FastFoodApp.service.CategoryIngredientServiceImp; |
| 25 | +import JEstebanC.FastFoodApp.service.CategoryAdditionalServiceImp; |
26 | 26 | import lombok.RequiredArgsConstructor;
|
27 | 27 |
|
28 | 28 | /**
|
29 | 29 | * @author Juan Esteban Castaño Holguin castanoesteban9@gmail.com 2022-01-24
|
30 | 30 | */
|
31 | 31 | @RestController
|
32 | 32 | @RequiredArgsConstructor
|
33 |
| -@RequestMapping("/category-ingredient") |
34 |
| -public class CategoryIngredientController { |
| 33 | +@RequestMapping("/category-additional") |
| 34 | +public class CategoryAdditionalController { |
35 | 35 |
|
36 | 36 | @Autowired
|
37 |
| - private final CategoryIngredientServiceImp serviceImp; |
| 37 | + private final CategoryAdditionalServiceImp serviceImp; |
38 | 38 |
|
39 | 39 | // CREATE
|
40 | 40 | @PostMapping()
|
41 |
| - public ResponseEntity<Response> saveCategoryIngredient(@RequestBody @Valid CategoryIngredient categoryIngredient) { |
| 41 | + public ResponseEntity<Response> saveCategoryAdditional(@RequestBody @Valid CategoryAdditional categoryAdditional) { |
42 | 42 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
43 |
| - .data(Map.of("categoryIngredient", serviceImp.create(categoryIngredient))) |
44 |
| - .message("Create category ingredient").status(HttpStatus.OK).statusCode(HttpStatus.OK.value()).build()); |
| 43 | + .data(Map.of("categoryAdditional", serviceImp.create(categoryAdditional))) |
| 44 | + .message("Create category additional").status(HttpStatus.OK).statusCode(HttpStatus.OK.value()).build()); |
45 | 45 | }
|
46 | 46 |
|
47 | 47 | // READ
|
48 | 48 | @GetMapping(value = "/list")
|
49 |
| - public ResponseEntity<Response> getCategoryIngredient() { |
| 49 | + public ResponseEntity<Response> getCategoryAdditional() { |
50 | 50 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
51 |
| - .data(Map.of("categoryIngredient", serviceImp.list())).message("List categories ingredients") |
| 51 | + .data(Map.of("categoryAdditional", serviceImp.list())).message("List categories additionals") |
52 | 52 | .status(HttpStatus.OK).statusCode(HttpStatus.OK.value()).build());
|
53 | 53 | }
|
54 | 54 |
|
55 | 55 | // UPDATE
|
56 | 56 | @PutMapping(value = "/{id}")
|
57 |
| - public ResponseEntity<Response> updateCategoryIngredient(@PathVariable("id") Long id, |
58 |
| - @RequestBody @Valid CategoryIngredient categoryIngredient) { |
| 57 | + public ResponseEntity<Response> updateCategoryAdditional(@PathVariable("id") Long id, |
| 58 | + @RequestBody @Valid CategoryAdditional categoryAdditional) { |
59 | 59 | if (serviceImp.exist(id)) {
|
60 | 60 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
61 |
| - .data(Map.of("categoryIngredient", serviceImp.update(categoryIngredient))) |
62 |
| - .message("Update category ingredient with id:" + id).status(HttpStatus.OK) |
| 61 | + .data(Map.of("categoryAdditional", serviceImp.update(categoryAdditional))) |
| 62 | + .message("Update category additional with id:" + id).status(HttpStatus.OK) |
63 | 63 | .statusCode(HttpStatus.OK.value()).build());
|
64 | 64 | } else {
|
65 | 65 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
66 |
| - .message("The category ingredient with id:" + id + " does not exist").status(HttpStatus.BAD_REQUEST) |
| 66 | + .message("The category additional with id:" + id + " does not exist").status(HttpStatus.BAD_REQUEST) |
67 | 67 | .statusCode(HttpStatus.BAD_REQUEST.value()).build());
|
68 | 68 | }
|
69 | 69 | }
|
70 | 70 |
|
71 | 71 | // DELETE
|
72 | 72 | @DeleteMapping(value = "/{id}")
|
73 |
| - public ResponseEntity<Response> deleteCategoryIngredient(@PathVariable("id") Long id) { |
| 73 | + public ResponseEntity<Response> deleteCategoryAdditional(@PathVariable("id") Long id) { |
74 | 74 | if (serviceImp.exist(id)) {
|
75 | 75 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
76 |
| - .data(Map.of("categoryIngredient", serviceImp.delete(id))) |
77 |
| - .message("Delete category ingredient with id: " + id).status(HttpStatus.OK) |
| 76 | + .data(Map.of("categoryAdditional", serviceImp.delete(id))) |
| 77 | + .message("Delete category additional with id: " + id).status(HttpStatus.OK) |
78 | 78 | .statusCode(HttpStatus.OK.value()).build());
|
79 | 79 | } else {
|
80 | 80 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
81 |
| - .message("The category ingredient " + id + " does not exist").status(HttpStatus.BAD_REQUEST) |
| 81 | + .message("The category additional " + id + " does not exist").status(HttpStatus.BAD_REQUEST) |
82 | 82 | .statusCode(HttpStatus.BAD_REQUEST.value()).build());
|
83 | 83 | }
|
84 | 84 | }
|
85 | 85 |
|
86 | 86 | // SEARCH BY NAME
|
87 | 87 | @GetMapping(value = "/{name}")
|
88 |
| - public ResponseEntity<Response> getCategoryIngredientByName(@PathVariable("name") String name) { |
| 88 | + public ResponseEntity<Response> getCategoryAdditionalByName(@PathVariable("name") String name) { |
89 | 89 | if (serviceImp.findByName(name) != null) {
|
90 | 90 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
91 |
| - .data(Map.of("categoryIngredient", serviceImp.findByName(name))) |
92 |
| - .message("Get category ingredient by name: " + name).status(HttpStatus.OK) |
| 91 | + .data(Map.of("categoryAdditional", serviceImp.findByName(name))) |
| 92 | + .message("Get category additional by name: " + name).status(HttpStatus.OK) |
93 | 93 | .statusCode(HttpStatus.OK.value()).build());
|
94 | 94 | } else {
|
95 | 95 | return ResponseEntity.ok(Response.builder().timeStamp(Instant.now())
|
96 |
| - .message("The category ingredient called" + name + " does not exist").status(HttpStatus.BAD_REQUEST) |
| 96 | + .message("The category additional called" + name + " does not exist").status(HttpStatus.BAD_REQUEST) |
97 | 97 | .statusCode(HttpStatus.BAD_REQUEST.value()).build());
|
98 | 98 | }
|
99 | 99 |
|
|
0 commit comments