Commit 1719b69ef7366f12ebbe7f4443957fc3f27326f0

Authored by 安浩浩
1 parent 643e2893

【新增】IOT 设备管理,获得设备数量接口

yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java
1 package cn.iocoder.yudao.module.iot.controller.admin.device; 1 package cn.iocoder.yudao.module.iot.controller.admin.device;
2 2
3 -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;  
4 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 -import cn.iocoder.yudao.framework.common.pojo.PageParam;  
6 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
8 -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;  
9 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDevicePageReqVO; 6 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDevicePageReqVO;
10 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceRespVO; 7 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceRespVO;
11 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceSaveReqVO; 8 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceSaveReqVO;
@@ -16,16 +13,11 @@ import io.swagger.v3.oas.annotations.Operation; @@ -16,16 +13,11 @@ import io.swagger.v3.oas.annotations.Operation;
16 import io.swagger.v3.oas.annotations.Parameter; 13 import io.swagger.v3.oas.annotations.Parameter;
17 import io.swagger.v3.oas.annotations.tags.Tag; 14 import io.swagger.v3.oas.annotations.tags.Tag;
18 import jakarta.annotation.Resource; 15 import jakarta.annotation.Resource;
19 -import jakarta.servlet.http.HttpServletResponse;  
20 import jakarta.validation.Valid; 16 import jakarta.validation.Valid;
21 import org.springframework.security.access.prepost.PreAuthorize; 17 import org.springframework.security.access.prepost.PreAuthorize;
22 import org.springframework.validation.annotation.Validated; 18 import org.springframework.validation.annotation.Validated;
23 import org.springframework.web.bind.annotation.*; 19 import org.springframework.web.bind.annotation.*;
24 20
25 -import java.io.IOException;  
26 -import java.util.List;  
27 -  
28 -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;  
29 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 21 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
30 22
31 @Tag(name = "管理后台 - IoT 设备") 23 @Tag(name = "管理后台 - IoT 设备")
@@ -86,4 +78,12 @@ public class IotDeviceController { @@ -86,4 +78,12 @@ public class IotDeviceController {
86 return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class)); 78 return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class));
87 } 79 }
88 80
  81 + @GetMapping("/count")
  82 + @Operation(summary = "获得设备数量")
  83 + @Parameter(name = "productId", description = "产品编号", example = "1")
  84 + @PreAuthorize("@ss.hasPermission('iot:device:query')")
  85 + public CommonResult<Long> getDeviceCount(@RequestParam("productId") Long productId) {
  86 + return success(deviceService.getDeviceCount(productId));
  87 + }
  88 +
89 } 89 }
90 \ No newline at end of file 90 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/device/IotDeviceMapper.java
@@ -47,4 +47,7 @@ public interface IotDeviceMapper extends BaseMapperX&lt;IotDeviceDO&gt; { @@ -47,4 +47,7 @@ public interface IotDeviceMapper extends BaseMapperX&lt;IotDeviceDO&gt; {
47 return selectCount(IotDeviceDO::getGatewayId, id); 47 return selectCount(IotDeviceDO::getGatewayId, id);
48 } 48 }
49 49
  50 + default Long selectCountByProductId(Long productId) {
  51 + return selectCount(IotDeviceDO::getProductId, productId);
  52 + }
50 } 53 }
51 \ No newline at end of file 54 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/DeviceServiceImpl.java
@@ -224,4 +224,9 @@ public class DeviceServiceImpl implements IotDeviceService { @@ -224,4 +224,9 @@ public class DeviceServiceImpl implements IotDeviceService {
224 deviceMapper.updateById(updateObj); 224 deviceMapper.updateById(updateObj);
225 } 225 }
226 226
  227 + @Override
  228 + public Long getDeviceCount(Long productId) {
  229 + return deviceMapper.selectCountByProductId(productId);
  230 + }
  231 +
227 } 232 }
228 \ No newline at end of file 233 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceService.java
@@ -57,4 +57,11 @@ public interface IotDeviceService { @@ -57,4 +57,11 @@ public interface IotDeviceService {
57 */ 57 */
58 void updateDeviceStatus(IotDeviceStatusUpdateReqVO updateReqVO); 58 void updateDeviceStatus(IotDeviceStatusUpdateReqVO updateReqVO);
59 59
  60 + /**
  61 + * 获得设备数量
  62 + *
  63 + * @param productId 产品编号
  64 + * @return 设备数量
  65 + */
  66 + Long getDeviceCount(Long productId);
60 } 67 }
61 \ No newline at end of file 68 \ No newline at end of file