Commit 1719b69ef7366f12ebbe7f4443957fc3f27326f0
1 parent
643e2893
【新增】IOT 设备管理,获得设备数量接口
Showing
4 changed files
with
23 additions
and
8 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/IotDeviceController.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.device; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 9 | 6 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDevicePageReqVO; |
| 10 | 7 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceRespVO; |
| 11 | 8 | import cn.iocoder.yudao.module.iot.controller.admin.device.vo.IotDeviceSaveReqVO; |
| ... | ... | @@ -16,16 +13,11 @@ import io.swagger.v3.oas.annotations.Operation; |
| 16 | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 17 | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 18 | 15 | import jakarta.annotation.Resource; |
| 19 | -import jakarta.servlet.http.HttpServletResponse; | |
| 20 | 16 | import jakarta.validation.Valid; |
| 21 | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 22 | 18 | import org.springframework.validation.annotation.Validated; |
| 23 | 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 | 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 30 | 22 | |
| 31 | 23 | @Tag(name = "管理后台 - IoT 设备") |
| ... | ... | @@ -86,4 +78,12 @@ public class IotDeviceController { |
| 86 | 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 | 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<IotDeviceDO> { |
| 47 | 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 | 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 | 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 | 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 | 57 | */ |
| 58 | 58 | void updateDeviceStatus(IotDeviceStatusUpdateReqVO updateReqVO); |
| 59 | 59 | |
| 60 | + /** | |
| 61 | + * 获得设备数量 | |
| 62 | + * | |
| 63 | + * @param productId 产品编号 | |
| 64 | + * @return 设备数量 | |
| 65 | + */ | |
| 66 | + Long getDeviceCount(Long productId); | |
| 60 | 67 | } |
| 61 | 68 | \ No newline at end of file | ... | ... |