From 40a647b468d117381abf63d9f98f1cc9308ef3fc Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Wed, 27 Mar 2024 10:23:47 +0800
Subject: [PATCH] 议事查询优化

---
 src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml b/src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml
index b31641d..73530a1 100644
--- a/src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml
+++ b/src/main/java/org/springblade/modules/discuss/mapper/UserTopicsMapper.xml
@@ -30,24 +30,25 @@
 
 
     <select id="selectUserTopicsPage" resultMap="userTopicsResultMap">
-        SELECT distinct
+        SELECT
         jut.article_id,
         jut.delete_flag,
         jut.signature_path,
         jut.create_time,
+        jut.household_id,
         bu.avatar,
-        bu.`name`,
-        bu.phone,
+        jh.name,
+        jh.phone_number phone,
         jda.address_name,
-        jda.aoi_name,
-        jt.option_content
+        jda.aoi_name
+        <if test="userTopics.articleId != null ">,
+        group_concat(jt.option_content) optionContent  </if>
         FROM
         jczz_user_topics as jut
-        LEFT JOIN blade_user bu ON jut.user_id = bu.id AND bu.is_deleted = 0
-        LEFT JOIN jczz_household jh ON jh.house_code = jut.house_code
-        AND jh.is_deleted = 0 and jut.user_id =jh.associated_user_id
+        LEFT JOIN jczz_household jh ON jh.id = jut.household_id and jh.is_deleted = 0
         LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jh.house_code
         LEFT JOIN jczz_topics jt on jt.id = jut.topics_id
+        LEFT JOIN blade_user bu ON jh.associated_user_id = bu.id AND bu.is_deleted = 0
         <where>
             <if test="userTopics.id != null ">and jut.id = #{userTopics.id}</if>
             <if test="userTopics.name != null and userTopics.name != ''">
@@ -64,20 +65,20 @@
                 </foreach>
             </if>
 
-            <if test="userTopics.userId != null ">and jut.user_id = #{userTopics.userId}</if>
+            <if test="userTopics.householdId != null ">and jut.household_id = #{userTopics.householdId}</if>
             <if test="userTopics.topicsId != null ">and jut.topics_id = #{userTopics.topicsId}</if>
             <if test="userTopics.createTime != null ">and jut.create_time = #{userTopics.createTime}</if>
             <if test="userTopics.updateTime != null ">and jut.update_time = #{userTopics.updateTime}</if>
             <if test="userTopics.deleteFlag != null ">and jut.delete_flag = #{userTopics.deleteFlag}</if>
-            <if test="userTopics.articleId != null ">and jut.article_id = #{userTopics.articleId}
+            <if test="userTopics.articleId != null ">
+                and jut.article_id = #{userTopics.articleId}
                 and jut.delete_flag = 0
-                GROUP BY jut.article_id, jut.signature_path,jut.create_time,jut.delete_flag,
+                GROUP BY jut.article_id, jut.signature_path,jut.create_time,jut.household_id,jut.delete_flag,
                 bu.avatar,
-                bu.`name`,
-                bu.phone,
+                jh.name,
+                jh.phone_number,
                 jda.address_name,
-                jda.aoi_name,
-                jt.option_content
+                jda.aoi_name
             </if>
         </where>
     </select>

--
Gitblit v1.9.3