From b3c6911c1e78563dc04998dd7bfb510130a9fcec Mon Sep 17 00:00:00 2001
From: huanghongfa <18228131219@163.com>
Date: 星期一, 01 二月 2021 16:37:52 +0800
Subject: [PATCH] auth

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComActDiscussDAO.java |   38 +++++++++++++++++++++++++-------------
 1 files changed, 25 insertions(+), 13 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 05236f8..4f72973 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
@@ -32,7 +32,7 @@
 //            " </if> " +
 //            " </where>" +
 //            "</script>")
-    @Select("select type,name,phone from sys_user where user_id=#{userId}")
+    @Select("select type,name,phone,image_url from sys_user where user_id=#{userId}")
     LoginUserInfoVO selectUserByUserId(Long userId);
     @Select("<script> " +
             "select t.* from ("+
@@ -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" +
@@ -67,7 +67,8 @@
             "u.`name` userName,\n" +
             "u.phone,\n" +
             "c.`comment`,\n" +
-            "COUNT( cu.id ) num,\n" +
+            "c.`parent_id`,\n" +
+            "COUNT(DISTINCT  cu.id ) num,\n" +
             "c.create_at,\n" +
             "c.id \n" +
             "FROM\n" +
@@ -80,12 +81,11 @@
             "AND u.phone LIKE concat( #{pageComActDiscussCommentDTO.account}, '%' )\n" +
             " </if> " +
             "LEFT JOIN com_act_discuss_comment_user cu ON c.id = cu.disscuss_comment_id \n" +
-            " <where>" +
+            " where c.discuss_id=#{pageComActDiscussCommentDTO.id}" +
             "<if test='pageComActDiscussCommentDTO.comment != null and pageComActDiscussCommentDTO.comment.trim() != &quot;&quot;'>" +
-            "c.`comment` LIKE concat( '%', #{pageComActDiscussCommentDTO.comment" +
+            " and c.`comment` LIKE concat( '%', #{pageComActDiscussCommentDTO.comment" +
             "}, '%' ) \n" +
             " </if> " +
-            " </where>" +
             "GROUP BY\n" +
             "c.id\n" +
             ")t order by t.create_at desc"+
@@ -96,12 +96,12 @@
             "SELECT\n" +
             "d.id,\n" +
             "d.vote_title,\n" +
-            "d.address,\n" +
+            "if(d.address is null or d.address='null',a.name,d.address )address,\n" +
             "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" +
@@ -155,18 +155,30 @@
             "AND u.phone LIKE concat( #{pageComActDiscussCommentDTO.account}, '%' )\n" +
             " </if> " +
             "LEFT JOIN com_act_discuss_comment_user cu ON c.id = cu.disscuss_comment_id \n" +
-            " <where>" +
+            " where c.discuss_id=#{pageComActDiscussCommentDTO.id} and parent_id=0 " +
             "<if test='pageComActDiscussCommentDTO.comment != null and pageComActDiscussCommentDTO.comment.trim() != &quot;&quot;'>" +
-            "c.`comment` LIKE concat( '%', #{pageComActDiscussCommentDTO.comment" +
+            " and c.`comment` LIKE concat( '%', #{pageComActDiscussCommentDTO.comment" +
             "}, '%' ) \n" +
             " </if> " +
-            " </where>" +
             "GROUP BY\n" +
             "c.id\n" +
             ")t order by t.is_topping desc , t.create_at desc"+
             "</script>")
     IPage<ComActDiscussCommentVO> pageDiscussCommentApplets(Page page, @Param("pageComActDiscussCommentDTO")PageComActDiscussCommentDTO pageComActDiscussCommentDTO);
 
-    @Select("select name from com_act where community_id=#{communityId}")
+    @Select("select name,address 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