From cb07aef10f307403e2d8b3249bb9b7de7f3d295f Mon Sep 17 00:00:00 2001
From: huanghongfa <18228131219@163.com>
Date: 星期日, 24 一月 2021 13:28:07 +0800
Subject: [PATCH] 评论

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDiscussDAO.java |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDiscussDAO.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDiscussDAO.java
index e57bcd6..91fbab1 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDiscussDAO.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDiscussDAO.java
@@ -40,7 +40,7 @@
             "d.id,\n" +
             "d.`discuss_subject`,\n" +
             "d.type,\n" +
-            "COUNT( c.id ) commentNum,\n" +
+            "COUNT( DISTINCT c.id ) commentNum,\n" +
             "u.name userName,\n" +
             "d.create_at \n" +
             "FROM\n" +
@@ -68,7 +68,7 @@
             "u.phone,\n" +
             "c.`comment`,\n" +
             "c.`parent_id`,\n" +
-            "COUNT( cu.id ) num,\n" +
+            "COUNT(DISTINCT  cu.id ) num,\n" +
             "c.create_at,\n" +
             "c.id \n" +
             "FROM\n" +
@@ -100,8 +100,8 @@
             "d.photo_pah,\n" +
             "d.`discuss_subject`,\n" +
             "d.type,\n" +
-            "COUNT( c.id ) commentNum,\n" +
-            "COUNT( du.id ) signNum,\n" +
+            "COUNT( DISTINCT c.id ) commentNum,\n" +
+            "COUNT( DISTINCT du.id ) signNum,\n" +
             "if(u.type=1,u.name,a.name) userName,\n" +
             "if(du.id is not null,1,0) haveSign,\n" +
             "if(ou.id is not null,1,0) haveVote,\n" +
@@ -169,4 +169,17 @@
 
     @Select("select name from com_act where community_id=#{communityId}")
     ComActVO selectCommunity(Long communityId);
+
+    @Select("SELECT \n" +
+            "if(du.id is not null,1,0)haveSign,\n" +
+            "if(ou.id is not null,1,0)haveVote\n" +
+            "FROM\n" +
+            "com_act_discuss d \n" +
+            "LEFT JOIN com_act_discuss_user du on d.id=du.discuss_id and du.`user_id`=#{loginUserId}\n" +
+            "LEFT JOIN com_act_discuss_option op on d.id=op.discuss_id\n" +
+            "LEFT JOIN com_act_discuss_option_user ou on op.id=ou.discuss_option_id and ou.user_id=#{loginUserId}\n" +
+            "WHERE\n" +
+            "d.id =#{id}\n" +
+            "GROUP BY d.id")
+    ComActDiscussVO selectHaveSignAndHaveVote(@Param("id") Long id, @Param("loginUserId")Long loginUserId);
 }

--
Gitblit v1.7.1