Pārlūkot izejas kodu

监控设备列表查询添加分页

jichaobo 3 gadi atpakaļ
vecāks
revīzija
7663c2acfa

+ 4 - 2
fiveep-controller/src/main/java/com/bizmatics/controller/web/DeviceAttributeController.java

@@ -85,8 +85,10 @@ public class DeviceAttributeController {
      * @return
      */
     @GetMapping("monitorDeviceList")
-    public ApiResult<List<MonitorDeviceListVO>> monitorDeviceList(@RequestParam(required = false) String siteName) {
-        return ApiResult.success(deviceAttributeService.monitorDeviceList(siteName));
+    public ApiResult<CommonPage<MonitorDeviceListVO>> monitorDeviceList(@RequestParam(required = false) String siteName,
+                                                                  @RequestParam(value = "size", required = false, defaultValue = "15") int size,
+                                                                  @RequestParam(value = "current", required = false, defaultValue = "1") int current) {
+        return ApiResult.success(deviceAttributeService.monitorDeviceList(siteName,size,current));
     }
 }
 

+ 3 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/DeviceAttributeMapper.java

@@ -16,5 +16,7 @@ import java.util.List;
  * @since 2021-09-24
  */
 public interface DeviceAttributeMapper extends CrudMapper<DeviceAttribute> {
-    List<MonitorDeviceListVO> monitorDeviceList(@Param("siteName") String siteName);
+    List<MonitorDeviceListVO> monitorDeviceList(@Param("siteName") String siteName,
+                                                @Param("startCurrent") Integer startCurrent,
+                                                @Param("size") Integer size);
 }

+ 4 - 0
fiveep-persistence/src/main/resources/mapper/mysql/DeviceAttributeMapper.xml

@@ -50,5 +50,9 @@
                 and a.site_name LIKE CONCAT(CONCAT('%', #{siteName}), '%')
             </if>
         </where>
+        <if test="startCurrent != null and size !=0">
+            LIMIT #{startCurrent},
+            #{size}
+        </if>
     </select>
 </mapper>

+ 1 - 1
fiveep-service/src/main/java/com/bizmatics/service/DeviceAttributeService.java

@@ -23,5 +23,5 @@ public interface DeviceAttributeService extends CrudService<DeviceAttribute> {
 
     void deviceNewsDel(int id);
 
-    List<MonitorDeviceListVO> monitorDeviceList(String siteName);
+    CommonPage<MonitorDeviceListVO> monitorDeviceList(String siteName,Integer size,Integer current);
 }

+ 10 - 3
fiveep-service/src/main/java/com/bizmatics/service/impl/DeviceAttributeServiceImpl.java

@@ -69,8 +69,15 @@ public class DeviceAttributeServiceImpl extends AbstractCrudService<DeviceAttrib
     }
 
     @Override
-    public List<MonitorDeviceListVO> monitorDeviceList(String siteName) {
-        List<MonitorDeviceListVO> monitorDeviceList = baseMapper.monitorDeviceList(siteName);
-        return monitorDeviceList;
+    public CommonPage<MonitorDeviceListVO> monitorDeviceList(String siteName ,Integer size,Integer current) {
+        List<MonitorDeviceListVO> monitorDeviceListOne = baseMapper.monitorDeviceList(siteName,null,0);
+        Integer total = 0;
+        if (monitorDeviceListOne.size()>0){
+            total = monitorDeviceListOne.size();
+        }
+        IPage<DeviceAttribute> page = new Page<DeviceAttribute>(current, size);
+        List<MonitorDeviceListVO> monitorDeviceList = baseMapper.monitorDeviceList(siteName,0,size);
+//        return monitorDeviceList;
+        return new CommonPage<>(monitorDeviceList, total, page.getSize(),page.getCurrent());
     }
 }