From 57fd18cd7c842a821bd03fafe2a954c605e387f6 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 30 九月 2020 17:59:11 +0800 Subject: [PATCH] 增加分页,搜索,等 --- src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceController.java | 45 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 37 insertions(+), 8 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 9b229ac..7958a8a 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 @@ -9,12 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; import com.alibaba.fastjson.JSONObject; @@ -72,12 +67,17 @@ * @return 閫氶亾鍒楄〃 */ @GetMapping("devices/{deviceId}/channels") - public ResponseEntity<PageResult> channels(@PathVariable String deviceId, int page, int count){ + public ResponseEntity<PageResult> channels(@PathVariable String deviceId, + int page, int count, + @RequestParam(required = false) String query, + @RequestParam(required = false) String online, + @RequestParam(required = false) Boolean channelType + ){ if (logger.isDebugEnabled()) { logger.debug("鏌ヨ鎵�鏈夎棰戣澶嘇PI璋冪敤"); } - PageResult pageResult = storager.queryChannelsByDeviceId(deviceId, page, count); + PageResult pageResult = storager.queryChannelsByDeviceId(deviceId, query, channelType, online, page, count); return new ResponseEntity<>(pageResult,HttpStatus.OK); } @@ -115,4 +115,33 @@ return new ResponseEntity<String>("璁惧棰勮API璋冪敤澶辫触锛�", HttpStatus.INTERNAL_SERVER_ERROR); } } + + /** + * 鍒嗛〉鏌ヨ閫氶亾鏁� + * @param channelId 閫氶亾id + * @param page 褰撳墠椤� + * @param count 姣忛〉鏉℃暟 + * @return 瀛愰�氶亾鍒楄〃 + */ + @GetMapping("subChannels/{deviceId}/{channelId}/channels") + public ResponseEntity<PageResult> subChannels(@PathVariable String deviceId, + @PathVariable String channelId, + int page, + int count, + @RequestParam(required = false) String query, + @RequestParam(required = false) String online, + @RequestParam(required = false) Boolean channelType){ + + if (logger.isDebugEnabled()) { + logger.debug("鏌ヨ鎵�鏈夎棰戣澶嘇PI璋冪敤"); + } + DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId); + if (deviceChannel == null) { + PageResult<DeviceChannel> deviceChannelPageResult = new PageResult<>(); + new ResponseEntity<>(deviceChannelPageResult,HttpStatus.OK); + } + + PageResult pageResult = storager.querySubChannels(deviceId, channelId, query, channelType, online, page, count); + return new ResponseEntity<>(pageResult,HttpStatus.OK); + } } -- Gitblit v1.8.0