Kaynağa Gözat

1.在线论坛多增加一个统计数量接口

jasonk5949 7 ay önce
ebeveyn
işleme
476a333762

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

@@ -172,5 +172,13 @@ public class ForumPostInfoController {
     }
 
 
+    /**
+     * 查询所有发帖数和回帖数
+     */
+    @GetMapping("/forum/postinfo/getCount")
+    public CommonResult<JSONObject> getCount() {
+        return forumPostInfoService.getCount();
+    }
+
 
 }

+ 8 - 0
snowy-plugin/snowy-plugin-forum/snowy-plugin-forum-func/src/main/java/vip/xiaonuo/forum/modular/postinfo/service/ForumPostInfoService.java

@@ -103,5 +103,13 @@ public interface ForumPostInfoService extends IService<ForumPostInfo> {
      */
     Page<ForumPostInfo> moreList(ForumPostInfoPageParam forumPostInfoPageParam);
 
+    /**
+     * 后台帖子列表
+     */
     Page<ForumPostInfo> adminPage(ForumPostInfoPageParam forumPostInfoPageParam);
+
+    /**
+     * 查询所有发帖数和回帖数
+     */
+    CommonResult<JSONObject> getCount();
 }

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

@@ -539,4 +539,20 @@ public class ForumPostInfoServiceImpl extends ServiceImpl<ForumPostInfoMapper, F
         return page;
     }
 
+    @Override
+    public CommonResult<com.alibaba.fastjson.JSONObject> getCount() {
+        // 查询帖子未关闭的总数量
+        QueryWrapper<ForumPostInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ForumPostInfo::getPostStatus, 0);
+        long count = this.count(queryWrapper);
+        // 查询所有回复数量
+        QueryWrapper<ForumPostReply> queryWrapper1 = new QueryWrapper<>();
+        long replyCount = forumPostReplyService.count(queryWrapper1);
+        // 封装返回参数
+        com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
+        jsonObject.put("postCount", count);
+        jsonObject.put("replyCount", replyCount);
+        return CommonResult.data(jsonObject);
+    }
+
 }