Commit ff9267ad759a819ba97cdd19c5264cb47ad23043
1 parent
415dd435
【功能新增】IoT: 数据桥梁 CRUD
Showing
10 changed files
with
334 additions
and
30 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ErrorCodeConstants.java
| ... | ... | @@ -70,4 +70,7 @@ public interface ErrorCodeConstants { |
| 70 | 70 | // ========== MQTT 通信相关 1-050-009-000 ========== |
| 71 | 71 | ErrorCode MQTT_TOPIC_ILLEGAL = new ErrorCode(1_050_009_000, "topic illegal"); |
| 72 | 72 | |
| 73 | + // ========== IoT 数据桥梁 1-050-010-000 ========== | |
| 74 | + ErrorCode DATA_BRIDGE_NOT_EXISTS = new ErrorCode(1_050_010_000, "IoT 数据桥梁不存在"); | |
| 75 | + | |
| 73 | 76 | } |
| 74 | 77 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/IotDataBridgeController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 4 | +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; | |
| 7 | +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.rule.vo.databridge.IotDataBridgePageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeRespVO; | |
| 11 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeSaveReqVO; | |
| 12 | +import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO; | |
| 13 | +import cn.iocoder.yudao.module.iot.service.rule.IotDataBridgeService; | |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.servlet.http.HttpServletResponse; | |
| 19 | +import jakarta.validation.Valid; | |
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 21 | +import org.springframework.validation.annotation.Validated; | |
| 22 | +import org.springframework.web.bind.annotation.*; | |
| 23 | + | |
| 24 | +import java.io.IOException; | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 28 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 29 | + | |
| 30 | +@Tag(name = "管理后台 - IoT 数据桥梁") | |
| 31 | +@RestController | |
| 32 | +@RequestMapping("/iot/data-bridge") | |
| 33 | +@Validated | |
| 34 | +public class IotDataBridgeController { | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private IotDataBridgeService dataBridgeService; | |
| 38 | + | |
| 39 | + @PostMapping("/create") | |
| 40 | + @Operation(summary = "创建IoT 数据桥梁") | |
| 41 | + @PreAuthorize("@ss.hasPermission('iot:data-bridge:create')") | |
| 42 | + public CommonResult<Long> createDataBridge(@Valid @RequestBody IotDataBridgeSaveReqVO createReqVO) { | |
| 43 | + return success(dataBridgeService.createDataBridge(createReqVO)); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @PutMapping("/update") | |
| 47 | + @Operation(summary = "更新IoT 数据桥梁") | |
| 48 | + @PreAuthorize("@ss.hasPermission('iot:data-bridge:update')") | |
| 49 | + public CommonResult<Boolean> updateDataBridge(@Valid @RequestBody IotDataBridgeSaveReqVO updateReqVO) { | |
| 50 | + dataBridgeService.updateDataBridge(updateReqVO); | |
| 51 | + return success(true); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @DeleteMapping("/delete") | |
| 55 | + @Operation(summary = "删除IoT 数据桥梁") | |
| 56 | + @Parameter(name = "id", description = "编号", required = true) | |
| 57 | + @PreAuthorize("@ss.hasPermission('iot:data-bridge:delete')") | |
| 58 | + public CommonResult<Boolean> deleteDataBridge(@RequestParam("id") Long id) { | |
| 59 | + dataBridgeService.deleteDataBridge(id); | |
| 60 | + return success(true); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @GetMapping("/get") | |
| 64 | + @Operation(summary = "获得IoT 数据桥梁") | |
| 65 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 66 | + @PreAuthorize("@ss.hasPermission('iot:data-bridge:query')") | |
| 67 | + public CommonResult<IotDataBridgeRespVO> getDataBridge(@RequestParam("id") Long id) { | |
| 68 | + IotDataBridgeDO dataBridge = dataBridgeService.getDataBridge(id); | |
| 69 | + return success(BeanUtils.toBean(dataBridge, IotDataBridgeRespVO.class)); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @GetMapping("/page") | |
| 73 | + @Operation(summary = "获得IoT 数据桥梁分页") | |
| 74 | + @PreAuthorize("@ss.hasPermission('iot:data-bridge:query')") | |
| 75 | + public CommonResult<PageResult<IotDataBridgeRespVO>> getDataBridgePage(@Valid IotDataBridgePageReqVO pageReqVO) { | |
| 76 | + PageResult<IotDataBridgeDO> pageResult = dataBridgeService.getDataBridgePage(pageReqVO); | |
| 77 | + return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @GetMapping("/export-excel") | |
| 81 | + @Operation(summary = "导出IoT 数据桥梁 Excel") | |
| 82 | + @PreAuthorize("@ss.hasPermission('iot:data-bridge:export')") | |
| 83 | + @ApiAccessLog(operateType = EXPORT) | |
| 84 | + public void exportDataBridgeExcel(@Valid IotDataBridgePageReqVO pageReqVO, | |
| 85 | + HttpServletResponse response) throws IOException { | |
| 86 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 87 | + List<IotDataBridgeDO> list = dataBridgeService.getDataBridgePage(pageReqVO).getList(); | |
| 88 | + // 导出 Excel | |
| 89 | + ExcelUtils.write(response, "IoT 数据桥梁.xls", "数据", IotDataBridgeRespVO.class, | |
| 90 | + BeanUtils.toBean(list, IotDataBridgeRespVO.class)); | |
| 91 | + } | |
| 92 | + | |
| 93 | +} | |
| 0 | 94 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/databridge/IotDataBridgePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - IoT 数据桥梁分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class IotDataBridgePageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "桥梁名称", example = "赵六") | |
| 21 | + private String name; | |
| 22 | + | |
| 23 | + @Schema(description = "桥梁描述", example = "随便") | |
| 24 | + private String description; | |
| 25 | + | |
| 26 | + @Schema(description = "桥梁状态", example = "2") | |
| 27 | + private Integer status; | |
| 28 | + | |
| 29 | + @Schema(description = "桥梁方向") | |
| 30 | + private Integer direction; | |
| 31 | + | |
| 32 | + @Schema(description = "桥梁类型", example = "1") | |
| 33 | + private Integer type; | |
| 34 | + | |
| 35 | + @Schema(description = "创建时间") | |
| 36 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 37 | + private LocalDateTime[] createTime; | |
| 38 | + | |
| 39 | +} | |
| 0 | 40 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/databridge/IotDataBridgeRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 6 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 7 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 8 | +import lombok.Data; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +@Schema(description = "管理后台 - IoT 数据桥梁 Response VO") | |
| 13 | +@Data | |
| 14 | +@ExcelIgnoreUnannotated | |
| 15 | +public class IotDataBridgeRespVO { | |
| 16 | + | |
| 17 | + @Schema(description = "桥梁编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18564") | |
| 18 | + @ExcelProperty("桥梁编号") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + @Schema(description = "桥梁名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | |
| 22 | + @ExcelProperty("桥梁名称") | |
| 23 | + private String name; | |
| 24 | + | |
| 25 | + @Schema(description = "桥梁描述", example = "随便") | |
| 26 | + @ExcelProperty("桥梁描述") | |
| 27 | + private String description; | |
| 28 | + | |
| 29 | + @Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 30 | + @ExcelProperty(value = "桥梁状态", converter = DictConvert.class) | |
| 31 | + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 | |
| 32 | + private Integer status; | |
| 33 | + | |
| 34 | + @Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 35 | + @ExcelProperty(value = "桥梁方向", converter = DictConvert.class) | |
| 36 | + @DictFormat("iot_data_bridg_direction_enum") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 | |
| 37 | + private Integer direction; | |
| 38 | + | |
| 39 | + @Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 40 | + @ExcelProperty(value = "桥梁类型", converter = DictConvert.class) | |
| 41 | + @DictFormat("iot_data_bridg_type_enum") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 | |
| 42 | + private Integer type; | |
| 43 | + | |
| 44 | + @Schema(description = "桥梁配置") | |
| 45 | + @ExcelProperty("桥梁配置") | |
| 46 | + private String config; | |
| 47 | + | |
| 48 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 49 | + @ExcelProperty("创建时间") | |
| 50 | + private LocalDateTime createTime; | |
| 51 | + | |
| 52 | +} | |
| 0 | 53 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/databridge/IotDataBridgeSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.NotEmpty; | |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - IoT 数据桥梁新增/修改 Request VO") | |
| 9 | +@Data | |
| 10 | +public class IotDataBridgeSaveReqVO { | |
| 11 | + | |
| 12 | + @Schema(description = "桥梁编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18564") | |
| 13 | + private Long id; | |
| 14 | + | |
| 15 | + @Schema(description = "桥梁名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | |
| 16 | + @NotEmpty(message = "桥梁名称不能为空") | |
| 17 | + private String name; | |
| 18 | + | |
| 19 | + @Schema(description = "桥梁描述", example = "随便") | |
| 20 | + private String description; | |
| 21 | + | |
| 22 | + @Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 23 | + @NotNull(message = "桥梁状态不能为空") | |
| 24 | + private Integer status; | |
| 25 | + | |
| 26 | + @Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 27 | + @NotNull(message = "桥梁方向不能为空") | |
| 28 | + private Integer direction; | |
| 29 | + | |
| 30 | + @Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 31 | + @NotNull(message = "桥梁类型不能为空") | |
| 32 | + private Integer type; | |
| 33 | + | |
| 34 | + @Schema(description = "桥梁配置") | |
| 35 | + private String config; | |
| 36 | + | |
| 37 | +} | |
| 0 | 38 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/rule/vo/package-info.java
0 → 100644
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/rule/IotDataBridgeMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.dal.mysql.rule; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 3 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgePageReqVO; | |
| 4 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO; |
| 5 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 9 | |
| 10 | +/** | |
| 11 | + * IoT 数据桥梁 Mapper | |
| 12 | + * | |
| 13 | + * @author HUIHUI | |
| 14 | + */ | |
| 7 | 15 | @Mapper |
| 8 | 16 | public interface IotDataBridgeMapper extends BaseMapperX<IotDataBridgeDO> { |
| 9 | -} | |
| 17 | + | |
| 18 | + default PageResult<IotDataBridgeDO> selectPage(IotDataBridgePageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<IotDataBridgeDO>() | |
| 20 | + .likeIfPresent(IotDataBridgeDO::getName, reqVO.getName()) | |
| 21 | + .likeIfPresent(IotDataBridgeDO::getDescription, reqVO.getDescription()) | |
| 22 | + .eqIfPresent(IotDataBridgeDO::getStatus, reqVO.getStatus()) | |
| 23 | + .eqIfPresent(IotDataBridgeDO::getDirection, reqVO.getDirection()) | |
| 24 | + .eqIfPresent(IotDataBridgeDO::getType, reqVO.getType()) | |
| 25 | + .betweenIfPresent(IotDataBridgeDO::getCreateTime, reqVO.getCreateTime()) | |
| 26 | + .orderByDesc(IotDataBridgeDO::getId)); | |
| 27 | + } | |
| 28 | + | |
| 29 | +} | |
| 10 | 30 | \ 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
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.rule; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgePageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeSaveReqVO; | |
| 3 | 6 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO; |
| 7 | +import jakarta.validation.Valid; | |
| 4 | 8 | |
| 5 | 9 | /** |
| 6 | - * IoT 数据桥梁的 Service 接口 | |
| 10 | + * IoT 数据桥梁 Service 接口 | |
| 7 | 11 | * |
| 8 | - * @author 芋道源码 | |
| 12 | + * @author HUIHUI | |
| 9 | 13 | */ |
| 10 | 14 | public interface IotDataBridgeService { |
| 11 | 15 | |
| 12 | 16 | /** |
| 13 | - * 获得指定数据桥梁 | |
| 17 | + * 创建IoT 数据桥梁 | |
| 14 | 18 | * |
| 15 | - * @param id 数据桥梁编号 | |
| 16 | - * @return 数据桥梁 | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 17 | 21 | */ |
| 18 | - IotDataBridgeDO getIotDataBridge(Long id); | |
| 22 | + Long createDataBridge(@Valid IotDataBridgeSaveReqVO createReqVO); | |
| 19 | 23 | |
| 20 | -} | |
| 24 | + /** | |
| 25 | + * 更新IoT 数据桥梁 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateDataBridge(@Valid IotDataBridgeSaveReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除IoT 数据桥梁 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteDataBridge(Long id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得IoT 数据桥梁 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return IoT 数据桥梁 | |
| 43 | + */ | |
| 44 | + IotDataBridgeDO getDataBridge(Long id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得IoT 数据桥梁分页 | |
| 48 | + * | |
| 49 | + * @param pageReqVO 分页查询 | |
| 50 | + * @return IoT 数据桥梁分页 | |
| 51 | + */ | |
| 52 | + PageResult<IotDataBridgeDO> getDataBridgePage(IotDataBridgePageReqVO pageReqVO); | |
| 53 | + | |
| 54 | +} | |
| 21 | 55 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/IotDataBridgeServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.rule; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.map.MapUtil; | |
| 4 | -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeSaveReqVO; | |
| 5 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO; |
| 6 | 8 | import cn.iocoder.yudao.module.iot.dal.mysql.rule.IotDataBridgeMapper; |
| 7 | -import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgTypeEnum; | |
| 8 | 9 | import jakarta.annotation.Resource; |
| 9 | -import lombok.extern.slf4j.Slf4j; | |
| 10 | 10 | import org.springframework.stereotype.Service; |
| 11 | 11 | import org.springframework.validation.annotation.Validated; |
| 12 | 12 | |
| 13 | -import java.util.Objects; | |
| 13 | +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; | |
| 14 | 15 | |
| 15 | 16 | /** |
| 16 | - * IoT 数据桥梁的 Service 实现类 | |
| 17 | + * IoT 数据桥梁 Service 实现类 | |
| 17 | 18 | * |
| 18 | - * @author 芋道源码 | |
| 19 | + * @author HUIHUI | |
| 19 | 20 | */ |
| 20 | 21 | @Service |
| 21 | 22 | @Validated |
| 22 | -@Slf4j | |
| 23 | 23 | public class IotDataBridgeServiceImpl implements IotDataBridgeService { |
| 24 | 24 | |
| 25 | 25 | @Resource |
| 26 | 26 | private IotDataBridgeMapper dataBridgeMapper; |
| 27 | 27 | |
| 28 | - // TODO @芋艿:临时测试 | |
| 29 | 28 | @Override |
| 30 | - public IotDataBridgeDO getIotDataBridge(Long id) { | |
| 31 | - if (Objects.equals(id, 1L)) { | |
| 32 | - IotDataBridgeDO.HttpConfig config = new IotDataBridgeDO.HttpConfig() | |
| 33 | - .setUrl("http://127.0.0.1:48080/test") | |
| 34 | -// .setMethod("POST") | |
| 35 | - .setMethod("GET") | |
| 36 | - .setQuery(MapUtil.of("aaa", "bbb")) | |
| 37 | - .setHeaders(MapUtil.of("ccc", "ddd")) | |
| 38 | - .setBody(JsonUtils.toJsonString(MapUtil.of("eee", "fff"))); | |
| 39 | - return IotDataBridgeDO.builder().id(1L).name("芋道").description("芋道源码").status(0).direction(1) | |
| 40 | - .type(IotDataBridgTypeEnum.HTTP.getType()).config(config).build(); | |
| 29 | + public Long createDataBridge(IotDataBridgeSaveReqVO createReqVO) { | |
| 30 | + // 插入 | |
| 31 | + IotDataBridgeDO dataBridge = BeanUtils.toBean(createReqVO, IotDataBridgeDO.class); | |
| 32 | + dataBridgeMapper.insert(dataBridge); | |
| 33 | + // 返回 | |
| 34 | + return dataBridge.getId(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void updateDataBridge(IotDataBridgeSaveReqVO updateReqVO) { | |
| 39 | + // 校验存在 | |
| 40 | + validateDataBridgeExists(updateReqVO.getId()); | |
| 41 | + // 更新 | |
| 42 | + IotDataBridgeDO updateObj = BeanUtils.toBean(updateReqVO, IotDataBridgeDO.class); | |
| 43 | + dataBridgeMapper.updateById(updateObj); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public void deleteDataBridge(Long id) { | |
| 48 | + // 校验存在 | |
| 49 | + validateDataBridgeExists(id); | |
| 50 | + // 删除 | |
| 51 | + dataBridgeMapper.deleteById(id); | |
| 52 | + } | |
| 53 | + | |
| 54 | + private void validateDataBridgeExists(Long id) { | |
| 55 | + if (dataBridgeMapper.selectById(id) == null) { | |
| 56 | + throw exception(DATA_BRIDGE_NOT_EXISTS); | |
| 41 | 57 | } |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public IotDataBridgeDO getDataBridge(Long id) { | |
| 42 | 62 | return dataBridgeMapper.selectById(id); |
| 43 | 63 | } |
| 44 | 64 | |
| 45 | -} | |
| 65 | + @Override | |
| 66 | + public PageResult<IotDataBridgeDO> getDataBridgePage(IotDataBridgePageReqVO pageReqVO) { | |
| 67 | + return dataBridgeMapper.selectPage(pageReqVO); | |
| 68 | + } | |
| 69 | + | |
| 70 | +} | |
| 46 | 71 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/action/IotRuleSceneDataBridgeAction.java
| ... | ... | @@ -36,7 +36,7 @@ public class IotRuleSceneDataBridgeAction implements IotRuleSceneAction { |
| 36 | 36 | } |
| 37 | 37 | // 1.2 获得数据桥梁 |
| 38 | 38 | Assert.notNull(config.getDataBridgeId(), "数据桥梁编号不能为空"); |
| 39 | - IotDataBridgeDO dataBridge = dataBridgeService.getIotDataBridge(config.getDataBridgeId()); | |
| 39 | + IotDataBridgeDO dataBridge = dataBridgeService.getDataBridge(config.getDataBridgeId()); | |
| 40 | 40 | if (dataBridge == null || dataBridge.getConfig() == null) { |
| 41 | 41 | log.error("[execute][message({}) config({}) 对应的数据桥梁不存在]", message, config); |
| 42 | 42 | return; | ... | ... |