Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
gellertnagy wants to merge2 commits intoenesacikoglu:master
base:master
Choose a base branch
Loading
fromgellertnagy:gellertnagy_patch

Conversation

@gellertnagy
Copy link

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.

enesacikoglu reacted with heart emoji
fronted_readme_images changes
backend_upload
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping(value = "/api", produces = MediaType.APPLICATION_JSON_VALUE)

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 )

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) {

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) {

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();

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) {

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

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"})

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"})

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,

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);

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@enesacikogluenesacikogluenesacikoglu left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@gellertnagy@enesacikoglu

[8]ページ先頭

©2009-2025 Movatter.jp