Переглянути джерело

fix(water): paginate facility queries for KingbaseES

Kazerin 1 тиждень тому
батько
коміт
9ecc93d674
11 змінених файлів з 200 додано та 51 видалено
  1. 10 7
      pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterPipeInfo/service/impl/WaterPipeInfoServiceImpl.java
  2. 11 5
      pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterPlantInfo/service/impl/WaterPlantInfoServiceImpl.java
  3. 11 5
      pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterPumpStation/service/impl/WaterPumpStationServiceImpl.java
  4. 11 5
      pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterSourceInfo/service/impl/WaterSourceInfoServiceImpl.java
  5. 11 5
      pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterUserInfo/service/impl/WaterUserInfoServiceImpl.java
  6. 8 8
      pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterPipeInfo/WaterPipeInfoMapper.xml
  7. 4 4
      pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterPlantInfo/WaterPlantInfoMapper.xml
  8. 4 4
      pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterPumpStation/WaterPumpStationMapper.xml
  9. 4 4
      pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterSourceInfo/WaterSourceInfoMapper.xml
  10. 4 4
      pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterUserInfo/WaterUserInfoMapper.xml
  11. 122 0
      pipe-network-service/zksy-system/src/test/java/com/zksy/WaterSupply/WaterFacilityQueryServiceTest.java

+ 10 - 7
pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterPipeInfo/service/impl/WaterPipeInfoServiceImpl.java

@@ -8,12 +8,10 @@ import com.zksy.WaterSupply.WaterPipeInfo.domain.WaterPipeInfo;
 import com.zksy.WaterSupply.WaterPipeInfo.mapper.WaterPipeInfoMapper;
 import com.zksy.WaterSupply.WaterPipeInfo.service.IWaterPipeInfoService;
 import org.springframework.stereotype.Service;
-import org.springframework.util.StringUtils;
 
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 @Service
 public class WaterPipeInfoServiceImpl extends ServiceImpl<WaterPipeInfoMapper, WaterPipeInfo>
@@ -27,10 +25,15 @@ public class WaterPipeInfoServiceImpl extends ServiceImpl<WaterPipeInfoMapper, W
                                           String status,
                                           LocalDateTime startTime,
                                           LocalDateTime endTime) {
-        List<WaterPipeInfo> list = baseMapper.selectPipeList(pipeCode, pipeName, pipeMaterial, status, startTime, endTime);
-        page.setRecords(list);
-        page.setTotal(list.size());
-        return page;
+        LambdaQueryWrapper<WaterPipeInfo> query = new LambdaQueryWrapper<WaterPipeInfo>()
+                .like(pipeCode != null && !pipeCode.isEmpty(), WaterPipeInfo::getPipeCode, pipeCode)
+                .like(pipeName != null && !pipeName.isEmpty(), WaterPipeInfo::getPipeName, pipeName)
+                .eq(pipeMaterial != null && !pipeMaterial.isEmpty(), WaterPipeInfo::getPipeMaterial, pipeMaterial)
+                .eq(status != null && !status.isEmpty(), WaterPipeInfo::getStatus, status)
+                .ge(startTime != null, WaterPipeInfo::getCreateTime, startTime)
+                .le(endTime != null, WaterPipeInfo::getCreateTime, endTime)
+                .orderByDesc(WaterPipeInfo::getCreateTime);
+        return baseMapper.selectPage(page, query);
     }
 
     @Override
@@ -82,4 +85,4 @@ public class WaterPipeInfoServiceImpl extends ServiceImpl<WaterPipeInfoMapper, W
         }
         return baseMapper.deleteByIdsPhysically(ids) > 0;
     }
-}
+}

