Archived
Add ByCategory component.
This commit is contained in:
@@ -57,9 +57,9 @@ public class PostController {
|
||||
|
||||
@JsonView(View.PostDTO.class)
|
||||
@GetMapping("/{postKey}")
|
||||
public PostDTO getByKey(@PathVariable("postKey") final String pPostKey,
|
||||
public Post getByKey(@PathVariable("postKey") final String pPostKey,
|
||||
final HttpServletResponse response) {
|
||||
final PostDTO result = getByKeyAndSource(pPostKey, response);
|
||||
final Post result = getByKeyAndSource(pPostKey, response);
|
||||
if(result != null) {
|
||||
result.setText(parserService.parse(result.getText()));
|
||||
}
|
||||
@@ -68,13 +68,13 @@ public class PostController {
|
||||
|
||||
@JsonView(View.PostDTO.class)
|
||||
@GetMapping("/{postKey}/source")
|
||||
public PostDTO getByKeyAndSource(@PathVariable("postKey")final String pPostKey,
|
||||
public Post getByKeyAndSource(@PathVariable("postKey")final String pPostKey,
|
||||
final HttpServletResponse response) {
|
||||
PostDTO result = null;
|
||||
Post result = null;
|
||||
|
||||
final Optional<Post> post = postRepository.getByKey(pPostKey);
|
||||
if(post.isPresent()) {
|
||||
result = new PostDTO(post.get());
|
||||
result = post.get();
|
||||
} else {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
@@ -96,9 +96,8 @@ public class PostController {
|
||||
|
||||
@JsonView(View.PostDTO.class)
|
||||
@GetMapping("/byCategory/{categoryId}")
|
||||
public List<PostDTO> getByCategory(@PathVariable("categoryId") final Long pCategoryId) {
|
||||
return postRepository.getByCategoryId(pCategoryId).stream()
|
||||
.map(PostDTO::new).collect(Collectors.toList());
|
||||
public List<Post> getByCategory(@PathVariable("categoryId") final Long pCategoryId) {
|
||||
return postRepository.getByCategoryId(pCategoryId);
|
||||
}
|
||||
|
||||
@JsonView(View.PostDTO.class)
|
||||
|
||||
Reference in New Issue
Block a user