新版
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
package com.peanut.modules.book.controller;
|
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.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.PageUtils;
|
||||||
import com.peanut.common.utils.R;
|
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.entity.*;
|
||||||
import com.peanut.modules.book.service.*;
|
import com.peanut.modules.book.service.*;
|
||||||
import com.peanut.modules.book.vo.BookForumArticlesVO;
|
import com.peanut.modules.book.vo.BookForumArticlesVO;
|
||||||
@@ -23,6 +31,10 @@ public class BookForumArticlesServiceController {
|
|||||||
private AuthorService authorService;
|
private AuthorService authorService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private PublisherService publisherService;
|
private PublisherService publisherService;
|
||||||
|
@Autowired
|
||||||
|
private BookForumArticlesDao bookForumArticlesDao;
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表 (开始时间倒叙) 后台get请求
|
* 列表 (开始时间倒叙) 后台get请求
|
||||||
@@ -46,6 +58,174 @@ public class BookForumArticlesServiceController {
|
|||||||
return R.ok().put("page", page);
|
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}")
|
@RequestMapping("/desc/{page}")
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.*;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,6 +160,8 @@ public class BookEntity implements Serializable {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Boolean isBuy;
|
private Boolean isBuy;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<BookForumArticlesEntity> forums;
|
||||||
|
|
||||||
|
|
||||||
// @TableField(exist = false)
|
// @TableField(exist = false)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.peanut.modules.book.entity;
|
package com.peanut.modules.book.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.peanut.modules.app.entity.UserEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章表主表
|
* 文章表主表
|
||||||
@@ -63,7 +66,7 @@ public class BookForumArticlesEntity {
|
|||||||
* 点赞数
|
* 点赞数
|
||||||
*/
|
*/
|
||||||
@TableField("contlike")
|
@TableField("contlike")
|
||||||
private Date contlike;
|
private Integer contlike;
|
||||||
|
|
||||||
@TableField("del_flag")
|
@TableField("del_flag")
|
||||||
@TableLogic
|
@TableLogic
|
||||||
@@ -81,6 +84,24 @@ public class BookForumArticlesEntity {
|
|||||||
@TableField("bookdesc")
|
@TableField("bookdesc")
|
||||||
private String bookdesc;
|
private String bookdesc;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String bookimage;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String bookname;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String bookauthor;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<BookForumCommentEntity> comment;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer commentNum;
|
||||||
|
|
||||||
|
//说话的人
|
||||||
|
@TableField(exist = false)
|
||||||
|
private UserEntity user;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ package com.peanut.modules.book.entity;
|
|||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.peanut.modules.app.entity.UserEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评价文章表
|
* 评价文章表
|
||||||
@@ -24,12 +26,16 @@ public class BookForumCommentEntity {
|
|||||||
*文章父id
|
*文章父id
|
||||||
*/
|
*/
|
||||||
@TableField("bfa_id")
|
@TableField("bfa_id")
|
||||||
private String bfaid;
|
private Integer bfaid;
|
||||||
/**
|
/**
|
||||||
*用户评论id
|
*用户评论id
|
||||||
*/
|
*/
|
||||||
@TableField("userid")
|
@TableField("userid")
|
||||||
private String userid;
|
private Integer userid;
|
||||||
|
@TableField("puserid")
|
||||||
|
private Integer puserid;
|
||||||
|
@TableField("pid")
|
||||||
|
private Integer pid;
|
||||||
/**
|
/**
|
||||||
*内容
|
*内容
|
||||||
*/
|
*/
|
||||||
@@ -50,6 +56,10 @@ public class BookForumCommentEntity {
|
|||||||
*/
|
*/
|
||||||
@TableField(fill = FieldFill.UPDATE)
|
@TableField(fill = FieldFill.UPDATE)
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
@TableField("contlike")
|
||||||
|
private Integer contlike;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@@ -58,4 +68,16 @@ public class BookForumCommentEntity {
|
|||||||
private Integer delflag;
|
private Integer delflag;
|
||||||
@TableField("book_id")
|
@TableField("book_id")
|
||||||
private Integer bookid;
|
private Integer bookid;
|
||||||
|
|
||||||
|
//发言者
|
||||||
|
@TableField(exist = false)
|
||||||
|
private UserEntity user;
|
||||||
|
|
||||||
|
//对谁说
|
||||||
|
@TableField(exist = false)
|
||||||
|
private UserEntity puser;
|
||||||
|
|
||||||
|
//子对话
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<BookForumCommentEntity> comments;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface BookForumArticlesService extends IService<BookForumArticlesEntity> {
|
public interface BookForumArticlesService extends IService<BookForumArticlesEntity> {
|
||||||
@@ -12,5 +13,8 @@ public interface BookForumArticlesService extends IService<BookForumArticlesEn
|
|||||||
PageUtils queryPages(Map<String, Object> params);
|
PageUtils queryPages(Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
List<BookForumArticlesEntity> getForumsLimit(Integer book_id,Integer limit);
|
||||||
|
|
||||||
|
Integer getForumsCount(Integer book_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,18 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.modules.book.entity.BookForumCommentEntity;
|
import com.peanut.modules.book.entity.BookForumCommentEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface BookForumCommenService extends IService<BookForumCommentEntity> {
|
public interface BookForumCommenService extends IService<BookForumCommentEntity> {
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
PageUtils importlistqueryPages(Map<String, Object> params);
|
PageUtils importlistqueryPages(Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
List<BookForumCommentEntity> getCommentsLimit(Integer forum_id,Integer limit);
|
||||||
|
|
||||||
|
Integer getCommentcount(Integer forum_id);
|
||||||
|
|
||||||
|
List<BookForumCommentEntity> getChildComments(Integer cid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.peanut.modules.book.service.impl;
|
package com.peanut.modules.book.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.common.utils.Query;
|
import com.peanut.common.utils.Query;
|
||||||
|
import com.peanut.modules.app.service.UserService;
|
||||||
import com.peanut.modules.book.dao.BookForumArticlesDao;
|
import com.peanut.modules.book.dao.BookForumArticlesDao;
|
||||||
import com.peanut.modules.book.entity.AuthorEntity;
|
import com.peanut.modules.book.entity.AuthorEntity;
|
||||||
import com.peanut.modules.book.entity.BookEntity;
|
import com.peanut.modules.book.entity.BookEntity;
|
||||||
@@ -24,6 +26,8 @@ import java.util.Map;
|
|||||||
@Service
|
@Service
|
||||||
public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesDao, BookForumArticlesEntity> implements BookForumArticlesService {
|
public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesDao, BookForumArticlesEntity> implements BookForumArticlesService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
UserService userService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,5 +61,27 @@ public class BookForumArticlesServiceImpl extends ServiceImpl<BookForumArticlesD
|
|||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BookForumArticlesEntity> getForumsLimit(Integer book_id,Integer limit) {
|
||||||
|
LambdaQueryWrapper<BookForumArticlesEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
|
||||||
|
wrapper.eq(BookForumArticlesEntity::getBookid,book_id);
|
||||||
|
wrapper.orderByDesc(BookForumArticlesEntity::getCreateTime);
|
||||||
|
wrapper.last("limit "+limit);
|
||||||
|
List<BookForumArticlesEntity> bookForumArticlesEntities = this.getBaseMapper().selectList(wrapper);
|
||||||
|
//补充说话的人的用户信息
|
||||||
|
for (BookForumArticlesEntity b : bookForumArticlesEntities){
|
||||||
|
b.setUser(userService.getById(b.getUserid()));
|
||||||
|
}
|
||||||
|
return bookForumArticlesEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getForumsCount(Integer book_id) {
|
||||||
|
LambdaQueryWrapper<BookForumArticlesEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BookForumArticlesEntity::getDelflag,0);
|
||||||
|
wrapper.eq(BookForumArticlesEntity::getBookid,book_id);
|
||||||
|
int count = this.count(wrapper);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,29 @@
|
|||||||
package com.peanut.modules.book.service.impl;
|
package com.peanut.modules.book.service.impl;
|
||||||
|
|
||||||
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
import cn.com.marsoft.base.impl.BaseServiceImpl;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.common.utils.Query;
|
import com.peanut.common.utils.Query;
|
||||||
|
import com.peanut.modules.app.entity.UserEntity;
|
||||||
|
import com.peanut.modules.app.service.UserService;
|
||||||
import com.peanut.modules.book.dao.BookForumCommentDao;
|
import com.peanut.modules.book.dao.BookForumCommentDao;
|
||||||
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
import com.peanut.modules.book.entity.BookForumArticlesEntity;
|
||||||
import com.peanut.modules.book.entity.BookForumCommentEntity;
|
import com.peanut.modules.book.entity.BookForumCommentEntity;
|
||||||
import com.peanut.modules.book.service.BookForumCommenService;
|
import com.peanut.modules.book.service.BookForumCommenService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao, BookForumCommentEntity> implements BookForumCommenService {
|
public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao, BookForumCommentEntity> implements BookForumCommenService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
@@ -39,4 +46,43 @@ public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao,
|
|||||||
|
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BookForumCommentEntity> getCommentsLimit(Integer forum_id, Integer limit) {
|
||||||
|
LambdaQueryWrapper<BookForumCommentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BookForumCommentEntity::getBfaid,forum_id);
|
||||||
|
wrapper.eq(BookForumCommentEntity::getDelflag,0);
|
||||||
|
wrapper.orderByDesc(BookForumCommentEntity::getCreateTime);
|
||||||
|
wrapper.last("limit "+limit);
|
||||||
|
List<BookForumCommentEntity> bookForumCommentEntities = this.getBaseMapper().selectList(wrapper);
|
||||||
|
|
||||||
|
//完善人员信息
|
||||||
|
for (BookForumCommentEntity b : bookForumCommentEntities){
|
||||||
|
b.setUser(userService.getById(b.getUserid()));
|
||||||
|
b.setPuser(userService.getById(b.getPuserid()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return bookForumCommentEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getCommentcount(Integer forum_id) {
|
||||||
|
LambdaQueryWrapper<BookForumCommentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BookForumCommentEntity::getBfaid,forum_id);
|
||||||
|
wrapper.eq(BookForumCommentEntity::getDelflag,0);
|
||||||
|
int count = this.count(wrapper);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BookForumCommentEntity> getChildComments(Integer cid) {
|
||||||
|
LambdaQueryWrapper<BookForumCommentEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BookForumCommentEntity::getPid,cid);
|
||||||
|
wrapper.eq(BookForumCommentEntity::getDelflag,0);
|
||||||
|
wrapper.orderByAsc(BookForumCommentEntity::getCreateTime);
|
||||||
|
List<BookForumCommentEntity> bookForumCommentEntities = this.getBaseMapper().selectList(wrapper);
|
||||||
|
return bookForumCommentEntities;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user