From fcb76a9ebc56575bb0d17a04e0d7c715976be6d6 Mon Sep 17 00:00:00 2001
From: Lawrence <1934378145@qq.com>
Date: 星期四, 14 一月 2021 23:41:54 +0800
Subject: [PATCH] 修正初次打开通道选择列表每页数量不对的问题
---
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java | 33 ++++++++++++++++++++-------------
1 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
index 65e294a..17d1e7d 100644
--- a/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
+++ b/src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java
@@ -1,15 +1,14 @@
package com.genersoft.iot.vmp.vmanager.device;
-import java.util.List;
-
-import com.genersoft.iot.vmp.common.PageResult;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
+import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
@@ -53,34 +52,42 @@
}
@GetMapping("/devices")
- public PageResult<Device> devices(int page, int count){
+ public PageInfo<Device> devices(int page, int count){
if (logger.isDebugEnabled()) {
logger.debug("鏌ヨ鎵�鏈夎棰戣澶嘇PI璋冪敤");
}
- return storager.queryVideoDeviceList(null, page, count);
+ return storager.queryVideoDeviceList(page, count);
}
/**
* 鍒嗛〉鏌ヨ閫氶亾鏁�
+ *
* @param deviceId 璁惧id
* @param page 褰撳墠椤�
* @param count 姣忛〉鏉℃暟
+ * @param query 鏌ヨ鍐呭
+ * @param online 鏄惁鍦ㄧ嚎 鍦ㄧ嚎 true / 绂荤嚎 false
+ * @param channelType 璁惧 false/瀛愮洰褰� true
* @return 閫氶亾鍒楄〃
*/
@GetMapping("/devices/{deviceId}/channels")
- public ResponseEntity<PageResult> channels(@PathVariable String deviceId,
+ public ResponseEntity<PageInfo> channels(@PathVariable String deviceId,
int page, int count,
@RequestParam(required = false) String query,
- @RequestParam(required = false) String online,
+ @RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean channelType
){
if (logger.isDebugEnabled()) {
logger.debug("鏌ヨ鎵�鏈夎棰戣澶嘇PI璋冪敤");
}
- PageResult pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count);
+ if (StringUtils.isEmpty(query)) {
+ query = null;
+ }
+
+ PageInfo pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
}
@@ -141,7 +148,7 @@
* @return 瀛愰�氶亾鍒楄〃
*/
@GetMapping("/subChannels/{deviceId}/{channelId}/channels")
- public ResponseEntity<PageResult> subChannels(@PathVariable String deviceId,
+ public ResponseEntity<PageInfo> subChannels(@PathVariable String deviceId,
@PathVariable String channelId,
int page,
int count,
@@ -154,23 +161,23 @@
}
DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId);
if (deviceChannel == null) {
- PageResult<DeviceChannel> deviceChannelPageResult = new PageResult<>();
+ PageInfo<DeviceChannel> deviceChannelPageResult = new PageInfo<>();
return new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK);
}
- PageResult pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
+ PageInfo pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count);
return new ResponseEntity<>(pageResult,HttpStatus.OK);
}
@PostMapping("/channel/update/{deviceId}")
- public ResponseEntity<PageResult> updateChannel(@PathVariable String deviceId,DeviceChannel channel){
+ public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){
storager.updateChannel(deviceId, channel);
return new ResponseEntity<>(null,HttpStatus.OK);
}
@GetMapping("/devices/{deviceId}/transport/{streamMode}")
@PostMapping("/devices/{deviceId}/transport/{streamMode}")
- public ResponseEntity<PageResult> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
+ public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){
Device device = storager.queryVideoDevice(deviceId);
device.setStreamMode(streamMode);
storager.updateDevice(device);
--
Gitblit v1.8.0