+ 11 - 5
pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterPlantInfo/service/impl/WaterPlantInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zksy.WaterSupply.WaterPlantInfo.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -23,10 +24,15 @@ public class WaterPlantInfoServiceImpl extends ServiceImpl<WaterPlantInfoMapper,
                                            String principal,
                                            LocalDateTime startTime,
                                            LocalDateTime endTime) {
-        List<WaterPlantInfo> list = baseMapper.selectPlantList(plantCode, plantName, status, principal, startTime, endTime);
-        page.setRecords(list);
-        page.setTotal(list.size());
-        return page;
+        LambdaQueryWrapper<WaterPlantInfo> query = new LambdaQueryWrapper<WaterPlantInfo>()
+                .like(plantCode != null && !plantCode.isEmpty(), WaterPlantInfo::getPlantCode, plantCode)
+                .like(plantName != null && !plantName.isEmpty(), WaterPlantInfo::getPlantName, plantName)
+                .eq(status != null && !status.isEmpty(), WaterPlantInfo::getStatus, status)
+                .like(principal != null && !principal.isEmpty(), WaterPlantInfo::getPrincipal, principal)
+                .ge(startTime != null, WaterPlantInfo::getCreateTime, startTime)
+                .le(endTime != null, WaterPlantInfo::getCreateTime, endTime)
+                .orderByDesc(WaterPlantInfo::getCreateTime);
+        return baseMapper.selectPage(page, query);
     }
 
     @Override
@@ -57,4 +63,4 @@ public class WaterPlantInfoServiceImpl extends ServiceImpl<WaterPlantInfoMapper,
         }
         return baseMapper.deleteByIdsPhysically(ids) > 0;
     }
-}
+}

+ 11 - 5
pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterPumpStation/service/impl/WaterPumpStationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zksy.WaterSupply.WaterPumpStation.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -23,10 +24,15 @@ public class WaterPumpStationServiceImpl extends ServiceImpl<WaterPumpStationMap
                                              String principal,
                                              LocalDateTime startTime,
                                              LocalDateTime endTime) {
-        List<WaterPumpStation> list = baseMapper.selectStationList(stationCode, stationName, status, principal, startTime, endTime);
-        page.setRecords(list);
-        page.setTotal(list.size());
-        return page;
+        LambdaQueryWrapper<WaterPumpStation> query = new LambdaQueryWrapper<WaterPumpStation>()
+                .like(stationCode != null && !stationCode.isEmpty(), WaterPumpStation::getStationCode, stationCode)
+                .like(stationName != null && !stationName.isEmpty(), WaterPumpStation::getStationName, stationName)
+                .eq(status != null && !status.isEmpty(), WaterPumpStation::getStatus, status)
+                .like(principal != null && !principal.isEmpty(), WaterPumpStation::getPrincipal, principal)
+                .ge(startTime != null, WaterPumpStation::getCreateTime, startTime)
+                .le(endTime != null, WaterPumpStation::getCreateTime, endTime)
+                .orderByDesc(WaterPumpStation::getCreateTime);
+        return baseMapper.selectPage(page, query);
     }
 
     @Override
@@ -57,4 +63,4 @@ public class WaterPumpStationServiceImpl extends ServiceImpl<WaterPumpStationMap
         }
         return baseMapper.deleteByIdsPhysically(ids) > 0;
     }
-}
+}

+ 11 - 5
pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterSourceInfo/service/impl/WaterSourceInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zksy.WaterSupply.WaterSourceInfo.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -23,10 +24,15 @@ public class WaterSourceInfoServiceImpl extends ServiceImpl<WaterSourceInfoMappe
                                             String unit,
                                             LocalDateTime startTime,
                                             LocalDateTime endTime) {
-        List<WaterSourceInfo> list = baseMapper.selectSourceList(sourceId, sourceName, status, unit, startTime, endTime);
-        page.setRecords(list);
-        page.setTotal(list.size());
-        return page;
+        LambdaQueryWrapper<WaterSourceInfo> query = new LambdaQueryWrapper<WaterSourceInfo>()
+                .like(sourceId != null && !sourceId.isEmpty(), WaterSourceInfo::getSourceId, sourceId)
+                .like(sourceName != null && !sourceName.isEmpty(), WaterSourceInfo::getSourceName, sourceName)
+                .eq(status != null && !status.isEmpty(), WaterSourceInfo::getStatus, status)
+                .like(unit != null && !unit.isEmpty(), WaterSourceInfo::getUnit, unit)
+                .ge(startTime != null, WaterSourceInfo::getCreateTime, startTime)
+                .le(endTime != null, WaterSourceInfo::getCreateTime, endTime)
+                .orderByDesc(WaterSourceInfo::getCreateTime);
+        return baseMapper.selectPage(page, query);
     }
 
     @Override
