diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java index 1da24e6..9a5bea6 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java @@ -92,7 +92,24 @@ public class CommentController extends BaseController { * ,页面在请求添加评论的时候,当给评论添加子评论的时候,父评论parentID有值,就无法添加子评论并且不显示回复2字,控制到两级 * @return */ - + @ApiOperation(value = "根据期刊ID获取分页评论列表(废除),用最新和热门两个接口,可以默认用热门展示",notes = "根据期刊ID获取根节点评论分页列表 ,数据库中保存的有期刊号的都是根节点,期刊号为空的代表有父评论且parentID一定有值,拿到当然根节点评论列表,每个根评论有 commentCount字段,页面可以显示有 280个回复,然后根据 @GetMapping(\"/comment/{parentId}/{page}/{size}\") 接口,分页拿到该评论下的子评论列表,页面在请求添加评论的时候,当给评论添加子评论的时候,父评论parentID有值,就无法添加子评论并且不显示回复2字,控制到两级") + @ApiImplicitParams({@ApiImplicitParam(name = "journalId", value = "剘刊id", required = true), + @ApiImplicitParam(name = "page", value = "分页: 页码,以1开始", required = true), + @ApiImplicitParam(name = "size", value = "分页: 每页数量", required = true)}) + @GetMapping("/{journalId}/{page}/{size}") + public Result findAllByJournalId(@PathVariable String journalId,@PathVariable int page,@PathVariable int size, @RequestHeader(value = "Authorization", required = false) String authorization) { + //验证是否登录,并且拿到ID + UserLoginDto userLoginDto = getUserLoginDto(authorization); + if (null == userLoginDto) { + Page pageList = commentService.findByJournalId(journalId,page,size); + List list =pageList.stream().map(x->getCommentResp(x,"")).collect(Collectors.toList()); + return Result.success(new PageResult(Long.valueOf(list.size()),list)); + } + String userId = userLoginDto.getUserId(); + Page pageList = commentService.findByJournalId(journalId,page,size); + List list =pageList.stream().map(x->getCommentResp(x,userId)).collect(Collectors.toList()); + return Result.success(new PageResult(Long.valueOf(list.size()),list)); + } @ApiOperation(value = "根据期刊ID获取分页评论列表(热门),按点赞数倒序",notes = "根据期刊ID获取根节点评论分页列表 ,数据库中保存的有期刊号的都是根节点,期刊号为空的代表有父评论且parentID一定有值,拿到当然根节点评论列表,每个根评论有 commentCount字段,页面可以显示有 280个回复,然后根据 @GetMapping(\"/comment/{parentId}/{page}/{size}\") 接口,分页拿到该评论下的子评论列表,页面在请求添加评论的时候,当给评论添加子评论的时候,父评论parentID有值,就无法添加子评论并且不显示回复2字,控制到两级")