Commit 08c0461a3e889306de71047f19b9ba7049147a6d

Authored by puhui999
1 parent 5a660377

【功能新增】IoT: 获取数据桥梁的精简信息列表

yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/IotDataBridgeController.java
1 package cn.iocoder.yudao.module.iot.controller.admin.rule; 1 package cn.iocoder.yudao.module.iot.controller.admin.rule;
2 2
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
3 import cn.iocoder.yudao.framework.common.pojo.CommonResult; 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -17,7 +18,10 @@ import org.springframework.security.access.prepost.PreAuthorize; @@ -17,7 +18,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
17 import org.springframework.validation.annotation.Validated; 18 import org.springframework.validation.annotation.Validated;
18 import org.springframework.web.bind.annotation.*; 19 import org.springframework.web.bind.annotation.*;
19 20
  21 +import java.util.List;
  22 +
20 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 23 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  24 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
21 25
22 @Tag(name = "管理后台 - IoT 数据桥梁") 26 @Tag(name = "管理后台 - IoT 数据桥梁")
23 @RestController 27 @RestController
@@ -69,4 +73,12 @@ public class IotDataBridgeController { @@ -69,4 +73,12 @@ public class IotDataBridgeController {
69 return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class)); 73 return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class));
70 } 74 }
71 75
72 -}  
73 \ No newline at end of file 76 \ No newline at end of file
  77 + @GetMapping("/simple-list")
  78 + @Operation(summary = "获取数据桥梁的精简信息列表", description = "主要用于前端的下拉选项")
  79 + public CommonResult<List<IotDataBridgeRespVO>> getSimpleDataBridgeList() {
  80 + List<IotDataBridgeDO> list = dataBridgeService.getDataBridgeList(CommonStatusEnum.ENABLE.getStatus());
  81 + return success(convertList(list, dataBridge -> // 只返回 id、name 字段
  82 + new IotDataBridgeRespVO().setId(dataBridge.getId()).setName(dataBridge.getName())));
  83 + }
  84 +
  85 +}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/rule/IotDataBridgeMapper.java
@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBr @@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBr
7 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO; 7 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO;
8 import org.apache.ibatis.annotations.Mapper; 8 import org.apache.ibatis.annotations.Mapper;
9 9
  10 +import java.util.List;
  11 +
10 /** 12 /**
11 * IoT 数据桥梁 Mapper 13 * IoT 数据桥梁 Mapper
12 * 14 *
@@ -23,4 +25,10 @@ public interface IotDataBridgeMapper extends BaseMapperX&lt;IotDataBridgeDO&gt; { @@ -23,4 +25,10 @@ public interface IotDataBridgeMapper extends BaseMapperX&lt;IotDataBridgeDO&gt; {
23 .orderByDesc(IotDataBridgeDO::getId)); 25 .orderByDesc(IotDataBridgeDO::getId));
24 } 26 }
25 27
  28 + default List<IotDataBridgeDO> selectList(Integer status) {
  29 + return selectList(new LambdaQueryWrapperX<IotDataBridgeDO>()
  30 + .eqIfPresent(IotDataBridgeDO::getStatus, status)
  31 + .orderByDesc(IotDataBridgeDO::getId));
  32 + }
  33 +
26 } 34 }
27 \ No newline at end of file 35 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/IotDataBridgeService.java
@@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBr @@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBr
6 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO; 6 import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO;
7 import jakarta.validation.Valid; 7 import jakarta.validation.Valid;
8 8
  9 +import java.util.List;
  10 +
9 /** 11 /**
10 * IoT 数据桥梁 Service 接口 12 * IoT 数据桥梁 Service 接口
11 * 13 *
@@ -51,4 +53,12 @@ public interface IotDataBridgeService { @@ -51,4 +53,12 @@ public interface IotDataBridgeService {
51 */ 53 */
52 PageResult<IotDataBridgeDO> getDataBridgePage(IotDataBridgePageReqVO pageReqVO); 54 PageResult<IotDataBridgeDO> getDataBridgePage(IotDataBridgePageReqVO pageReqVO);
53 55
54 -}  
55 \ No newline at end of file 56 \ No newline at end of file
  57 + /**
  58 + * 获取数据桥梁列表
  59 + *
  60 + * @param status 状态,如果为空,则不进行筛选
  61 + * @return 数据桥梁列表
  62 + */
  63 + List<IotDataBridgeDO> getDataBridgeList(Integer status);
  64 +
  65 +}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/IotDataBridgeServiceImpl.java
@@ -10,6 +10,8 @@ import jakarta.annotation.Resource; @@ -10,6 +10,8 @@ import jakarta.annotation.Resource;
10 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
11 import org.springframework.validation.annotation.Validated; 11 import org.springframework.validation.annotation.Validated;
12 12
  13 +import java.util.List;
  14 +
13 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 15 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
14 import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DATA_BRIDGE_NOT_EXISTS; 16 import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DATA_BRIDGE_NOT_EXISTS;
15 17
@@ -67,4 +69,9 @@ public class IotDataBridgeServiceImpl implements IotDataBridgeService { @@ -67,4 +69,9 @@ public class IotDataBridgeServiceImpl implements IotDataBridgeService {
67 return dataBridgeMapper.selectPage(pageReqVO); 69 return dataBridgeMapper.selectPage(pageReqVO);
68 } 70 }
69 71
70 -}  
71 \ No newline at end of file 72 \ No newline at end of file
  73 + @Override
  74 + public List<IotDataBridgeDO> getDataBridgeList(Integer status) {
  75 + return dataBridgeMapper.selectList(status);
  76 + }
  77 +
  78 +}