Browse Source

Merge branch 'dev' of http://192.168.1.245:11111/jinjilong/onlineEducation-fwd into dev

honorfire 6 months ago
parent
commit
bd2f7b8159

+ 1 - 1
snowy-plugin/snowy-plugin-forum/snowy-plugin-forum-func/src/main/java/vip/xiaonuo/forum/modular/postinfo/controller/ForumPostInfoController.java

@@ -186,7 +186,7 @@ public class ForumPostInfoController {
     }
 
     /**
-     * 统计:学习进度概览 根据日期查询发帖和回帖数
+     * 统计:学习进度概览 根据课程、日期查询发帖和回帖数
      */
     @PostMapping("/forum/postinfo/getCountByDate")
     public CommonResult<JSONObject> getCountByDate(@RequestBody JSONObject json) {

+ 4 - 3
snowy-plugin/snowy-plugin-forum/snowy-plugin-forum-func/src/main/java/vip/xiaonuo/forum/modular/postinfo/service/impl/ForumPostInfoServiceImpl.java

@@ -724,16 +724,18 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
     @Override
     public CommonResult<com.alibaba.fastjson.JSONObject> getCountByDate(com.alibaba.fastjson.JSONObject json) {
         // 取出起始时间和截止时间
+        String courseId = json.getString("courseId");
         String startTime = json.getString("startTime");
         String endTime = json.getString("endTime");
         // 计算两个时间段内的发帖数和回帖数
         // 1.发帖数
-        long postCountByDateAndType = forumPostReplyService.getPostCountByDateAndType(startTime, endTime, 3);
+        long postCountByDateAndType = forumPostReplyService.getPostCountByDateAndType(courseId, startTime, endTime, 3);
         // 2.回帖数
-        long replyCountByDateAndType = forumPostReplyService.getReplyCountByDateAndType(startTime, endTime, 3);
+        long replyCountByDateAndType = forumPostReplyService.getReplyCountByDateAndType(courseId, startTime, endTime, 3);
         com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
         result.put("postCount", postCountByDateAndType);
         result.put("replyCount", replyCountByDateAndType);
+        result.put("forumCount", postCountByDateAndType + replyCountByDateAndType);
         return CommonResult.data(result);
     }
 
@@ -811,7 +813,6 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
         List<Map<String, String>> studentAndTeacher = forumPostInfoMapper.getStudentPostInfoList(courseId, dateType);
         // 封装参数
         JSONArray jsonArray = new JSONArray();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         if (studentAndTeacher.size() > 0) {
             for (Map<String, String> dataMap : studentAndTeacher) {
                 com.alibaba.fastjson.JSONObject info = new com.alibaba.fastjson.JSONObject();

+ 2 - 2
snowy-plugin/snowy-plugin-forum/snowy-plugin-forum-func/src/main/java/vip/xiaonuo/forum/modular/postreply/service/ForumPostReplyService.java

@@ -82,10 +82,10 @@ public interface ForumPostReplyService extends IService<ForumPostReply> {
     /**
      * 查询两个时间段内的发帖数
      */
-    long getPostCountByDateAndType(String startTime, String endTime, Integer postType);
+    long getPostCountByDateAndType(String courseId, String startTime, String endTime, Integer postType);
 
     /**
      * 查询两个时间段的回帖数
      */
-    long getReplyCountByDateAndType(String startTime, String endTime, Integer postType);
+    long getReplyCountByDateAndType(String courseId, String startTime, String endTime, Integer postType);
 }

+ 53 - 15
snowy-plugin/snowy-plugin-forum/snowy-plugin-forum-func/src/main/java/vip/xiaonuo/forum/modular/postreply/service/impl/ForumPostReplyServiceImpl.java

@@ -16,19 +16,20 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollStreamUtil;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
 import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
-import vip.xiaonuo.common.enums.CommonSortOrderEnum;
 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.postinfo.entity.ForumPostInfo;
 import vip.xiaonuo.forum.modular.postinfo.mapper.ForumPostInfoMapper;
 import vip.xiaonuo.forum.modular.postlike.entity.ForumPostLike;
@@ -47,7 +48,6 @@ import vip.xiaonuo.forum.modular.sensitivityrecord.mapper.ForumSensitivityRecord
 import vip.xiaonuo.sys.api.SysUserApi;
 
 import javax.annotation.Resource;
-import java.time.LocalDate;
 import java.util.Date;
 import java.util.List;
 
@@ -75,6 +75,12 @@ public class ForumPostReplyServiceImpl extends ServiceImpl<ForumPostReplyMapper,
     @Resource
     private ForumPostLikeMapper forumPostLikeMapper;
 
+    @Resource
+    private ForumPostReplyMapper forumPostReplyMapper;
+
+    @Resource
+    private ForumChapterDiscussionMapper forumChapterDiscussionMapper;
+
 
     @Override
     public Page<ForumPostReply> page(ForumPostReplyPageParam forumPostReplyPageParam) {
@@ -249,21 +255,53 @@ public class ForumPostReplyServiceImpl extends ServiceImpl<ForumPostReplyMapper,
     /**
      * 查询两个时间段的发帖数
      */
-    public long getPostCountByDateAndType(String startTime, String endTime, Integer postType) {
-        QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ForumPostReply::getPostType, 3);
-        queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
-        queryWrapper.lambda().eq(ForumPostReply::getParentId, "-1");
-        return this.count(queryWrapper);
+    public long getPostCountByDateAndType(String courseId, String startTime, String endTime, Integer postType) {
+        if (StringUtils.isNotBlank(courseId)) {
+            QueryWrapper<ForumChapterDiscussion> queryWrapper1 = new QueryWrapper<>();
+            queryWrapper1.lambda().eq(ForumChapterDiscussion::getCourseId, courseId);
+            List<ForumChapterDiscussion> forumChapterDiscussions = forumChapterDiscussionMapper.selectList(queryWrapper1);
+            if (forumChapterDiscussions.size() > 0) {
+                QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
+                queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
+                queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
+                queryWrapper.lambda().in(ForumPostReply::getPostId, CollStreamUtil.toList(forumChapterDiscussions, ForumChapterDiscussion::getPostId));
+                queryWrapper.lambda().eq(ForumPostReply::getParentId, "-1");
+                return this.count(queryWrapper);
+            } else {
+                return 0;
+            }
+        } else {
+            QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
+            queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
+            queryWrapper.lambda().eq(ForumPostReply::getParentId, "-1");
+            return this.count(queryWrapper);
+        }
     }
 
     @Override
-    public long getReplyCountByDateAndType(String startTime, String endTime, Integer postType) {
-        QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(ForumPostReply::getPostType, 3);
-        queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
-        queryWrapper.lambda().notIn(ForumPostReply::getParentId, "-1");
-        return this.count(queryWrapper);
+    public long getReplyCountByDateAndType(String courseId, String startTime, String endTime, Integer postType) {
+        if (StringUtils.isNotBlank(courseId)) {
+            QueryWrapper<ForumChapterDiscussion> queryWrapper1 = new QueryWrapper<>();
+            queryWrapper1.lambda().eq(ForumChapterDiscussion::getCourseId, courseId);
+            List<ForumChapterDiscussion> forumChapterDiscussions = forumChapterDiscussionMapper.selectList(queryWrapper1);
+            if (forumChapterDiscussions.size() > 0) {
+                QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
+                queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
+                queryWrapper.lambda().notIn(ForumPostReply::getParentId, "-1");
+                queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
+                queryWrapper.lambda().in(ForumPostReply::getPostId, CollStreamUtil.toList(forumChapterDiscussions, ForumChapterDiscussion::getPostId));
+                return this.count(queryWrapper);
+            } else {
+                return 0;
+            }
+        } else {
+            QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
+            queryWrapper.lambda().notIn(ForumPostReply::getParentId, "-1");
+            queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
+            return this.count(queryWrapper);
+        }
     }
 
 }