Commit 5727cfe3 by 宋珺琪

意见反馈添加姓名和警号

parent 5b8d9d20
......@@ -22,7 +22,12 @@ public class CommentEntity implements Serializable {
@TableId(type = IdType.INPUT)
private String plId; // 评论ID
private String content; // 评论内容
private String userName; // 评论作者姓名
private String userName; // 评论作者身份证
@TableField(exist = false)
private String name; // 评论作者姓名
@TableField(exist = false)
private String policemanId; //评论者警号
private String createTime; // 评论时间
private String isDelete; // 是否删除(0:未删除;1:已删除)
......@@ -36,6 +41,8 @@ public class CommentEntity implements Serializable {
@TableField(exist = false)
private String parentName; // 父评论名字(被回复的评论)
@TableField(exist = false)
private String parentPolicemanId; // 父评论警号(被回复的评论)
@TableField(exist = false)
private List<CommentEntity> child; // 本评论下的子评论
......
......@@ -22,7 +22,11 @@ import java.util.List;
public class PaperEntity implements Serializable {
@TableId(type = IdType.INPUT)
private String id; // 文章id
private String userName; // 文章作者姓名
private String userName; // 文章作者身份证
@TableField(exist = false)
private String name; // 文章作者姓名
@TableField(exist = false)
private String policemanId; //文章作者警号
private String content; // 文章内容
private String title; // 文章标题
private Integer count; // 文章评论次数
......
......@@ -3,13 +3,13 @@ package com.founder.publicapi.controller.SuggestionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.founder.commonutils.model.newPublicEntity.MapRestResult;
import com.founder.commonutils.model.newPublicEntity.SkypDesktopEntity.SkMenu;
import com.founder.commonutils.model.newPublicEntity.SysUser;
import com.founder.commonutils.model.newPublicEntity.suggestionEntity.CommentEntity;
import com.founder.commonutils.model.newPublicEntity.suggestionEntity.PaperEntity;
import com.founder.commonutils.util.KeyUtilNaotu;
import com.founder.publicapi.mapper.mysqlMapper.CommentMapper;
import com.founder.servicebase.logs.OperLog;
import com.founder.servicebase.logs.OperationType;
import com.founder.servicebase.mapper.mysqlMapper.SysUserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,6 +26,9 @@ public class CommentController {
@Autowired
CommentMapper commentMapper;
@Autowired
SysUserMapper sysUserMapper;
/**
* 评论发表、评论回复
......@@ -117,6 +120,10 @@ public class CommentController {
// 将所有根评论加入 map
for(CommentEntity comment : list) {
if(comment.getParentId() == null){
//获取姓名和警号
SysUser sysUser = jbxxBysfz(comment.getUserName());
comment.setName(sysUser.getTrueName());
comment.setPolicemanId(sysUser.getPolicemanid());
result.add(comment);
}
map.put(comment.getPlId(), comment);
......@@ -124,18 +131,25 @@ public class CommentController {
// 子评论加入到父评论的 child 中
for(CommentEntity comment : list) {
String id = comment.getParentId();
System.out.println(id);
if(id != null) { // 当前评论为子评论
//父的名称
CommentEntity name = commentMapper.selectById(id);
comment.setParentName(name.getUserName());
SysUser sysUser1 = jbxxBysfz(name.getUserName());
comment.setParentName(sysUser1.getTrueName());
comment.setParentPolicemanId(sysUser1.getPolicemanid());
//根的名称
SysUser sysUser = jbxxBysfz(comment.getUserName());
comment.setName(sysUser.getTrueName());
comment.setPolicemanId(sysUser.getPolicemanid());
CommentEntity p = map.get(id);
if(p.getChild() == null) { // child 为空,则创建
if(p.getChild() == null) { // child 为空,则先创建list
p.setChild(new ArrayList<>());
}else {
p.getChild().add(comment);
}
p.getChild().add(comment);
}
}
......@@ -153,6 +167,9 @@ public class CommentController {
public MapRestResult commentDetails(@RequestBody CommentEntity commentEntity){
CommentEntity commentEntity1 = commentMapper.selectById(commentEntity.getPlId());
SysUser sysUser = jbxxBysfz(commentEntity1.getUserName());
commentEntity1.setName(sysUser.getTrueName());
commentEntity1.setPolicemanId(sysUser.getPolicemanid());
return new MapRestResult(200,"ok",commentEntity1);
}
......@@ -167,4 +184,11 @@ public class CommentController {
return formatter.format(date);
}
public SysUser jbxxBysfz(String sfz){
QueryWrapper wrapper = new QueryWrapper<>();
wrapper.eq("IDENTITYCARD",sfz);
SysUser sysUser = sysUserMapper.selectOne(wrapper);
return sysUser;
}
}
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.founder.commonutils.model.newPublicEntity.MapRestResult;
import com.founder.commonutils.model.newPublicEntity.SysUser;
import com.founder.commonutils.model.newPublicEntity.suggestionEntity.CommentEntity;
import com.founder.commonutils.model.newPublicEntity.suggestionEntity.PaperEntity;
import com.founder.commonutils.util.KeyUtil;
......@@ -15,6 +16,7 @@ import com.founder.publicapi.mapper.mysqlMapper.CommentMapper;
import com.founder.publicapi.mapper.mysqlMapper.PaperMapper;
import com.founder.servicebase.logs.OperLog;
import com.founder.servicebase.logs.OperationType;
import com.founder.servicebase.mapper.mysqlMapper.SysUserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -51,6 +53,9 @@ public class PaperController {
@Autowired
CommentMapper commentMapper;
@Autowired
SysUserMapper sysUserMapper;
/**
* 文章新增
* @return
......@@ -229,6 +234,10 @@ public class PaperController {
List<PaperEntity> list = iPage.getRecords();
//遍历每一个文章 获取他的评论次数
for (PaperEntity pap : list) {
SysUser sysUser = jbxxBysfz(pap.getUserName());
pap.setName(sysUser.getTrueName());
pap.setPolicemanId(sysUser.getPolicemanid());
QueryWrapper<CommentEntity> wrapper1 = new QueryWrapper<>();
wrapper1.eq("blog_id",pap.getId());
wrapper1.eq("is_delete","0");
......@@ -249,6 +258,10 @@ public class PaperController {
public MapRestResult articleDetails(@RequestBody PaperEntity paperEntity) {
PaperEntity paperEntity1 = paperMapper.selectById(paperEntity.getId());
SysUser sysUser = jbxxBysfz(paperEntity1.getUserName());
paperEntity1.setName(sysUser.getTrueName());
paperEntity1.setPolicemanId(sysUser.getPolicemanid());
return new MapRestResult(200,"ok",paperEntity1);
}
......@@ -264,4 +277,12 @@ public class PaperController {
}
public SysUser jbxxBysfz(String sfz){
QueryWrapper wrapper = new QueryWrapper<>();
wrapper.eq("IDENTITYCARD",sfz);
SysUser sysUser = sysUserMapper.selectOne(wrapper);
return sysUser;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment