This commit is contained in:
wangjinlei
2023-09-26 16:55:44 +08:00
parent e42d0243cd
commit 1755a78a8d
16 changed files with 159 additions and 146 deletions

View File

@@ -1,5 +1,4 @@
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;
@@ -7,7 +6,6 @@ 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.*;
@@ -180,7 +178,8 @@ public class BookForumArticlesServiceController {
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()));
UserEntity byId = userService.getById(b.getUserid());
b.setUser(byId);
b.setComment(bookForumCommenService.getCommentsLimit(b.getId(),3));
}
return R.ok().put("page",bookForumArticlesEntityPage);
@@ -198,26 +197,28 @@ public class BookForumArticlesServiceController {
LambdaQueryWrapper<BookForumCommentEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookForumCommentEntity::getDelflag,0);
wrapper.eq(BookForumCommentEntity::getPid,0);
wrapper.eq(BookForumCommentEntity::getBfaid,forumId);
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()));
b.setCommentsNum(bookForumCommenService.getCommentCountInComment(b.getId()));
}
return R.ok().put("page",bookForumCommentEntityPage);
}
/**
*
* 获取书评详情
* @param forumId
* @return
*/
@RequestMapping("/getForumdetail")
public R getForumdetail(@RequestParam Integer forumId){
return R.ok();
BookForumArticlesEntity byId = bookForumArticlesService.getById(forumId);
return R.ok().put("forum",byId);
}
/**
@@ -244,8 +245,8 @@ public class BookForumArticlesServiceController {
@RequestParam Integer forumId,
@RequestParam String content,
@RequestParam Integer userId,
@RequestParam(required = false,value = "0") Integer pid,
@RequestParam(required = false,value = "0") Integer puserId){
@RequestParam(required = false,defaultValue = "0") Integer pid,
@RequestParam(required = false,defaultValue = "0") Integer puserId){
BookForumArticlesEntity forumInfo = bookForumArticlesService.getById(forumId);
BookForumCommentEntity bookForumCommentEntity = new BookForumCommentEntity();
bookForumCommentEntity.setBfaid(forumId);
@@ -259,20 +260,6 @@ public class BookForumArticlesServiceController {
}
/**
* 添加书评项目
* @return
*/
@RequestMapping("/addForum")
public R addForum(@RequestParam Integer userId,@RequestParam String content){
return null;
}
@RequestMapping("/desc/{page}")
public R Descupd(@RequestParam Map<String, Object> params,@PathVariable("page") Integer page){
HashMap<Object, Object> map = new HashMap<>();

View File

@@ -0,0 +1,24 @@
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有,侵权必究!
*/
package com.peanut.modules.book.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.peanut.modules.book.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 用户
*
* @author Mark sunlightcs@gmail.com
*/
@Mapper
public interface UserDao extends MPJBaseMapper<UserEntity> {
}

View File

@@ -1,12 +1,10 @@
package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.peanut.modules.app.entity.UserEntity;
import lombok.Data;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 文章表主表

View File

@@ -2,7 +2,6 @@ package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.peanut.modules.app.entity.UserEntity;
import lombok.Data;
import java.util.Date;
@@ -80,4 +79,7 @@ public class BookForumCommentEntity {
//子对话
@TableField(exist = false)
private List<BookForumCommentEntity> comments;
//子对话数量
@TableField(exist = false)
private Integer commentsNum;
}

View File

@@ -0,0 +1,65 @@
package com.peanut.modules.book.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@Data
@TableName("user")
public class UserEntity {
private static final long serialVersionUID = 1L;
@TableId
@TableField("id")
private Integer id;
private String name;
private Integer age;
private Integer sex;
private String avatar;
private String nickname;
private String tel;
private String password;
private String vip;
@TableField("vip_start_time")
private Date vipStartTime;
@TableField("vip_validtime")
private Date vipValidtime;
@TableField("peanut_coin")
private BigDecimal peanutCoin;
@TableField("read_time")
private Date readTime;
@TableField("last_login_time")
private Date lastLoginTime;
@TableField("yljk_oid")
private String yljkOid;
@TableField("create_time")
private Date createTime;
@TableField("update_time")
private Date updateTime;
@TableField("del_flag")
private Integer delFlag;
private String remark;
}

View File

@@ -17,5 +17,7 @@ public interface BookForumCommenService extends IService<BookForumCommentEntit
Integer getCommentcount(Integer forum_id);
Integer getCommentCountInComment(Integer comment_id);
List<BookForumCommentEntity> getChildComments(Integer cid);
}

View File

@@ -1,16 +1,13 @@
package com.peanut.modules.book.service.impl;
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.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.common.utils.PageUtils;
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.entity.BookForumArticlesEntity;
import com.peanut.modules.book.entity.BookForumCommentEntity;
import com.peanut.modules.book.service.BookForumCommenService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -83,6 +80,19 @@ public class BookForumCommenServiceImpl extends ServiceImpl<BookForumCommentDao,
wrapper.eq(BookForumCommentEntity::getDelflag,0);
wrapper.orderByAsc(BookForumCommentEntity::getCreateTime);
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 getCommentCountInComment(Integer comment_id) {
LambdaQueryWrapper<BookForumCommentEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BookForumCommentEntity::getPid,comment_id);
wrapper.eq(BookForumCommentEntity::getDelflag,0);
Integer integer = this.getBaseMapper().selectCount(wrapper);
return integer;
}
}