Răsfoiți Sursa

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

安浩浩 10 luni în urmă
părinte
comite
1719b69ef7

+ 8 - 8
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java

@@ -1,11 +1,8 @@
 package cn.iocoder.yudao.module.iot.controller.admin.device;
 
-import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDevicePageReqVO;
 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceRespVO;
 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceSaveReqVO;
@@ -16,16 +13,11 @@ import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.annotation.Resource;
-import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.Valid;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.io.IOException;
-import java.util.List;
-
-import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
 @Tag(name = "管理后台 - IoT 设备")
@@ -86,4 +78,12 @@ public class IotDeviceController {
         return success(BeanUtils.toBean(pageResult, IotDeviceRespVO.class));
     }
 
+    @GetMapping("/count")
+    @Operation(summary = "获得设备数量")
+    @Parameter(name = "productId", description = "产品编号", example = "1")
+    @PreAuthorize("@ss.hasPermission('iot:device:query')")
+    public CommonResult<Long> getDeviceCount(@RequestParam("productId") Long productId) {
+        return success(deviceService.getDeviceCount(productId));
+    }
+
 }

+ 3 - 0
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<IotDeviceDO> {
         return selectCount(IotDeviceDO::getGatewayId, id);
     }
 
+    default Long selectCountByProductId(Long productId) {
+        return selectCount(IotDeviceDO::getProductId, productId);
+    }
 }

+ 5 - 0
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 {
         deviceMapper.updateById(updateObj);
     }
 
+    @Override
+    public Long getDeviceCount(Long productId) {
+        return deviceMapper.selectCountByProductId(productId);
+    }
+
 }

+ 7 - 0
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 {
      */
     void updateDeviceStatus(IotDeviceStatusUpdateReqVO updateReqVO);
 
+    /**
+     * 获得设备数量
+     *
+     * @param productId 产品编号
+     * @return 设备数量
+     */
+    Long getDeviceCount(Long productId);
 }