diff --git a/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleCommentDao.java b/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleCommentDao.java new file mode 100644 index 00000000..2c614b85 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleCommentDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.TaihuTalentArticleComment; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TaihuTalentArticleCommentDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleDao.java b/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleDao.java new file mode 100644 index 00000000..6e09b86a --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.TaihuTalentArticle; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TaihuTalentArticleDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleLikeDao.java b/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleLikeDao.java new file mode 100644 index 00000000..5bd9df80 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/TaihuTalentArticleLikeDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.TaihuTalentArticleLike; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TaihuTalentArticleLikeDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticle.java b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticle.java new file mode 100644 index 00000000..4717bedd --- /dev/null +++ b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticle.java @@ -0,0 +1,42 @@ +package com.peanut.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import java.io.Serializable; +import java.util.Date; + +@Data +@TableName("taihu_talent_article") +public class TaihuTalentArticle implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId + private Integer id; + private Integer userId; + //标题 + private String title; + //内容 + private String content; + //图片 + private String img; + //阅读数 + private Integer readCount; + //转发数 + private Integer forwardCount; + private Date createTime; + @TableLogic + private Integer delFlag; + //评论数 + @TableField(exist = false) + private Integer commentCount; + //点赞数 + @TableField(exist = false) + private Integer likeCount; + @TableField(exist = false) + private Integer likeFlag; + @TableField(exist = false) + private TaihuTalent taihuTalent; +} diff --git a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleComment.java b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleComment.java new file mode 100644 index 00000000..4f78ba99 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleComment.java @@ -0,0 +1,32 @@ +package com.peanut.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +@Data +@TableName("taihu_talent_article_comment") +public class TaihuTalentArticleComment implements Serializable { + private static final long serialVersionUID = 1L; + @TableId + private Integer id; + private Integer pid; + //文章id + private Integer articleId; + //用户id + private Integer userId; + //内容 + private String content; + //阅读状态 + private Integer readFlag; + private Date createTime; + @TableLogic + private Integer delFlag; + @TableField(exist = false) + private List children; +} diff --git a/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleLike.java b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleLike.java new file mode 100644 index 00000000..acaa1df2 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/entity/TaihuTalentArticleLike.java @@ -0,0 +1,20 @@ +package com.peanut.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import java.io.Serializable; + +@Data +@TableName("taihu_talent_article_like") +public class TaihuTalentArticleLike implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId + private Integer id; + private Integer articleId; + private Integer userId; + @TableLogic + private Integer delFlag; +} diff --git a/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleCommentService.java b/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleCommentService.java new file mode 100644 index 00000000..ec6f6b6a --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleCommentService.java @@ -0,0 +1,7 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.TaihuTalentArticleComment; + +public interface TaihuTalentArticleCommentService extends IService { +} diff --git a/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleLikeService.java b/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleLikeService.java new file mode 100644 index 00000000..e07d05d1 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleLikeService.java @@ -0,0 +1,7 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.TaihuTalentArticleLike; + +public interface TaihuTalentArticleLikeService extends IService { +} diff --git a/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleService.java b/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleService.java new file mode 100644 index 00000000..6a8cea9d --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/TaihuTalentArticleService.java @@ -0,0 +1,7 @@ +package com.peanut.modules.common.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.TaihuTalentArticle; + +public interface TaihuTalentArticleService extends IService { +} diff --git a/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleCommentServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleCommentServiceImpl.java new file mode 100644 index 00000000..48dbb599 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleCommentServiceImpl.java @@ -0,0 +1,13 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.TaihuTalentArticleCommentDao; +import com.peanut.modules.common.entity.TaihuTalentArticleComment; +import com.peanut.modules.common.service.TaihuTalentArticleCommentService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("commonTaihuTalentArticleCommentService") +public class TaihuTalentArticleCommentServiceImpl extends ServiceImpl implements TaihuTalentArticleCommentService { +} diff --git a/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleLikeServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleLikeServiceImpl.java new file mode 100644 index 00000000..eb58b80d --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleLikeServiceImpl.java @@ -0,0 +1,13 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.TaihuTalentArticleLikeDao; +import com.peanut.modules.common.entity.TaihuTalentArticleLike; +import com.peanut.modules.common.service.TaihuTalentArticleLikeService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("commonTaihuTalentArticleLikeService") +public class TaihuTalentArticleLikeServiceImpl extends ServiceImpl implements TaihuTalentArticleLikeService { +} diff --git a/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleServiceImpl.java new file mode 100644 index 00000000..a2910158 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/service/impl/TaihuTalentArticleServiceImpl.java @@ -0,0 +1,13 @@ +package com.peanut.modules.common.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.TaihuTalentArticleDao; +import com.peanut.modules.common.entity.TaihuTalentArticle; +import com.peanut.modules.common.service.TaihuTalentArticleService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("commonTaihuTalentArticleService") +public class TaihuTalentArticleServiceImpl extends ServiceImpl implements TaihuTalentArticleService { +} diff --git a/src/main/java/com/peanut/modules/master/controller/TaihuTalentArticleController.java b/src/main/java/com/peanut/modules/master/controller/TaihuTalentArticleController.java new file mode 100644 index 00000000..50904349 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/controller/TaihuTalentArticleController.java @@ -0,0 +1,91 @@ +package com.peanut.modules.master.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import com.peanut.common.utils.R; +import com.peanut.common.utils.ShiroUtils; +import com.peanut.modules.common.entity.*; +import com.peanut.modules.common.service.TaihuTalentArticleCommentService; +import com.peanut.modules.common.service.TaihuTalentArticleService; +import com.peanut.modules.common.service.TaihuTalentService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@Slf4j +@RestController("masterTaihuTalentArticle") +@RequestMapping("master/taihuTalentArticle") +public class TaihuTalentArticleController { + + @Autowired + private TaihuTalentArticleService taihuTalentArticleService; + @Autowired + private TaihuTalentService taihuTalentService; + @Autowired + private TaihuTalentArticleCommentService taihuTalentArticleCommentService; + + //太湖英才文章列表 + @RequestMapping("/getArticleList") + public R getArticleList(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.leftJoin(TaihuTalent.class,TaihuTalent::getUserId,TaihuTalentArticle::getUserId); + wrapper.selectAll(TaihuTalentArticle.class); + wrapper.like(TaihuTalentArticle::getTitle,params.get("title")); + wrapper.like(TaihuTalent::getName,params.get("name")); + wrapper.orderByDesc(TaihuTalentArticle::getCreateTime); + Page page = taihuTalentArticleService.page(new Page<>(Long.parseLong(params.get("current").toString()), + Long.parseLong(params.get("limit").toString())), wrapper); + for (TaihuTalentArticle article : page.getRecords()) { + article.setTaihuTalent(taihuTalentService.getOne(new LambdaQueryWrapper() + .eq(TaihuTalent::getUserId, article.getUserId()))); + article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()))); + } + return R.ok().put("page",page); + } + + //新增文章 + @RequestMapping("/addArticle") + public R addArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){ + taihuTalentArticleService.save(taihuTalentArticle); + return R.ok(); + } + + //删除文章 + @RequestMapping("/delArticle") + public R delArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){ + taihuTalentArticleService.removeById(taihuTalentArticle); + return R.ok(); + } + + //评论列表 + @RequestMapping("/getCommentList") + public R getCommentList(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,TaihuTalentArticleComment::getUserId); + wrapper.selectAll(TaihuTalentArticleComment.class); + wrapper.like(TaihuTalentArticleComment::getContent,params.get("conten")); + if (StringUtils.isNotEmpty(params.get("userInfo").toString())) { + wrapper.and(t->t.like(MyUserEntity::getName,params.get("userInfo")).or().like(MyUserEntity::getNickname,params.get("userInfo")) + .or().like(MyUserEntity::getTel,params.get("userInfo")).or().like(MyUserEntity::getEmail,params.get("userInfo"))); + } + wrapper.orderByDesc(TaihuTalentArticle::getCreateTime); + Page page = taihuTalentArticleCommentService.page(new Page<>(Long.parseLong(params.get("current").toString()), + Long.parseLong(params.get("limit").toString())), wrapper); + return R.ok().put("page",page); + } + + //删除评论 + @RequestMapping("/delComment") + public R delComment(@RequestBody TaihuTalentArticleComment comment){ + taihuTalentArticleCommentService.removeById(comment); + return R.ok(); + } + +} diff --git a/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentArticleController.java b/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentArticleController.java new file mode 100644 index 00000000..9513a2c4 --- /dev/null +++ b/src/main/java/com/peanut/modules/taihumed/controller/TaihuTalentArticleController.java @@ -0,0 +1,174 @@ +package com.peanut.modules.taihumed.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.peanut.common.utils.R; +import com.peanut.common.utils.ShiroUtils; +import com.peanut.modules.common.entity.*; +import com.peanut.modules.common.service.*; +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.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; + +@Slf4j +@RestController("commonTaihuTalentArticle") +@RequestMapping("common/taihuTalentArticle") +public class TaihuTalentArticleController { + + @Autowired + private TaihuTalentArticleService taihuTalentArticleService; + @Autowired + private TaihuTalentService taihuTalentService; + @Autowired + private TaihuTalentArticleCommentService taihuTalentArticleCommentService; + @Autowired + private TaihuTalentArticleLikeService taihuTalentArticleLikeService; + @Autowired + private SysSensitiveWordsService sysSensitiveWordsService; + + //太湖英才文章列表 + @RequestMapping("/getArticleList") + public R getArticleList(@RequestBody Map params){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.orderByDesc(TaihuTalentArticle::getCreateTime); + Page page = taihuTalentArticleService.page(new Page<>(Long.parseLong(params.get("current").toString()), + Long.parseLong(params.get("limit").toString())), wrapper); + for (TaihuTalentArticle article : page.getRecords()) { + article.setTaihuTalent(taihuTalentService.getOne(new LambdaQueryWrapper() + .eq(TaihuTalent::getUserId, article.getUserId()))); + article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()))); + article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId()))); + article.setLikeFlag((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId()) + .eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId()))); + } + return R.ok().put("page",page); + } + + //太湖英才文章详情 + @RequestMapping("/getArticleInfo") + public R getArticleInfo(@RequestBody Map params){ + TaihuTalentArticle article = taihuTalentArticleService.getById(params.get("articleId").toString()); + article.setTaihuTalent(taihuTalentService.getOne(new LambdaQueryWrapper() + .eq(TaihuTalent::getUserId, article.getUserId()))); + article.setCommentCount((int) taihuTalentArticleCommentService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()))); + article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId()))); + article.setLikeCount((int) taihuTalentArticleLikeService.count(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,article.getId()) + .eq(TaihuTalentArticleLike::getUserId, ShiroUtils.getUId()))); + List comments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()) + .eq(TaihuTalentArticleComment::getPid,0) + .orderByDesc(TaihuTalentArticleComment::getCreateTime)); + for (TaihuTalentArticleComment comment : comments) { + comment.setChildren(taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getArticleId,article.getId()) + .ne(TaihuTalentArticleComment::getPid,0) + .orderByAsc(TaihuTalentArticleComment::getCreateTime))); + } + if (!Objects.equals(article.getUserId(), ShiroUtils.getUId())){ + article.setReadCount(article.getReadCount()+1); + taihuTalentArticleService.updateById(article); + } + return R.ok().put("article",article).put("comments",comments); + } + + //太湖英才文章点赞或取消 + @RequestMapping("/addOrCancelArticleLike") + public R addOrCancelArticleLike(@RequestBody Map params){ + TaihuTalentArticleLike like = taihuTalentArticleLikeService.getOne(new LambdaQueryWrapper() + .eq(TaihuTalentArticleLike::getArticleId,params.get("articleId").toString()) + .eq(TaihuTalentArticleLike::getUserId,ShiroUtils.getUId())); + if (like != null) { + taihuTalentArticleLikeService.removeById(like); + }else { + like = new TaihuTalentArticleLike(); + like.setUserId(ShiroUtils.getUId()); + like.setArticleId(Integer.parseInt(params.get("articleId").toString())); + taihuTalentArticleLikeService.save(like); + } + return R.ok(); + } + + //新增文章评论 + @RequestMapping("/addArticleComment") + public R addArticleComment(@RequestBody TaihuTalentArticleComment comment){ + R result = new R(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.last(" where instr(\""+comment.getContent()+"\",word)>0"); + List 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(); + } + } + result.put("tip","您的评论含有敏感词:"+str+",请重新输入。"); + }else { + taihuTalentArticleCommentService.save(comment); + result.put("tip","评论成功!"); + } + + return result; + } + + //评论提醒 + @RequestMapping("/getCommentRemind") + public R getCommentRemind(@RequestBody Map params){ + List list = new ArrayList<>(); + List userComments = taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getUserId,ShiroUtils.getUId()) + .eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString())); + for (TaihuTalentArticleComment comment : userComments) { + if(comment.getPid().equals(0)){ + list.addAll(taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getPid,comment.getId()) + .eq(TaihuTalentArticleComment::getReadFlag,0) + .eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString()))); + }else { + list.addAll(taihuTalentArticleCommentService.list(new LambdaQueryWrapper() + .eq(TaihuTalentArticleComment::getPid,comment.getPid()) + .eq(TaihuTalentArticleComment::getReadFlag,0) + .eq(TaihuTalentArticleComment::getArticleId,params.get("articleId").toString()))); + } + } + return R.ok().put("list",list); + } + + //我的文章列表 + @RequestMapping("/myArticleList") + public R myArticleList(@RequestBody Map params){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaihuTalentArticle::getUserId,ShiroUtils.getUId()); + wrapper.orderByDesc(TaihuTalentArticle::getCreateTime); + Page page = taihuTalentArticleService.page(new Page<>(Long.parseLong(params.get("current").toString()), + Long.parseLong(params.get("limit").toString())), wrapper); + return R.ok().put("page",page); + } + + //新增文章 + @RequestMapping("/addArticle") + public R addArticle(@RequestBody TaihuTalentArticle taihuTalentArticle){ + taihuTalentArticle.setUserId(ShiroUtils.getUId()); + taihuTalentArticleService.save(taihuTalentArticle); + return R.ok(); + } + + +}