新版
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.app.entity.UserEntity;
|
||||
import com.peanut.modules.app.service.UserService;
|
||||
import com.peanut.modules.book.dao.BookForumArticlesDao;
|
||||
import com.peanut.modules.book.entity.*;
|
||||
import com.peanut.modules.book.service.*;
|
||||
import com.peanut.modules.book.vo.BookForumArticlesVO;
|
||||
@@ -23,6 +31,10 @@ public class BookForumArticlesServiceController {
|
||||
private AuthorService authorService;
|
||||
@Autowired
|
||||
private PublisherService publisherService;
|
||||
@Autowired
|
||||
private BookForumArticlesDao bookForumArticlesDao;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 列表 (开始时间倒叙) 后台get请求
|
||||
@@ -46,6 +58,174 @@ public class BookForumArticlesServiceController {
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取书评首页列表(最新)
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("getForumsNew")
|
||||
public R getForumsNew(@RequestParam Integer limit,@RequestParam Integer page){
|
||||
MPJLambdaWrapper<BookForumArticlesEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(BookForumArticlesEntity.class);
|
||||
wrapper.selectAs(BookEntity::getImages,"bookimage");
|
||||
wrapper.selectAs(BookEntity::getName,"bookname");
|
||||
wrapper.selectAs(AuthorEntity::getAuthorName,"bookauthor");
|
||||
wrapper.leftJoin(BookEntity.class,BookEntity::getId,BookForumArticlesEntity::getBookid);
|
||||
wrapper.leftJoin(AuthorEntity.class,AuthorEntity::getId,BookEntity::getAuthorId);
|
||||
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
|
||||
wrapper.eq(BookEntity::getDelFlag,0);
|
||||
Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesDao.selectJoinPage(new Page<>(page, limit), BookForumArticlesEntity.class, wrapper);
|
||||
|
||||
for (BookForumArticlesEntity b : bookForumArticlesEntityPage.getRecords()){
|
||||
List<BookForumCommentEntity> commentsLimit = bookForumCommenService.getCommentsLimit(b.getId(), 3);
|
||||
Integer commentcount = bookForumCommenService.getCommentcount(b.getId());
|
||||
b.setComment(commentsLimit);
|
||||
b.setCommentNum(commentcount);
|
||||
}
|
||||
|
||||
|
||||
return R.ok().put("page",bookForumArticlesEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取书评首页列表(最热)
|
||||
* @param limit
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getForumsHot")
|
||||
public R getForumsHot(@RequestParam Integer limit,@RequestParam Integer page){
|
||||
|
||||
MPJLambdaWrapper<BookForumArticlesEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(BookForumArticlesEntity.class);
|
||||
wrapper.selectAs(BookEntity::getImages,"bookimage");
|
||||
wrapper.selectAs(BookEntity::getName,"bookname");
|
||||
wrapper.selectAs(AuthorEntity::getAuthorName,"bookauthor");
|
||||
wrapper.leftJoin(BookEntity.class,BookEntity::getId,BookForumArticlesEntity::getBookid);
|
||||
wrapper.leftJoin(AuthorEntity.class,AuthorEntity::getId,BookEntity::getAuthorId);
|
||||
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
|
||||
wrapper.eq(BookEntity::getDelFlag,0);
|
||||
wrapper.orderByDesc(BookForumArticlesEntity::getContlike);
|
||||
Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesDao.selectJoinPage(new Page<>(page, limit), BookForumArticlesEntity.class, wrapper);
|
||||
|
||||
for (BookForumArticlesEntity b : bookForumArticlesEntityPage.getRecords()){
|
||||
List<BookForumCommentEntity> commentsLimit = bookForumCommenService.getCommentsLimit(b.getId(), 3);
|
||||
Integer commentcount = bookForumCommenService.getCommentcount(b.getId());
|
||||
b.setComment(commentsLimit);
|
||||
b.setCommentNum(commentcount);
|
||||
}
|
||||
|
||||
|
||||
return R.ok().put("page",bookForumArticlesEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取书评首页列表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getForumsAndBook")
|
||||
public R getForumsAndBook(@RequestParam Integer userId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
String existSql = "select 1 from book_forum_articles where book.id = bookid";
|
||||
LambdaQueryWrapper<BookEntity> wrapper = new LambdaQueryWrapper<BookEntity>();
|
||||
wrapper.eq(BookEntity::getDelFlag,0);
|
||||
wrapper.exists(existSql);
|
||||
Page<BookEntity> bookEntityPage = bookService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
|
||||
for (BookEntity b :bookEntityPage.getRecords()){
|
||||
List<BookForumArticlesEntity> forumsLimit = bookForumArticlesService.getForumsLimit(b.getId(), 4);
|
||||
b.setForums(forumsLimit);
|
||||
}
|
||||
|
||||
return R.ok().put("page",bookEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞书评帖子
|
||||
* @param forum_id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/chickForumContlike")
|
||||
public R chickForumContlike(@RequestParam Integer forum_id){
|
||||
UpdateWrapper<BookForumArticlesEntity> wrapper = new UpdateWrapper<>();
|
||||
wrapper.setSql("contlike = contlike + 1");
|
||||
wrapper.eq("id",forum_id);
|
||||
boolean update = bookForumArticlesService.update(null, wrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞书评帖子回复
|
||||
* @param comment_id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/chickCommentConlike")
|
||||
public R chickCommentConlike(@RequestParam Integer comment_id){
|
||||
UpdateWrapper<BookForumCommentEntity> wrapper = new UpdateWrapper<BookForumCommentEntity>();
|
||||
wrapper.setSql("contlike = contlike + 1");
|
||||
wrapper.eq("id",comment_id);
|
||||
boolean update = bookForumCommenService.update(null, wrapper);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取单本书的书评列表
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getForumByBook")
|
||||
public R getForumByBook(@RequestParam Integer bookId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
LambdaQueryWrapper<BookForumArticlesEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
|
||||
wrapper.orderByDesc(BookForumArticlesEntity::getCreateTime);
|
||||
Page<BookForumArticlesEntity> bookForumArticlesEntityPage = bookForumArticlesService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
for (BookForumArticlesEntity b:bookForumArticlesEntityPage.getRecords()){
|
||||
b.setUser(userService.getById(b.getUserid()));
|
||||
b.setComment(bookForumCommenService.getCommentsLimit(b.getId(),3));
|
||||
}
|
||||
return R.ok().put("page",bookForumArticlesEntityPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单帖子的全部回复
|
||||
* @param forumId
|
||||
* @param limit
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getCommentByForum")
|
||||
public R getCommentByForum(@RequestParam Integer forumId,@RequestParam Integer limit,@RequestParam Integer page){
|
||||
LambdaQueryWrapper<BookForumCommentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(BookForumCommentEntity::getDelflag,0);
|
||||
wrapper.gt(BookForumCommentEntity::getPid,0);
|
||||
wrapper.orderByAsc(BookForumCommentEntity::getCreateTime);
|
||||
Page<BookForumCommentEntity> bookForumCommentEntityPage = bookForumCommenService.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
for (BookForumCommentEntity b : bookForumCommentEntityPage.getRecords()){
|
||||
b.setComments(bookForumCommenService.getChildComments(b.getId()));
|
||||
b.setUser(userService.getById(b.getUserid()));
|
||||
b.setPuser(userService.getById(b.getPuserid()));
|
||||
}
|
||||
return R.ok().put("page",bookForumCommentEntityPage);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/pushMsgToForum")
|
||||
public R pushMsgToForum(
|
||||
@RequestParam Integer forumId,
|
||||
@RequestParam String content,
|
||||
@RequestParam Integer userId,
|
||||
@RequestParam(required = false,value = "0") Integer pid,
|
||||
@RequestParam(required = false,value = "0") Integer puserId){
|
||||
BookForumArticlesEntity forumInfo = bookForumArticlesService.getById(forumId);
|
||||
BookForumCommentEntity bookForumCommentEntity = new BookForumCommentEntity();
|
||||
bookForumCommentEntity.setBfaid(forumId);
|
||||
bookForumCommentEntity.setUserid(userId);
|
||||
bookForumCommentEntity.setContent(content.trim());
|
||||
bookForumCommentEntity.setBookid(forumInfo.getBookid());
|
||||
bookForumCommentEntity.setPid(pid);
|
||||
bookForumCommentEntity.setPuserid(puserId);
|
||||
bookForumCommenService.save(bookForumCommentEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/desc/{page}")
|
||||
|
||||
Reference in New Issue
Block a user