Commit 3b4d53ce by 段启岩

PostApi /my/post,验证参数

parent 40d0e1ee
...@@ -107,7 +107,10 @@ public class PostApi { ...@@ -107,7 +107,10 @@ public class PostApi {
@Anonymous @Anonymous
@ApiOperation("动态列表") @ApiOperation("动态列表")
@GetMapping("/posts") @GetMapping("/posts")
public Response<PageVO<PostVO>> getPostPage (@Valid PageForm pageForm) { public Response<?> getPostPage (@Valid PageForm pageForm, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return Response.fieldError(bindingResult.getFieldError());
}
IPage<Post> postPage = postService.getPostPage(pageForm.getPage(),pageForm.getSize()); IPage<Post> postPage = postService.getPostPage(pageForm.getPage(),pageForm.getSize());
List<PostVO> postVOList = postPage.getRecords().stream() List<PostVO> postVOList = postPage.getRecords().stream()
.map(post -> { .map(post -> {
...@@ -150,7 +153,10 @@ public class PostApi { ...@@ -150,7 +153,10 @@ public class PostApi {
@Anonymous @Anonymous
@ApiOperation("他人动态列表") @ApiOperation("他人动态列表")
@GetMapping("/user/{userId}/posts") @GetMapping("/user/{userId}/posts")
public Response<PageVO<Post>> getOtherPosts (@PathVariable("userId") String userId , @Valid PageForm pageForm) { public Response<?> getOtherPosts (@PathVariable("userId") String userId , @Valid PageForm pageForm, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return Response.fieldError(bindingResult.getFieldError());
}
IPage<Post> postPage = postService.getUserPostPage(pageForm.getPage(), pageForm.getSize(), userId); IPage<Post> postPage = postService.getUserPostPage(pageForm.getPage(), pageForm.getSize(), userId);
PageVO<Post> postPageVO = new PageVO<>(postPage); PageVO<Post> postPageVO = new PageVO<>(postPage);
return Response.success(postPageVO); return Response.success(postPageVO);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment