海外读书修改

This commit is contained in:
wuchunlei
2024-11-26 18:08:44 +08:00
parent 238a6364a4
commit f32146383b
3 changed files with 16 additions and 2 deletions

View File

@@ -40,7 +40,7 @@ public class BookAbroadController {
//评论树 //评论树
@RequestMapping("/getBookAbroadCommentTree") @RequestMapping("/getBookAbroadCommentTree")
public List<BookAbroadComment> getBookAbroadCommentTree(@RequestBody Map<String,Object> params) { public R getBookAbroadCommentTree(@RequestBody Map<String,Object> params) {
List<BookAbroadComment> comments = bookAbroadCommentService.list(new LambdaQueryWrapper<BookAbroadComment>() List<BookAbroadComment> comments = bookAbroadCommentService.list(new LambdaQueryWrapper<BookAbroadComment>()
.eq(BookAbroadComment::getBookId,params.get("bookId"))); .eq(BookAbroadComment::getBookId,params.get("bookId")));
List<BookAbroadComment> commentsTree = comments.stream().filter((bookAbroadComment) -> List<BookAbroadComment> commentsTree = comments.stream().filter((bookAbroadComment) ->
@@ -49,13 +49,15 @@ public class BookAbroadController {
comment.setIsLike(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>() comment.setIsLike(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
.eq(BookAbroadCommentLike::getCommentId,comment.getId()) .eq(BookAbroadCommentLike::getCommentId,comment.getId())
.eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId()))); .eq(BookAbroadCommentLike::getUserId,ShiroUtils.getUId())));
comment.setLikeCount(bookAbroadCommentLikeService.count(new LambdaQueryWrapper<BookAbroadCommentLike>()
.eq(BookAbroadCommentLike::getCommentId,comment.getId())));
comment.setUserEntity(userService.getOne(new LambdaQueryWrapper<MyUserEntity>() comment.setUserEntity(userService.getOne(new LambdaQueryWrapper<MyUserEntity>()
.select(MyUserEntity::getId,MyUserEntity::getName,MyUserEntity::getNickname,MyUserEntity::getAvatar) .select(MyUserEntity::getId,MyUserEntity::getName,MyUserEntity::getNickname,MyUserEntity::getAvatar)
.eq(MyUserEntity::getId,comment.getUserId()))); .eq(MyUserEntity::getId,comment.getUserId())));
comment.setChildren(getLabelChildrens(comment,comments)); comment.setChildren(getLabelChildrens(comment,comments));
return comment; return comment;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return commentsTree; return R.ok().put("commentsTree",commentsTree);
} }
private List<BookAbroadComment> getLabelChildrens(BookAbroadComment root,List<BookAbroadComment> all){ private List<BookAbroadComment> getLabelChildrens(BookAbroadComment root,List<BookAbroadComment> all){

View File

@@ -171,6 +171,16 @@ public class HomeController {
return R.ok().put("contentPage",contentPage); return R.ok().put("contentPage",contentPage);
} }
//已读\已买人数
@RequestMapping("/getBookReadCount")
public R getBookReadCount(@RequestBody Map<String,Object> params){
int readCount = bookReadRateService.count(new LambdaQueryWrapper<BookReadRateEntity>()
.eq(BookReadRateEntity::getBookId,params.get("bookId")));
int buyCount = userEbookBuyService.count(new LambdaQueryWrapper<UserEbookBuyEntity>()
.eq(UserEbookBuyEntity::getBookId,params.get("bookId")));
return R.ok().put("readCount",readCount).put("buyCount",buyCount);
}
//获取当前书的阅读记录 //获取当前书的阅读记录
@RequestMapping("/getBookReadRate") @RequestMapping("/getBookReadRate")
public R getBookReadRate(@RequestBody Map<String,Object> params){ public R getBookReadRate(@RequestBody Map<String,Object> params){

View File

@@ -33,6 +33,8 @@ public class BookAbroadComment implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private int isLike; private int isLike;
@TableField(exist = false) @TableField(exist = false)
private int likeCount;
@TableField(exist = false)
private MyUserEntity userEntity; private MyUserEntity userEntity;
@TableField(exist = false) @TableField(exist = false)
private List<BookAbroadComment> children; private List<BookAbroadComment> children;