-
Notifications
You must be signed in to change notification settings - Fork 10
Book-strore #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Book-strore #2
Conversation
import javax.servlet.http.HttpServletResponse; | ||
|
||
@RestController | ||
@RequestMapping(value = "/api", produces = MediaType.APPLICATION_JSON_VALUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RequestMapping("api") must be enough ( produces etc not required actuallly )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) { | ||
authService.authenticate(authorization, response); | ||
BookResponse resp = new BookResponse(); | ||
if (response.getStatus() == 200) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same problem create a service class
import javax.servlet.http.HttpServletResponse; | ||
|
||
@RestController | ||
@Transactional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@transactional and produces same problem
return resp; | ||
} | ||
|
||
@PostMapping(value="/employees", produces = {"application/json"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
produces can remove
} | ||
|
||
|
||
@DeleteMapping(value = "/employees/{employeeId}", produces = {"application/json"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
produces can remove
|
||
@GetMapping(value = "/orders") | ||
public OrderInfoResponse getOrdersByPage( | ||
@RequestParam(value = "page", defaultValue = "0", required = false) Integer page, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.