@@ -53,4 +59,4 @@ public class WaterSourceInfoServiceImpl extends ServiceImpl<WaterSourceInfoMappe
         if (ids == null || ids.isEmpty()) return false;
         return baseMapper.deleteByIdsPhysically(ids) > 0;
     }
-}
+}

+ 11 - 5
pipe-network-service/zksy-system/src/main/java/com/zksy/WaterSupply/WaterUserInfo/service/impl/WaterUserInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zksy.WaterSupply.WaterUserInfo.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -22,10 +23,15 @@ public class WaterUserInfoServiceImpl extends ServiceImpl<WaterUserInfoMapper, W
                                           String userType,
                                           LocalDateTime startTime,
                                           LocalDateTime endTime) {
-        List<WaterUserInfo> list = baseMapper.selectUserList(userCode, userName, status, userType, startTime, endTime);
-        page.setRecords(list);
-        page.setTotal(list.size());
-        return page;
+        LambdaQueryWrapper<WaterUserInfo> query = new LambdaQueryWrapper<WaterUserInfo>()
+                .like(userCode != null && !userCode.isEmpty(), WaterUserInfo::getUserCode, userCode)
+                .like(userName != null && !userName.isEmpty(), WaterUserInfo::getUserName, userName)
+                .eq(status != null && !status.isEmpty(), WaterUserInfo::getStatus, status)
+                .eq(userType != null && !userType.isEmpty(), WaterUserInfo::getUserType, userType)
+                .ge(startTime != null, WaterUserInfo::getCreateTime, startTime)
+                .le(endTime != null, WaterUserInfo::getCreateTime, endTime)
+                .orderByDesc(WaterUserInfo::getCreateTime);
+        return baseMapper.selectPage(page, query);
     }
 
     @Override
@@ -52,4 +58,4 @@ public class WaterUserInfoServiceImpl extends ServiceImpl<WaterUserInfoMapper, W
         if (ids == null || ids.isEmpty()) return false;
         return baseMapper.deleteByIdsPhysically(ids) > 0;
     }
-}
+}

+ 8 - 8
pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterPipeInfo/WaterPipeInfoMapper.xml

@@ -35,7 +35,7 @@
 
     <select id="selectPipeList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_pipe_info
