|
|
@ -138,23 +138,25 @@ public class CommentController extends BaseController {
|
|
|
|
@GetMapping("/hot/{journalId}/{page}/{size}")
|
|
|
|
@GetMapping("/hot/{journalId}/{page}/{size}")
|
|
|
|
public Result findHotByJournalId(@PathVariable String journalId,@PathVariable int page,@PathVariable int size, @RequestHeader(value = "Authorization", required = false) String authorization) {
|
|
|
|
public Result findHotByJournalId(@PathVariable String journalId,@PathVariable int page,@PathVariable int size, @RequestHeader(value = "Authorization", required = false) String authorization) {
|
|
|
|
List<CommentResp> list = (List<CommentResp>) cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_HOT+"_"+journalId,page+"_"+size, key->getHotList(journalId,page,size),true).getValue();
|
|
|
|
List<CommentResp> list = (List<CommentResp>) cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_HOT+"_"+journalId,page+"_"+size, key->getHotList(journalId,page,size),true).getValue();
|
|
|
|
|
|
|
|
String count = cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_COUNT,journalId, key->getCommentListCount(journalId,page,size),true).getValue().toString();
|
|
|
|
// List<CommentResp> list = getHotList(journalId,page,size);
|
|
|
|
// List<CommentResp> list = getHotList(journalId,page,size);
|
|
|
|
//验证是否登录,并且拿到ID
|
|
|
|
//验证是否登录,并且拿到ID
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(list.size()),list));
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(count),list));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
|
|
|
|
|
|
|
|
Set<String> publicationLikeSet = publicationLikeDao.findAllByUserId(userId).parallelStream().map(p->p.getLikedItemId()).collect(Collectors.toSet());
|
|
|
|
Set<String> publicationLikeSet = publicationLikeDao.findAllByUserId(userId).parallelStream().map(p->p.getLikedItemId()).collect(Collectors.toSet());
|
|
|
|
list = list.parallelStream().map(c->updateHaveThumbup(c,publicationLikeSet)).collect(Collectors.toList());
|
|
|
|
list = list.parallelStream().map(c->updateHaveThumbup(c,publicationLikeSet)).collect(Collectors.toList());
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(list.size()),list));
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(count),list));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<CommentResp> getHotList(String journalId,int page,int size) {
|
|
|
|
private List<CommentResp> getHotList(String journalId,int page,int size) {
|
|
|
|
Page<Comment> pageList = commentService.findHotByJournalId(journalId,page,size);
|
|
|
|
Page<Comment> pageList = commentService.findHotByJournalId(journalId,page,size);
|
|
|
|
|
|
|
|
|
|
|
|
List<CommentResp> list =pageList.stream().parallel().map(x->getCommentResp(x)).collect(Collectors.toList());
|
|
|
|
List<CommentResp> list =pageList.stream().parallel().map(x->getCommentResp(x)).collect(Collectors.toList());
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -178,16 +180,17 @@ public class CommentController extends BaseController {
|
|
|
|
public Result findNewByJournalId(@PathVariable String journalId,@PathVariable int page,@PathVariable int size, @RequestHeader(value = "Authorization", required = false) String authorization) {
|
|
|
|
public Result findNewByJournalId(@PathVariable String journalId,@PathVariable int page,@PathVariable int size, @RequestHeader(value = "Authorization", required = false) String authorization) {
|
|
|
|
// List<CommentResp> list = getNewList(journalId,page,size);
|
|
|
|
// List<CommentResp> list = getNewList(journalId,page,size);
|
|
|
|
List<CommentResp> list = (List<CommentResp>) cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_NEW+"_"+journalId,page+"_"+size, key->getNewList(journalId,page,size),true).getValue();
|
|
|
|
List<CommentResp> list = (List<CommentResp>) cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_NEW+"_"+journalId,page+"_"+size, key->getNewList(journalId,page,size),true).getValue();
|
|
|
|
|
|
|
|
String count = cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_COMMENT_PAGE_COUNT,journalId, key->getCommentListCount(journalId,page,size),true).getValue().toString();
|
|
|
|
//验证是否登录,并且拿到ID
|
|
|
|
//验证是否登录,并且拿到ID
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(list.size()),list));
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(count),list));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
Set<String> publicationLikeSet = publicationLikeDao.findAllByUserId(userId).parallelStream().map(p->p.getLikedItemId()).collect(Collectors.toSet());
|
|
|
|
Set<String> publicationLikeSet = publicationLikeDao.findAllByUserId(userId).parallelStream().map(p->p.getLikedItemId()).collect(Collectors.toSet());
|
|
|
|
list = list.parallelStream().map(c->updateHaveThumbup(c,publicationLikeSet)).collect(Collectors.toList());
|
|
|
|
list = list.parallelStream().map(c->updateHaveThumbup(c,publicationLikeSet)).collect(Collectors.toList());
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(list.size()),list));
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(count),list));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CommentResp getCommentResp(Comment comment,String userId) {
|
|
|
|
private CommentResp getCommentResp(Comment comment,String userId) {
|
|
|
@ -436,7 +439,7 @@ public class CommentController extends BaseController {
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
UserLoginDto userLoginDto = getUserLoginDto(authorization);
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
if (null == userLoginDto) {
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(list.size()),list));
|
|
|
|
return Result.success(new PageResult<CommentResp>(Long.valueOf(count),list));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
String userId = userLoginDto.getUserId();
|
|
|
|
Set<String> publicationLikeSet = publicationLikeDao.findAllByUserId(userId).parallelStream().map(p->p.getLikedItemId()).collect(Collectors.toSet());
|
|
|
|
Set<String> publicationLikeSet = publicationLikeDao.findAllByUserId(userId).parallelStream().map(p->p.getLikedItemId()).collect(Collectors.toSet());
|
|
|
@ -456,6 +459,11 @@ public class CommentController extends BaseController {
|
|
|
|
Page<Comment> pageList = commentService.findByParentId(parentId,page,size);
|
|
|
|
Page<Comment> pageList = commentService.findByParentId(parentId,page,size);
|
|
|
|
return pageList.getTotalElements();
|
|
|
|
return pageList.getTotalElements();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Long getCommentListCount(String journalId,int page,int size) {
|
|
|
|
|
|
|
|
Page<Comment> pageList = commentService.findByJournalId(journalId,page,size);
|
|
|
|
|
|
|
|
return pageList.getTotalElements();
|
|
|
|
|
|
|
|
}
|
|
|
|
@ApiOperation(value = "点赞/取消点赞评论",notes = "返回")
|
|
|
|
@ApiOperation(value = "点赞/取消点赞评论",notes = "返回")
|
|
|
|
@PutMapping("/thumbup/{commentId}")
|
|
|
|
@PutMapping("/thumbup/{commentId}")
|
|
|
|
public Result thumbup(@PathVariable String commentId,@RequestHeader(value = "Authorization", required = true) String authorization) {
|
|
|
|
public Result thumbup(@PathVariable String commentId,@RequestHeader(value = "Authorization", required = true) String authorization) {
|
|
|
|