Conversation
| import javax.servlet.http.HttpServletResponse; | ||
|
|
||
| @RestController | ||
| @RequestMapping(value = "/api", produces = MediaType.APPLICATION_JSON_VALUE) |
There was a problem hiding this comment.
@RequestMapping("api") must be enough ( produces etc not required actuallly )
| ) { | ||
| authService.authenticate(authorization, response); | ||
| BookResponse resp = new BookResponse(); | ||
| if (response.getStatus() == 200) { |
There was a problem hiding this comment.
In my opinion,controller classes must work like routers.All business logic can live inside service class and all layer can talk each other from top to buttom like controller->service->repository.So,you can move all business inside service class.
| authService.authenticate(authorization, response); | ||
| OperationResponse resp = new OperationResponse(); | ||
| if (response.getStatus() == 200) { | ||
| if (this.bookRepository.findBookById(book.getId()) != null) { |
There was a problem hiding this comment.
Same problem create a service class
| @RequestMapping(value = "/books/{bookId}", method = RequestMethod.DELETE, produces = {"application/json"}) | ||
| public OperationResponse deleteProduct(@PathVariable("bookId") Integer bookId, @RequestHeader(value = "Authorization") String authorization, HttpServletResponse response) { | ||
| authService.authenticate(authorization, response); | ||
| OperationResponse resp = new OperationResponse(); |
There was a problem hiding this comment.
Same problem create a service class
| public SingleDataSeriesResponse getProductStatsByQuantity(@RequestHeader(value = "Authorization") String authorization, HttpServletResponse response) { | ||
| authService.authenticate(authorization, response); | ||
| SingleDataSeriesResponse resp = new SingleDataSeriesResponse(); | ||
| if (response.getStatus() == 200) { |
There was a problem hiding this comment.
Same problem create a service class
| import javax.servlet.http.HttpServletResponse; | ||
|
|
||
| @RestController | ||
| @Transactional |
| return resp; | ||
| } | ||
|
|
||
| @PostMapping(value="/employees", produces = {"application/json"}) |
| } | ||
|
|
||
|
|
||
| @DeleteMapping(value = "/employees/{employeeId}", produces = {"application/json"}) |
|
|
||
| @GetMapping(value = "/orders") | ||
| public OrderInfoResponse getOrdersByPage( | ||
| @RequestParam(value = "page", defaultValue = "0", required = false) Integer page, |
There was a problem hiding this comment.
to much parameter inside.You can wrap it into a request class if possible
| where = where + " and order_id = " + orderId; | ||
| } | ||
|
|
||
| List<Map<String, Object>> list = jdbcTemplate.queryForList(sql + where + order); |
There was a problem hiding this comment.
Opppss! Where is the clean code :) You can move all business inside service layer.Also please use Java 8 futeres like lambda,streams.https://www.baeldung.com/java-8-streams
This upgrade contains a book-store. Here you can manage the shipping of the books. First you can login with your account. On the dashboard you can see the pie chart and the bar graph of the ordered books. You can switch between the the diagrams. On the orders page the shipped books details are seen. If you press on an ID it can show you more details about the ordered book(s) and the shipping info. Next page is the books page. The page lists the current available book in the strore. You can see the cost of the book, the category etc. Next page is the customers. If someone order a book his/her details can found here. Since the size of the customers are so big, the scrolling feature is implemented by an "infinity scrolling" function. The last page is the employees. It is kindly similar to the customers by listing their details and infos.