太湖云医 医案、文章

This commit is contained in:
wuchunlei
2025-08-25 10:41:35 +08:00
parent c4d61fe0ad
commit e92d1ca482
28 changed files with 588 additions and 179 deletions

View File

@@ -1,6 +1,8 @@
package com.peanut.modules.taihumed.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.R;
import com.peanut.common.utils.ShiroUtils;
@@ -10,14 +12,12 @@ import com.peanut.modules.sys.entity.SysSensitiveWords;
import com.peanut.modules.sys.service.SysSensitiveWordsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
@Slf4j
@RestController("commonTaihuTalentArticle")
@@ -34,11 +34,16 @@ public class TaihuTalentArticleController {
private TaihuTalentArticleLikeService taihuTalentArticleLikeService;
@Autowired
private SysSensitiveWordsService sysSensitiveWordsService;
@Autowired
private MyUserService userService;
@Autowired
private MedicalRecordsService medicalRecordsService;
//太湖英才文章列表
@RequestMapping("/getArticleList")
public R getArticleList(@RequestBody Map<String,Object> params){
LambdaQueryWrapper<TaihuTalentArticle> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TaihuTalentArticle::getShowFlag,1);
wrapper.orderByDesc(TaihuTalentArticle::getCreateTime);
Page<TaihuTalentArticle> page = taihuTalentArticleService.page(new Page<>(Long.parseLong(params.get("current").toString()),
Long.parseLong(params.get("limit").toString())), wrapper);
@@ -49,6 +54,12 @@ public class TaihuTalentArticleController {
.eq(TaihuTalentArticleComment::getArticleId,article.getId())));
article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId())));
List<TaihuTalentArticleLike> likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId()));
for (TaihuTalentArticleLike like: likeList) {
like.setUser(userService.getById(like.getUserId()));
}
article.setLikeList(likeList);
article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId())
.eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId())));
@@ -64,9 +75,14 @@ public class TaihuTalentArticleController {
.eq(TaihuTalent::getUserId, article.getUserId())));
article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())));
article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId())));
article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper<TaihuTalentArticleLike>()
List<TaihuTalentArticleLike> likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId()));
for (TaihuTalentArticleLike like: likeList) {
like.setUser(userService.getById(like.getUserId()));
}
article.setLikeList(likeList);
article.setLikeCount(likeList.size());
article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId())
.eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId())));
List<TaihuTalentArticleComment> comments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
@@ -74,10 +90,15 @@ public class TaihuTalentArticleController {
.eq(TaihuTalentArticleComment::getPid,0)
.orderByDesc(TaihuTalentArticleComment::getCreateTime));
for (TaihuTalentArticleComment comment : comments) {
comment.setChildren(taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
List<TaihuTalentArticleComment> childrenList = taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())
.ne(TaihuTalentArticleComment::getPid,0)
.orderByAsc(TaihuTalentArticleComment::getCreateTime)));
.eq(TaihuTalentArticleComment::getPid,comment.getId())
.orderByAsc(TaihuTalentArticleComment::getCreateTime));
for (TaihuTalentArticleComment cc : childrenList) {
cc.setUser(userService.getById(cc.getUserId()));
}
comment.setChildren(childrenList);
comment.setUser(userService.getById(comment.getUserId()));
}
if (!Objects.equals(article.getUserId(), ShiroUtils.getUId())){
article.setReadCount(article.getReadCount()+1);
@@ -86,12 +107,63 @@ public class TaihuTalentArticleController {
return R.ok().put("article",article).put("comments",comments);
}
//太湖英才文章点赞和评论数量
@RequestMapping("/getArticleLikeAndComment")
public R getArticleLikeAndComment(@RequestBody Map<String,Object> params){
TaihuTalentArticle article = taihuTalentArticleService.getById(params.get("articleId").toString());
article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())));
List<TaihuTalentArticleLike> likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId()));
for (TaihuTalentArticleLike like: likeList) {
like.setUser(userService.getById(like.getUserId()));
}
article.setLikeList(likeList);
article.setLikeCount(likeList.size());
article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId())
.eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId())));
List<TaihuTalentArticleComment> comments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())
.eq(TaihuTalentArticleComment::getPid,0)
.orderByDesc(TaihuTalentArticleComment::getCreateTime));
for (TaihuTalentArticleComment comment : comments) {
List<TaihuTalentArticleComment> childrenList = taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())
.eq(TaihuTalentArticleComment::getPid,comment.getId())
.orderByAsc(TaihuTalentArticleComment::getCreateTime));
for (TaihuTalentArticleComment cc : childrenList) {
cc.setUser(userService.getById(cc.getUserId()));
}
comment.setChildren(childrenList);
comment.setUser(userService.getById(comment.getUserId()));
}
return R.ok().put("article",article).put("comments",comments);
}
//增加阅读数
@RequestMapping("/addReadCount")
public R addReadCount(@RequestBody Map<String,Object> params){
TaihuTalentArticle article = taihuTalentArticleService.getById(params.get("articleId").toString());
if (article!=null){
article.setReadCount(article.getReadCount()+1);
taihuTalentArticleService.updateById(article);
}
return R.ok();
}
//太湖英才文章点赞或取消
@RequestMapping("/addOrCancelArticleLike")
@Transactional
public R addOrCancelArticleLike(@RequestBody Map<String,Object> params){
TaihuTalentArticleLike like = taihuTalentArticleLikeService.getOne(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,params.get("articleId").toString())
.eq(TaihuTalentArticleLike::getUserId,ShiroUtils.getUId()));
TaihuTalentArticle article = taihuTalentArticleService.getById(params.get("articleId").toString());
if (article!=null){
article.setReadCount(article.getReadCount()+1);
taihuTalentArticleService.updateById(article);
}
if (like != null) {
taihuTalentArticleLikeService.removeById(like);
}else {
@@ -105,7 +177,13 @@ public class TaihuTalentArticleController {
//新增文章评论
@RequestMapping("/addArticleComment")
@Transactional
public R addArticleComment(@RequestBody TaihuTalentArticleComment comment){
TaihuTalentArticle article = taihuTalentArticleService.getById(comment.getArticleId());
if (article!=null){
article.setReadCount(article.getReadCount()+1);
taihuTalentArticleService.updateById(article);
}
R result = new R();
LambdaQueryWrapper<SysSensitiveWords> wrapper = new LambdaQueryWrapper<>();
wrapper.last(" where instr(\""+comment.getContent()+"\",word)>0");
@@ -121,34 +199,38 @@ public class TaihuTalentArticleController {
}
result.put("tip","您的评论含有敏感词:"+str+",请重新输入。");
}else {
comment.setUserId(ShiroUtils.getUId());
taihuTalentArticleCommentService.save(comment);
result.put("tip","评论成功!");
}
return result;
}
//评论提醒
@RequestMapping("/getCommentRemind")
public R getCommentRemind(@RequestBody Map<String,Object> params){
List<TaihuTalentArticleComment> list = new ArrayList<>();
public R getCommentRemind(){
Set<TaihuTalentArticle> set = new HashSet<>();
List<TaihuTalentArticleComment> userComments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getUserId,ShiroUtils.getUId())
.eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString()));
.eq(TaihuTalentArticleComment::getReadFlag,0));
for (TaihuTalentArticleComment comment : userComments) {
if(comment.getPid().equals(0)){
list.addAll(taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getPid,comment.getId())
.eq(TaihuTalentArticleComment::getReadFlag,0)
.eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString())));
}else {
list.addAll(taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getPid,comment.getPid())
.eq(TaihuTalentArticleComment::getReadFlag,0)
.eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString())));
TaihuTalentArticle article = taihuTalentArticleService.getById(comment.getArticleId());
if (article!=null){
set.add(article);
}
}
return R.ok().put("list",list);
return R.ok().put("set",set);
}
//评论提醒
@RequestMapping("/setReadFlag")
public R setReadFlag(@RequestBody Map<String,Object> params){
taihuTalentArticleCommentService.update(new LambdaUpdateWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getUserId,ShiroUtils.getUId())
.eq(TaihuTalentArticleComment::getReadFlag,0)
.eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString())
.set(TaihuTalentArticleComment::getReadFlag,1));
return R.ok();
}
//我的文章列表
@@ -156,17 +238,103 @@ public class TaihuTalentArticleController {
public R myArticleList(@RequestBody Map<String,Object> params){
LambdaQueryWrapper<TaihuTalentArticle> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TaihuTalentArticle::getUserId,ShiroUtils.getUId());
wrapper.eq(TaihuTalentArticle::getShowFlag,params.get("showFlag").toString());
wrapper.orderByDesc(TaihuTalentArticle::getCreateTime);
Page<TaihuTalentArticle> page = taihuTalentArticleService.page(new Page<>(Long.parseLong(params.get("current").toString()),
Long.parseLong(params.get("limit").toString())), wrapper);
for (TaihuTalentArticle article : page.getRecords()) {
article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())));
List<TaihuTalentArticleLike> likeList = taihuTalentArticleLikeService.list(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId()));
for (TaihuTalentArticleLike like: likeList) {
like.setUser(userService.getById(like.getUserId()));
}
article.setLikeList(likeList);
article.setLikeCount(likeList.size());
article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,article.getId())
.eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId())));
List<TaihuTalentArticleComment> comments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())
.eq(TaihuTalentArticleComment::getPid,0)
.orderByDesc(TaihuTalentArticleComment::getCreateTime));
for (TaihuTalentArticleComment comment : comments) {
List<TaihuTalentArticleComment> childrenList = taihuTalentArticleCommentService.list(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,article.getId())
.eq(TaihuTalentArticleComment::getPid,comment.getId())
.orderByAsc(TaihuTalentArticleComment::getCreateTime));
for (TaihuTalentArticleComment cc : childrenList) {
cc.setUser(userService.getById(cc.getUserId()));
}
comment.setChildren(childrenList);
comment.setUser(userService.getById(comment.getUserId()));
}
}
return R.ok().put("page",page);
}
//当前用户是否能新增文章
@RequestMapping("/getArticleRoleByUser")
public R getArticleRoleByUser(){
return R.ok().put("roleFlag", taihuTalentService.count(new LambdaQueryWrapper<TaihuTalent>()
.eq(TaihuTalent::getUserId,ShiroUtils.getUId())));
}
//新增文章
@RequestMapping("/addArticle")
public R addArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){
taihuTalentArticle.setUserId(ShiroUtils.getUId());
taihuTalentArticleService.save(taihuTalentArticle);
LambdaQueryWrapper<SysSensitiveWords> wrapper = new LambdaQueryWrapper<>();
wrapper.last(" where instr(\""+taihuTalentArticle.getTitle()+"\",word)>0");
List<SysSensitiveWords> list = sysSensitiveWordsService.list(wrapper);
if (list.size() > 0){
String str = "";
for (SysSensitiveWords words:list) {
if ("".equals(str)){
str = words.getWord();
}else {
str = str + "" + words.getWord();
}
}
return R.error("您的标题含有敏感词:"+str+",请重新输入。");
}else {
LambdaQueryWrapper<SysSensitiveWords> cwrapper = new LambdaQueryWrapper<>();
cwrapper.last(" where instr(\""+taihuTalentArticle.getContent()+"\",word)>0");
List<SysSensitiveWords> clist = sysSensitiveWordsService.list(cwrapper);
if (clist.size() > 0){
String str = "";
for (SysSensitiveWords words:clist) {
if ("".equals(str)){
str = words.getWord();
}else {
str = str + "" + words.getWord();
}
}
return R.error("您的内容含有敏感词:"+str+",请重新输入。");
}else {
taihuTalentArticle.setUserId(ShiroUtils.getUId());
taihuTalentArticleService.save(taihuTalentArticle);
return R.ok();
}
}
}
//删除文章
@RequestMapping("/delArticle")
@Transactional
public R delArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){
taihuTalentArticle = taihuTalentArticleService.getById(taihuTalentArticle.getId());
if (taihuTalentArticle.getCome()==1){
medicalRecordsService.update(new LambdaUpdateWrapper<MedicalRecords>()
.eq(MedicalRecords::getUserId,taihuTalentArticle.getUserId())
.eq(MedicalRecords::getTitle,taihuTalentArticle.getTitle())
.set(MedicalRecords::getArticleFlag,0));
}
taihuTalentArticleCommentService.remove(new LambdaQueryWrapper<TaihuTalentArticleComment>()
.eq(TaihuTalentArticleComment::getArticleId,taihuTalentArticle.getId()));
taihuTalentArticleLikeService.remove(new LambdaQueryWrapper<TaihuTalentArticleLike>()
.eq(TaihuTalentArticleLike::getArticleId,taihuTalentArticle.getId()));
taihuTalentArticleService.removeById(taihuTalentArticle);
return R.ok();
}

