ソースを参照

预问诊后台维护标签分页

wangyu 5 年 前
コミット
c2bfc49b84
1 ファイル変更38 行追加113 行削除
  1. 38 113
      precman-service/src/main/resources/mapper/QuestionInfoMapper.xml

+ 38 - 113
precman-service/src/main/resources/mapper/QuestionInfoMapper.xml

@@ -103,143 +103,68 @@
 
     <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
         <if test="callType != null and callType == 1">
-            SELECT e.* FROM(SELECT
-            a.id,
-            a.is_deleted,
-            a.gmt_create,
-            a.gmt_modified,
-            a.creator,
-            a.modifier,
-            a.tag_name,
-            a.`name`,
-            a.description,
-            a.`sex_type`,
-            a.age_begin,
-            a.age_end,
-            a.tag_type,
-            a.control_type,
-            a.type,
-            a.item_type,
-            a.label_prefix,
-            a.label_suffix,
-            a.url,
-            a.spec_flag,
-            a.required,
-            a.explains,
-            c.tag_name combinationName,
-            a.remark
+            SELECT
+            t1.id,
+            t1.is_deleted,
+            t1.gmt_create,
+            t1.gmt_modified,
+            t1.creator,
+            t1.modifier,
+            t1.tag_name,
+            t1.`name`,
+            t1.description,
+            group_concat(t3.tag_name) as combinationName,
+            t1.`sex_type`,
+            t1.age_begin,
+            t1.age_end,
+            t1.tag_type,
+            t1.control_type,
+            t1.type,
+            t1.item_type,
+            t1.label_prefix,
+            t1.label_suffix,
+            t1.url,
+            t1.spec_flag,
+            t1.required,
+            t1.explains,
+            t1.remark
             FROM
-            `prec_question_info` a,
-            prec_question_info c,
-            prec_question_mapping b
-            WHERE
-            a.is_deleted = 'N'
-            AND b.is_deleted = 'N'
-            AND c.is_deleted = 'N'
-            AND a.id = b.son_question
-            AND c.id = b.parent_question
+            `prec_question_info` t1
+            LEFT JOIN prec_question_mapping t2 on t1.id = t2.son_question and t2.is_deleted = 'N'
+            LEFT JOIN `prec_question_info` t3 on t2.parent_question = t3.id and t3.is_deleted = 'N'
+            WHERE t1.is_deleted = 'N'
             <if test="combinationName != null and combinationName != ''">
-                AND b.parent_question IN (-- 搜索所有组合项的id
-                SELECT
-                f.id
-                FROM
-                `prec_question_info` f
-                WHERE
-                f.is_deleted = 'N'
-                )
+                and t3.tag_name like concat ('%', #{combinationName}, '%')
             </if>
-            <if test="combinationName != null and combinationName != ''">
-                AND c.tag_name like concat ('%', #{combinationName}, '%')
-            </if>
-
             <if test="type != null and type != ''">
-                AND a.type = #{type}
+                AND t1.type = #{type}
             </if>
             <if test="name != null and name != ''">
-                AND a.name like concat ('%', #{name}, '%')
+                AND t1.name like concat ('%', #{name}, '%')
             </if>
             <if test="tagName != null and tagName != ''">
-                AND a.tag_name like concat ('%', #{tagName}, '%')
+                AND t1.tag_name like concat ('%', #{tagName}, '%')
             </if>
             <if test="notTypeList != null and notTypeList.size() > 0 ">
-                and a.type not in
+                and t1.type not in
                 <foreach  collection="notTypeList" item="notType" open="("  separator=","  close=")">
                     #{notType}
                 </foreach>
             </if>
             <if test="tagTypeList != null and tagTypeList.size() > 0 ">
-                and a.tag_type in
+                and t1.tag_type in
                 <foreach  collection="tagTypeList" item="tagType" open="("  separator=","  close=")">
                     #{tagType}
                 </foreach>
             </if>
             <if test="controlTypeList != null and controlTypeList.size() > 0 ">
-                and a.control_type in
+                and t1.control_type in
                 <foreach  collection="controlTypeList" item="controlType" open="("  separator=","  close=")">
                     #{controlType}
                 </foreach>
             </if>
-            <if test="combinationName == null or combinationName == ''">
-                UNION
-                SELECT d.id,
-                d.is_deleted,
-                d.gmt_create,
-                d.gmt_modified,
-                d.creator,
-                d.modifier,
-                d.tag_name,
-                d.`name`,
-                d.description,
-                d.`sex_type`,
-                d.age_begin,
-                d.age_end,
-                d.tag_type,
-                d.control_type,
-                d.type,
-                d.item_type,
-                d.label_prefix,
-                d.label_suffix,
-                d.url,
-                d.spec_flag,
-                d.required,
-                d.explains,
-                null combinationName,
-                d.remark FROM prec_question_info d
-                WHERE
-                d.is_deleted = 'N'
-                <if test="type != null and type != ''">
-                    AND d.type = #{type}
-                </if>
-                <if test="tagName != null and tagName != ''">
-                    AND d.tag_name like concat ('%', #{tagName}, '%')
-                </if>
-                <if test="name != null and name != ''">
-                    AND d.name like concat ('%', #{name}, '%')
-                </if>
-                <if test="notTypeList != null and notTypeList.size() > 0 ">
-                    and d.type not in
-                    <foreach  collection="notTypeList" item="notType" open="("  separator=","  close=")">
-                        #{notType}
-                    </foreach>
-                </if>
-                <if test="tagTypeList != null and tagTypeList.size() > 0 ">
-                    and d.tag_type in
-                    <foreach  collection="tagTypeList" item="tagType" open="("  separator=","  close=")">
-                        #{tagType}
-                    </foreach>
-                </if>
-                <if test="controlTypeList != null and controlTypeList.size() > 0 ">
-                    and d.control_type in
-                    <foreach  collection="controlTypeList" item="controlType" open="("  separator=","  close=")">
-                        #{controlType}
-                    </foreach>
-                </if>
-            </if>
-            ) e
-            GROUP BY
-            e.id
-            order by
-            e.gmt_modified desc
+            group by t1.id
+            ORDER BY t1.gmt_modified desc
         </if>
         <if test="callType != null and callType == 2">
             SELECT a.* FROM `prec_question_info` a