|
|
@@ -30,15 +30,14 @@ import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
import vip.xiaonuo.common.exception.CommonException;
|
|
|
import vip.xiaonuo.common.page.CommonPageRequest;
|
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
+import vip.xiaonuo.forum.modular.chapterDiscussion.entity.ForumChapterDiscussion;
|
|
|
+import vip.xiaonuo.forum.modular.chapterDiscussion.mapper.ForumChapterDiscussionMapper;
|
|
|
import vip.xiaonuo.forum.modular.contentcorrection.entity.ForumContentCorrection;
|
|
|
import vip.xiaonuo.forum.modular.contentcorrection.mapper.ForumContentCorrectionMapper;
|
|
|
import vip.xiaonuo.forum.modular.postinfo.entity.ForumPostInfo;
|
|
|
import vip.xiaonuo.forum.modular.postinfo.entity.ForumPostInfoVo;
|
|
|
import vip.xiaonuo.forum.modular.postinfo.mapper.ForumPostInfoMapper;
|
|
|
-import vip.xiaonuo.forum.modular.postinfo.param.ForumPostInfoAddParam;
|
|
|
-import vip.xiaonuo.forum.modular.postinfo.param.ForumPostInfoEditParam;
|
|
|
-import vip.xiaonuo.forum.modular.postinfo.param.ForumPostInfoIdParam;
|
|
|
-import vip.xiaonuo.forum.modular.postinfo.param.ForumPostInfoPageParam;
|
|
|
+import vip.xiaonuo.forum.modular.postinfo.param.*;
|
|
|
import vip.xiaonuo.forum.modular.postinfo.service.ForumPostInfoService;
|
|
|
import vip.xiaonuo.forum.modular.postlike.entity.ForumPostLike;
|
|
|
import vip.xiaonuo.forum.modular.postlike.service.ForumPostLikeService;
|
|
|
@@ -98,6 +97,9 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
|
|
|
@Lazy
|
|
|
private ForumPostLikeService forumPostLikeService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ForumChapterDiscussionMapper forumChapterDiscussionMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Page<ForumPostInfo> page(ForumPostInfoPageParam forumPostInfoPageParam) {
|
|
|
@@ -110,7 +112,7 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
|
|
|
if (StringUtils.isNotBlank(forumPostInfoPageParam.getTypeId())) {
|
|
|
queryWrapper.lambda().eq(ForumPostInfo::getTypeId, forumPostInfoPageParam.getTypeId());
|
|
|
}
|
|
|
- // 帖子类型 0普通帖子 1技术支持 2内容纠错
|
|
|
+ // 帖子类型 0普通帖子 1技术支持 2内容纠错 3章节讨论
|
|
|
if (forumPostInfoPageParam.getPostType() != null) {
|
|
|
queryWrapper.lambda().eq(ForumPostInfo::getPostType, forumPostInfoPageParam.getPostType());
|
|
|
}
|
|
|
@@ -183,7 +185,7 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
|
|
|
forumPostInfo.setPostContent(postContent);
|
|
|
// 存储基础表
|
|
|
this.save(forumPostInfo);
|
|
|
- // 区分出是普通帖子、还是技术支持帖子、内容纠错帖子 0普通帖子 1技术支持 2内容纠错
|
|
|
+ // 区分出是普通帖子、还是技术支持帖子、内容纠错帖子 0普通帖子 1技术支持 2内容纠错 3章节讨论
|
|
|
if (forumPostInfo.getPostType() == 0) {
|
|
|
// 普通帖子直接存储
|
|
|
// 普通帖子暂时不做其他处理
|
|
|
@@ -197,6 +199,11 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
|
|
|
ForumContentCorrection forumContentCorrection = BeanUtil.toBean(forumPostInfoAddParam.getContentCorrectionParam(), ForumContentCorrection.class);
|
|
|
forumContentCorrection.setPostId(uuid);
|
|
|
forumContentCorrectionMapper.insert(forumContentCorrection);
|
|
|
+ } else if (forumPostInfo.getPostType() == 3) {
|
|
|
+ // 章节讨论帖子,需要额外存储课程id,课时id
|
|
|
+ ForumChapterDiscussion forumChapterDiscussion = BeanUtil.toBean(forumPostInfoAddParam.getChapterDiscussionParam(), ForumChapterDiscussion.class);
|
|
|
+ forumChapterDiscussion.setPostId(uuid);
|
|
|
+ forumChapterDiscussionMapper.insert(forumChapterDiscussion);
|
|
|
} else {
|
|
|
return CommonResult.error("帖子类型不正确");
|
|
|
}
|
|
|
@@ -330,6 +337,13 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
|
|
|
if (forumContentCorrection != null) {
|
|
|
forumPostInfoVo.setForumContentCorrection(forumContentCorrection);
|
|
|
}
|
|
|
+ } else if (forumPostInfoVo.getPostType() == 3) {
|
|
|
+ QueryWrapper<ForumChapterDiscussion> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumChapterDiscussion::getPostId, forumPostInfoVo.getPostId());
|
|
|
+ ForumChapterDiscussion forumChapterDiscussion = forumChapterDiscussionMapper.selectOne(queryWrapper);
|
|
|
+ if (forumChapterDiscussion != null) {
|
|
|
+ forumPostInfoVo.setForumChapterDiscussion(forumChapterDiscussion);
|
|
|
+ }
|
|
|
}
|
|
|
// 关联被指向的用户
|
|
|
if (forumPostInfoVo.getAppointUser() != null) {
|
|
|
@@ -587,6 +601,125 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ForumPostInfoVo getChapter(ChapterDiscussionParam chapterDiscussionParam) {
|
|
|
+ // 先根据课程id和课时id查询是否有此帖子,如果没有需要自动新建一个帖子
|
|
|
+ String postId;
|
|
|
+ QueryWrapper<ForumChapterDiscussion> chapterDiscussionQueryWrapper = new QueryWrapper<>();
|
|
|
+ chapterDiscussionQueryWrapper.lambda().eq(ForumChapterDiscussion::getChapterId, chapterDiscussionParam.getChapterId());
|
|
|
+ chapterDiscussionQueryWrapper.lambda().eq(ForumChapterDiscussion::getCourseId, chapterDiscussionParam.getCourseId());
|
|
|
+ ForumChapterDiscussion dbChapterDiscussion = forumChapterDiscussionMapper.selectOne(chapterDiscussionQueryWrapper);
|
|
|
+ // 如果没有新建帖子,如果有关联出帖子id
|
|
|
+ if (dbChapterDiscussion == null) {
|
|
|
+ postId = addChapterPost(chapterDiscussionParam);
|
|
|
+ } else {
|
|
|
+ postId = dbChapterDiscussion.getPostId();
|
|
|
+ }
|
|
|
+ // 查询和转换帖子基础信息
|
|
|
+ ForumPostInfo forumPostInfo = this.queryEntity(postId);
|
|
|
+ ForumPostInfoVo forumPostInfoVo = BeanUtil.toBean(forumPostInfo, ForumPostInfoVo.class);
|
|
|
+// // 关联分类名称
|
|
|
+// ForumPostType forumPostType = forumPostTypeMapper.selectById(forumPostInfoVo.getTypeId());
|
|
|
+// if (ObjectUtil.isNotNull(forumPostType)) {
|
|
|
+// forumPostInfoVo.setTypeName(forumPostType.getTypeName());
|
|
|
+// }
|
|
|
+// // 关联发帖用户的信息
|
|
|
+// JSONObject user = sysUserApi.getUserByIdWithoutException(forumPostInfo.getUserId());
|
|
|
+// if (user != null) {
|
|
|
+// forumPostInfoVo.setUserNickName(user.getStr("name"));
|
|
|
+// forumPostInfoVo.setUserAvatar(user.getStr("avatar"));
|
|
|
+// }
|
|
|
+ // 关联最后发帖用户的信息
|
|
|
+ JSONObject lastReplyUser = sysUserApi.getUserByIdWithoutException(forumPostInfo.getLastReplyUserId());
|
|
|
+ if (lastReplyUser != null) {
|
|
|
+ forumPostInfoVo.setLastReplyUserNickName(lastReplyUser.getStr("name"));
|
|
|
+ forumPostInfoVo.setLastReplyUserAvatar(lastReplyUser.getStr("avatar"));
|
|
|
+ }
|
|
|
+ // 校验此条帖子是否为自己的
|
|
|
+// if (forumPostInfo.getUserId().equals(StpLoginUserUtil.getLoginUser().getId())) {
|
|
|
+// forumPostInfoVo.setIsSelf(1);
|
|
|
+// } else {
|
|
|
+// forumPostInfoVo.setIsSelf(0);
|
|
|
+// }
|
|
|
+ // 查询是否点赞
|
|
|
+ QueryWrapper<ForumPostLike> queryWrapper3 = new QueryWrapper<>();
|
|
|
+ queryWrapper3.lambda().eq(ForumPostLike::getTargetId, forumPostInfoVo.getPostId());
|
|
|
+ queryWrapper3.lambda().eq(ForumPostLike::getUserId, StpLoginUserUtil.getLoginUser().getId());
|
|
|
+ long count = forumPostLikeService.count(queryWrapper3);
|
|
|
+ if (count > 0) {
|
|
|
+ forumPostInfoVo.setIsLike(1);
|
|
|
+ } else {
|
|
|
+ forumPostInfoVo.setIsLike(0);
|
|
|
+ }
|
|
|
+ // 查询详情的同时,给帖子增加浏览量和热度
|
|
|
+ forumPostInfo.setViewCount(forumPostInfo.getViewCount() + 1);
|
|
|
+ this.updateById(forumPostInfo);
|
|
|
+ // 查询帖子回复信息
|
|
|
+ ForumPostReplyPageParam forumPostReplyPageParam = new ForumPostReplyPageParam();
|
|
|
+ forumPostReplyPageParam.setCurrent(chapterDiscussionParam.getCurrent());
|
|
|
+ forumPostReplyPageParam.setSize(chapterDiscussionParam.getSize());
|
|
|
+ forumPostReplyPageParam.setPostId(forumPostInfoVo.getPostId());
|
|
|
+ Page<ForumPostReply> page = forumPostReplyService.page(forumPostReplyPageParam);
|
|
|
+ forumPostInfoVo.setReplyList(page);
|
|
|
+ // 如果是技术支持或内容纠错,需要关联对应的
|
|
|
+ if (forumPostInfoVo.getPostType() == 1) {
|
|
|
+ QueryWrapper<ForumSupportEnv> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumSupportEnv::getPostId, forumPostInfoVo.getPostId());
|
|
|
+ ForumSupportEnv forumSupportEnv = forumSupportEnvMapper.selectOne(queryWrapper);
|
|
|
+ if (forumSupportEnv != null) {
|
|
|
+ forumPostInfoVo.setForumSupportEnv(forumSupportEnv);
|
|
|
+ }
|
|
|
+ } else if (forumPostInfoVo.getPostType() == 2) {
|
|
|
+ QueryWrapper<ForumContentCorrection> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumContentCorrection::getPostId, forumPostInfoVo.getPostId());
|
|
|
+ ForumContentCorrection forumContentCorrection = forumContentCorrectionMapper.selectOne(queryWrapper);
|
|
|
+ if (forumContentCorrection != null) {
|
|
|
+ forumPostInfoVo.setForumContentCorrection(forumContentCorrection);
|
|
|
+ }
|
|
|
+ } else if (forumPostInfoVo.getPostType() == 3) {
|
|
|
+ QueryWrapper<ForumChapterDiscussion> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumChapterDiscussion::getPostId, forumPostInfoVo.getPostId());
|
|
|
+ ForumChapterDiscussion forumChapterDiscussion = forumChapterDiscussionMapper.selectOne(queryWrapper);
|
|
|
+ if (forumChapterDiscussion != null) {
|
|
|
+ forumPostInfoVo.setForumChapterDiscussion(forumChapterDiscussion);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 关联被指向的用户
|
|
|
+// if (forumPostInfoVo.getAppointUser() != null) {
|
|
|
+// String appointUser = forumPostInfoVo.getAppointUser();
|
|
|
+// StringBuffer sb = new StringBuffer();
|
|
|
+// String[] split = appointUser.split(",");
|
|
|
+// for (int i = 0; i < split.length; i++) {
|
|
|
+// JSONObject userByIdWithoutException = sysUserApi.getUserByIdWithoutException(split[i]);
|
|
|
+// if (i != split.length - 1) {
|
|
|
+// sb.append(userByIdWithoutException.getStr("name")).append(",");
|
|
|
+// } else {
|
|
|
+// sb.append(userByIdWithoutException.getStr("name"));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// forumPostInfoVo.setAppointUser(sb.toString());
|
|
|
+// }
|
|
|
+ return forumPostInfoVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自动创建章节讨论类型的帖子
|
|
|
+ */
|
|
|
+ public String addChapterPost(ChapterDiscussionParam chapterDiscussionParam) {
|
|
|
+ String uuid = IdUtil.fastSimpleUUID();
|
|
|
+ ForumPostInfo forumPostInfo = new ForumPostInfo();
|
|
|
+ forumPostInfo.setPostType(3);
|
|
|
+ forumPostInfo.setPostId(uuid);
|
|
|
+ forumPostInfo.setPostTitle("课程:"+chapterDiscussionParam.getCourseName()+" 章节:"+chapterDiscussionParam.getChapterName());
|
|
|
+ // 存储基础表
|
|
|
+ this.save(forumPostInfo);
|
|
|
+ // 区分出是普通帖子、还是技术支持帖子、内容纠错帖子 0普通帖子 1技术支持 2内容纠错 3章节讨论
|
|
|
+ // 章节讨论帖子,需要额外存储课程id,课时id
|
|
|
+ ForumChapterDiscussion forumChapterDiscussion = BeanUtil.toBean(chapterDiscussionParam, ForumChapterDiscussion.class);
|
|
|
+ forumChapterDiscussion.setPostId(uuid);
|
|
|
+ forumChapterDiscussionMapper.insert(forumChapterDiscussion);
|
|
|
+ return uuid;
|
|
|
+ }
|
|
|
|
|
|
public static List<String> getDatesBetween(String startDateStr, String endDateStr) {
|
|
|
// 定义日期格式
|