View File

@@ -31,15 +31,15 @@ public class TaihuTalentController {
@Autowired
private MedicalRecordsService medicalRecordsService;
@Autowired
private MedicalRecordsLabelService medicalRecordsLabelService;
private DeptLabelService deptLabelService;
//太湖英才列表
@RequestMapping("/getTaihuTalents")
public R getTaihuTalents(@RequestBody Map<String,Object> params){
MPJLambdaWrapper<TaihuTalent> wrapper = new MPJLambdaWrapper<>();
wrapper.leftJoin(MedicalRecordsLabel.class,MedicalRecordsLabel::getId,TaihuTalent::getDeptLabelId);
wrapper.leftJoin(DeptLabel.class, DeptLabel::getId,TaihuTalent::getDeptLabelId);
wrapper.selectAll(TaihuTalent.class);
wrapper.selectAs(MedicalRecordsLabel::getTitle,TaihuTalent::getDepartment);
wrapper.selectAs(DeptLabel::getTitle,TaihuTalent::getDepartment);
wrapper.like(StringUtils.isNotEmpty(params.get("name").toString()),TaihuTalent::getName,params.get("name"));
wrapper.eq(StringUtils.isNotEmpty(params.get("deptLabelId").toString()),TaihuTalent::getDeptLabelId,params.get("deptLabelId"));
wrapper.like(StringUtils.isNotEmpty(params.get("region").toString()),TaihuTalent::getRegion,params.get("region"));
@@ -68,7 +68,7 @@ public class TaihuTalentController {
@RequestMapping("/taihuTalentInfo")
public R taihuTalentInfo(@RequestBody Map<String,Object> params){
TaihuTalent taihuTalent = taihuTalentService.getById(params.get("id").toString());
taihuTalent.setDepartment(medicalRecordsLabelService.getById(taihuTalent.getDeptLabelId()).getTitle());
taihuTalent.setDepartment(deptLabelService.getById(taihuTalent.getDeptLabelId()).getTitle());
List<UserCertificateLabel> labels = userCertificateLabelService.list(new LambdaQueryWrapper<UserCertificateLabel>()
.eq(UserCertificateLabel::getPid,0));
List<UserCertificateLabel> filterLabels = new ArrayList<>();
@@ -115,7 +115,7 @@ public class TaihuTalentController {
List<CourseEntity> courseList = courseService.list(wrapper);
//精彩医案
List<MedicalRecords> medicalRecords = medicalRecordsService.list(new LambdaQueryWrapper<MedicalRecords>()
.eq(MedicalRecords::getState,3)
.ge(MedicalRecords::getState,5)
.eq(MedicalRecords::getShowFlag,1)
.eq(MedicalRecords::getUserId,taihuTalent.getUserId())
.orderByDesc(MedicalRecords::getTrain));