crazycat преди 2 години
родител
ревизия
4efcf839e5
променени са 1 файла, в които са добавени 20 реда и са изтрити 7 реда
  1. 20 7
      src/main/resources/mapper/GlobalLocationMapper.xml

+ 20 - 7
src/main/resources/mapper/GlobalLocationMapper.xml

@@ -259,10 +259,14 @@
         from section s
         left join lampinfo l on l.sectionid = s.id
         left join global_location gl on s.pid = gl.id
-        where gl.id in
-        <foreach collection="idList" item="item" open="(" close=")" separator=",">
-            #{item}
-        </foreach>
+        where 1=1
+        <if test="idList != null and !idList.isEmpty()">
+            and gl.id in
+            <foreach collection="idList" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+
         group by gl.id
     </select>
 
@@ -284,10 +288,13 @@
         from section s
         left join lamp_pole l on l.sectionid = s.id
         left join global_location gl on s.pid = gl.id
-        where gl.id in
+        where 1=1
+        <if test="idList != null and !idList.isEmpty()">
+         and gl.id in
         <foreach collection="idList" item="item" open="(" close=")" separator=",">
             #{item}
         </foreach>
+        </if>
         group by gl.id
     </select>
 
@@ -310,10 +317,13 @@
         left join lamp_pole l on l.sectionid = s.id
         left join global_location gl on s.pid = gl.id
         left join global_location gl1 on gl.pid = gl1.id
-        where gl1.id in
+        where 1=1
+        <if test="idList != null and !idList.isEmpty()">
+        and gl1.id in
         <foreach collection="idList" item="item" open="(" close=")" separator=",">
             #{item}
         </foreach>
+        </if>
         group by gl1.id
     </select>
 
@@ -336,10 +346,13 @@
         left join lampinfo l on l.sectionid = s.id
         left join global_location gl on s.pid = gl.id
         left join global_location gl1 on gl.pid = gl1.id
-        where gl1.id in
+        where 1=1
+        <if test="idList != null and !idList.isEmpty()">
+         and gl1.id in
         <foreach collection="idList" item="item" open="(" close=")" separator=",">
             #{item}
         </foreach>
+        </if>
         group by gl1.id
     </select>