+        FROM app_user.water_pipe_info
         WHERE del_flag = '0'
         <if test="pipeCode != null and pipeCode != ''">
             AND pipe_code LIKE CONCAT('%', #{pipeCode}, '%')
@@ -62,7 +62,7 @@
         SELECT
         status,
         COUNT(*) AS pipeCount
-        FROM water_pipe_info
+        FROM app_user.water_pipe_info
         WHERE del_flag = '0'
         GROUP BY status
     </select>
@@ -72,14 +72,14 @@
         pipe_material AS pipeMaterial,
         COUNT(*) AS pipeCount,
         SUM(pipe_length) AS totalLength
-        FROM water_pipe_info
+        FROM app_user.water_pipe_info
         WHERE del_flag = '0'
         GROUP BY pipe_material
     </select>
 
     <select id="getLatestPipe" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_pipe_info
+        FROM app_user.water_pipe_info
         WHERE del_flag = '0'
         ORDER BY create_time DESC
         LIMIT 1
@@ -91,13 +91,13 @@
         SUM(pipe_length) AS totalLength,
         SUM(CASE WHEN status = '0' THEN 1 ELSE 0 END) AS runningCount,
         SUM(CASE WHEN status = '1' THEN 1 ELSE 0 END) AS stopCount
-        FROM water_pipe_info
+        FROM app_user.water_pipe_info
         WHERE del_flag = '0'
     </select>
 
     <select id="selectDeletedList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_pipe_info
+        FROM app_user.water_pipe_info
         WHERE del_flag = '2'
         <if test="pipeCode != null and pipeCode != ''">
             AND pipe_code LIKE CONCAT('%', #{pipeCode}, '%')
@@ -118,14 +118,14 @@
     </select>
 
     <delete id="deleteByIdsPhysically">
-        DELETE FROM water_pipe_info WHERE id IN
+        DELETE FROM app_user.water_pipe_info WHERE id IN
         <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
 
     <update id="restoreByIds">
-        UPDATE water_pipe_info
+        UPDATE app_user.water_pipe_info
         SET del_flag = '0',
         update_by = #{updateBy},
         update_time = CURRENT_TIMESTAMP

+ 4 - 4
pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterPlantInfo/WaterPlantInfoMapper.xml

@@ -36,7 +36,7 @@
     <!-- 条件查询水厂列表 -->
     <select id="selectPlantList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_plant_info
+        FROM app_user.water_plant_info
         WHERE del_flag = '0'
         <if test="plantCode != null and plantCode != ''">
             AND plant_code LIKE CONCAT('%', #{plantCode}, '%')
@@ -61,7 +61,7 @@
 
     <select id="selectDeletedList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_plant_info
+        FROM app_user.water_plant_info
         WHERE del_flag = '2'
         <if test="plantCode != null and plantCode != ''">
             AND plant_code LIKE CONCAT('%', #{plantCode}, '%')
@@ -82,7 +82,7 @@
     </select>
 
     <update id="restoreByIds">
-        UPDATE water_plant_info
+        UPDATE app_user.water_plant_info
         SET del_flag = '0',
         update_by = #{updateBy},
         update_time = CURRENT_TIMESTAMP
@@ -93,7 +93,7 @@
     </update>
 
     <delete id="deleteByIdsPhysically">
-        DELETE FROM water_plant_info WHERE id IN
+        DELETE FROM app_user.water_plant_info WHERE id IN
         <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 4 - 4
pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterPumpStation/WaterPumpStationMapper.xml

@@ -34,7 +34,7 @@
     <!-- 条件查询泵站列表 -->
     <select id="selectStationList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_pump_station
+        FROM app_user.water_pump_station
         WHERE del_flag = '0'
         <if test="stationCode != null and stationCode != ''">
             AND station_code LIKE CONCAT('%', #{stationCode}, '%')
@@ -60,7 +60,7 @@
     <!-- 回收站SQL -->
     <select id="selectDeletedList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_pump_station
+        FROM app_user.water_pump_station
         WHERE del_flag = '2'
         <if test="stationCode != null and stationCode != ''">
             AND station_code LIKE CONCAT('%', #{stationCode}, '%')
@@ -81,7 +81,7 @@
     </select>
 
     <update id="restoreByIds">
-        UPDATE water_pump_station
+        UPDATE app_user.water_pump_station
         SET del_flag = '0',
         update_by = #{updateBy},
         update_time = CURRENT_TIMESTAMP
@@ -92,7 +92,7 @@
     </update>
 
     <delete id="deleteByIdsPhysically">
-        DELETE FROM water_pump_station WHERE id IN
+        DELETE FROM app_user.water_pump_station WHERE id IN
         <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 4 - 4
pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterSourceInfo/WaterSourceInfoMapper.xml

@@ -34,7 +34,7 @@
 
     <select id="selectSourceList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_source_info
+        FROM app_user.water_source_info
         WHERE del_flag = '0'
         <if test="sourceId != null and sourceId != ''">
             AND source_id LIKE CONCAT('%', #{sourceId}, '%')
@@ -59,7 +59,7 @@
 
     <select id="selectDeletedList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_source_info
+        FROM app_user.water_source_info
         WHERE del_flag = '2'
         <if test="sourceId != null and sourceId != ''">
             AND source_id LIKE CONCAT('%', #{sourceId}, '%')
@@ -80,7 +80,7 @@
     </select>
 
     <update id="restoreByIds">
-        UPDATE water_source_info
+        UPDATE app_user.water_source_info
         SET del_flag = '0',
         update_by = #{updateBy},
         update_time = CURRENT_TIMESTAMP
@@ -91,7 +91,7 @@
     </update>
 
     <delete id="deleteByIdsPhysically">
-        DELETE FROM water_source_info WHERE id IN
+        DELETE FROM app_user.water_source_info WHERE id IN
         <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 4 - 4
pipe-network-service/zksy-system/src/main/resources/mapper/WaterSupply/WaterUserInfo/WaterUserInfoMapper.xml

@@ -34,7 +34,7 @@
 
     <select id="selectUserList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_user_info
+        FROM app_user.water_user_info
         WHERE del_flag = '0'
         <if test="userCode != null and userCode != ''">
             AND user_code LIKE CONCAT('%', #{userCode}, '%')
@@ -59,7 +59,7 @@
 
     <select id="selectDeletedList" resultMap="BaseResultMap">
         SELECT <include refid="Base_Column_List"/>
-        FROM water_user_info
+        FROM app_user.water_user_info
         WHERE del_flag = '2'
         <if test="userCode != null and userCode != ''">
             AND user_code LIKE CONCAT('%', #{userCode}, '%')
@@ -80,7 +80,7 @@
     </select>
 
     <update id="restoreByIds">
-        UPDATE water_user_info
+        UPDATE app_user.water_user_info
         SET del_flag = '0',
         update_by = #{updateBy},
         update_time = CURRENT_TIMESTAMP
@@ -91,7 +91,7 @@
     </update>
 
     <delete id="deleteByIdsPhysically">
-        DELETE FROM water_user_info WHERE id IN
+        DELETE FROM app_user.water_user_info WHERE id IN
         <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 122 - 0
pipe-network-service/zksy-system/src/test/java/com/zksy/WaterSupply/WaterFacilityQueryServiceTest.java

@@ -0,0 +1,122 @@
+package com.zksy.WaterSupply;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.WaterSupply.WaterPipeInfo.domain.WaterPipeInfo;
+import com.zksy.WaterSupply.WaterPipeInfo.mapper.WaterPipeInfoMapper;
+import com.zksy.WaterSupply.WaterPipeInfo.service.impl.WaterPipeInfoServiceImpl;
+import com.zksy.WaterSupply.WaterPlantInfo.domain.WaterPlantInfo;
+import com.zksy.WaterSupply.WaterPlantInfo.mapper.WaterPlantInfoMapper;
+import com.zksy.WaterSupply.WaterPlantInfo.service.impl.WaterPlantInfoServiceImpl;
+import com.zksy.WaterSupply.WaterPumpStation.domain.WaterPumpStation;
+import com.zksy.WaterSupply.WaterPumpStation.mapper.WaterPumpStationMapper;
+import com.zksy.WaterSupply.WaterPumpStation.service.impl.WaterPumpStationServiceImpl;
+import com.zksy.WaterSupply.WaterSourceInfo.domain.WaterSourceInfo;
+import com.zksy.WaterSupply.WaterSourceInfo.mapper.WaterSourceInfoMapper;
+import com.zksy.WaterSupply.WaterSourceInfo.service.impl.WaterSourceInfoServiceImpl;
+import com.zksy.WaterSupply.WaterUserInfo.domain.WaterUserInfo;
+import com.zksy.WaterSupply.WaterUserInfo.mapper.WaterUserInfoMapper;
+import com.zksy.WaterSupply.WaterUserInfo.service.impl.WaterUserInfoServiceImpl;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentMatchers;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import java.util.List;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class WaterFacilityQueryServiceTest {
+
+    @Test
+    void pipeQueryUsesDatabasePaginationAndFilters() {
+        WaterPipeInfoMapper mapper = mock(WaterPipeInfoMapper.class);
+        Page<WaterPipeInfo> expected = pageOf(new WaterPipeInfo());
+        when(mapper.selectPage(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(expected);
+        WaterPipeInfoServiceImpl service = new WaterPipeInfoServiceImpl();
+        ReflectionTestUtils.setField(service, "baseMapper", mapper);
+
+        IPage<WaterPipeInfo> actual = service.queryPage(new Page<>(2, 20), "P-1", "主干", "PE", "0", null, null);
+
+        assertEquals(expected, actual);
+        verify(mapper).selectPage(ArgumentMatchers.any(), ArgumentMatchers.any());
+    }
+
+    @Test
+    void plantQueryUsesDatabasePagination() {
+        WaterPlantInfoMapper mapper = mock(WaterPlantInfoMapper.class);
+        Page<WaterPlantInfo> expected = pageOf(new WaterPlantInfo());
+        when(mapper.selectPage(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(expected);
+        WaterPlantInfoServiceImpl service = new WaterPlantInfoServiceImpl();
+        ReflectionTestUtils.setField(service, "baseMapper", mapper);
+
+        assertEquals(expected, service.queryPage(new Page<>(3, 5), "P", "厂", "0", "负责人", null, null));
+        verify(mapper).selectPage(ArgumentMatchers.any(), ArgumentMatchers.any());
+    }
+
+    @Test
+    void pumpStationQueryUsesDatabasePagination() {
+        WaterPumpStationMapper mapper = mock(WaterPumpStationMapper.class);
+        Page<WaterPumpStation> expected = pageOf(new WaterPumpStation());
+        when(mapper.selectPage(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(expected);
+        WaterPumpStationServiceImpl service = new WaterPumpStationServiceImpl();
+        ReflectionTestUtils.setField(service, "baseMapper", mapper);
+
+        assertEquals(expected, service.queryPage(new Page<>(1, 10), "S", "泵站", "0", "负责人", null, null));
+        verify(mapper).selectPage(ArgumentMatchers.any(), ArgumentMatchers.any());
+    }
+
+    @Test
+    void sourceQueryUsesDatabasePagination() {
+        WaterSourceInfoMapper mapper = mock(WaterSourceInfoMapper.class);
+        Page<WaterSourceInfo> expected = pageOf(new WaterSourceInfo());
+        when(mapper.selectPage(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(expected);
+        WaterSourceInfoServiceImpl service = new WaterSourceInfoServiceImpl();
+        ReflectionTestUtils.setField(service, "baseMapper", mapper);
+
+        assertEquals(expected, service.queryPage(new Page<>(1, 10), "W", "水源", "0", "单位", null, null));
+        verify(mapper).selectPage(ArgumentMatchers.any(), ArgumentMatchers.any());
+    }
+
+    @Test
+    void waterUserQueryUsesDatabasePagination() {
+        WaterUserInfoMapper mapper = mock(WaterUserInfoMapper.class);
+        Page<WaterUserInfo> expected = pageOf(new WaterUserInfo());
+        when(mapper.selectPage(ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(expected);
+        WaterUserInfoServiceImpl service = new WaterUserInfoServiceImpl();
+        ReflectionTestUtils.setField(service, "baseMapper", mapper);
+
+        assertEquals(expected, service.queryPage(new Page<>(4, 10), "U", "居民", "0", "居民", null, null));
+        verify(mapper).selectPage(ArgumentMatchers.any(), ArgumentMatchers.any());
+    }
+
+    @Test
+    void facilityMapperQueriesUseKingbaseAppUserSchema() throws Exception {
+        String[] mapperPaths = {
+                "mapper/WaterSupply/WaterPipeInfo/WaterPipeInfoMapper.xml",
+                "mapper/WaterSupply/WaterPlantInfo/WaterPlantInfoMapper.xml",
+                "mapper/WaterSupply/WaterPumpStation/WaterPumpStationMapper.xml",
+                "mapper/WaterSupply/WaterSourceInfo/WaterSourceInfoMapper.xml",
+                "mapper/WaterSupply/WaterUserInfo/WaterUserInfoMapper.xml"
+        };
+        for (String path : mapperPaths) {
+            try (InputStream input = getClass().getClassLoader().getResourceAsStream(path)) {
+                String xml = new String(input.readAllBytes(), StandardCharsets.UTF_8);
+                org.junit.jupiter.api.Assertions.assertFalse(
+                        xml.matches("(?s).*\\b(?:FROM|UPDATE|DELETE FROM)\\s+water_(?:pipe_info|plant_info|pump_station|source_info|user_info)\\b.*"),
+                        path + " must qualify facilities with app_user schema");
+            }
+        }
+    }
+
+    private static <T> Page<T> pageOf(T record) {
+        Page<T> page = new Page<>(1, 1);
+        page.setRecords(List.of(record));
+        page.setTotal(1);
+        return page;
+    }
+}