Commit 3756830b9c672f2a035b6aa0a29f2a8b1fbb6cac
1 parent
966357b4
【代码优化】IoT: 数据桥梁代码优化
Showing
5 changed files
with
9 additions
and
53 deletions
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.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.rule.vo.databridge.IotDataBridgePageReqVO; | 6 | 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; | 7 | 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; | 8 | import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeSaveReqVO; |
| @@ -15,16 +12,11 @@ import io.swagger.v3.oas.annotations.Operation; | @@ -15,16 +12,11 @@ import io.swagger.v3.oas.annotations.Operation; | ||
| 15 | import io.swagger.v3.oas.annotations.Parameter; | 12 | import io.swagger.v3.oas.annotations.Parameter; |
| 16 | import io.swagger.v3.oas.annotations.tags.Tag; | 13 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | import jakarta.annotation.Resource; | 14 | import jakarta.annotation.Resource; |
| 18 | -import jakarta.servlet.http.HttpServletResponse; | ||
| 19 | import jakarta.validation.Valid; | 15 | import jakarta.validation.Valid; |
| 20 | import org.springframework.security.access.prepost.PreAuthorize; | 16 | import org.springframework.security.access.prepost.PreAuthorize; |
| 21 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 22 | import org.springframework.web.bind.annotation.*; | 18 | import org.springframework.web.bind.annotation.*; |
| 23 | 19 | ||
| 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; | 20 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 29 | 21 | ||
| 30 | @Tag(name = "管理后台 - IoT 数据桥梁") | 22 | @Tag(name = "管理后台 - IoT 数据桥梁") |
| @@ -77,18 +69,4 @@ public class IotDataBridgeController { | @@ -77,18 +69,4 @@ public class IotDataBridgeController { | ||
| 77 | return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class)); | 69 | return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class)); |
| 78 | } | 70 | } |
| 79 | 71 | ||
| 80 | - // TODO @puhui999:不用导出哈。相关的 IotDataBridgeRespVO 里的导出也注释掉哈 | ||
| 81 | - @GetMapping("/export-excel") | ||
| 82 | - @Operation(summary = "导出数据桥梁 Excel") | ||
| 83 | - @PreAuthorize("@ss.hasPermission('iot:data-bridge:export')") | ||
| 84 | - @ApiAccessLog(operateType = EXPORT) | ||
| 85 | - public void exportDataBridgeExcel(@Valid IotDataBridgePageReqVO pageReqVO, | ||
| 86 | - HttpServletResponse response) throws IOException { | ||
| 87 | - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 88 | - List<IotDataBridgeDO> list = dataBridgeService.getDataBridgePage(pageReqVO).getList(); | ||
| 89 | - // 导出 Excel | ||
| 90 | - ExcelUtils.write(response, "IoT 数据桥梁.xls", "数据", IotDataBridgeRespVO.class, | ||
| 91 | - BeanUtils.toBean(list, IotDataBridgeRespVO.class)); | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | } | 72 | } |
| 95 | \ No newline at end of file | 73 | \ 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
| @@ -20,22 +20,11 @@ public class IotDataBridgePageReqVO extends PageParam { | @@ -20,22 +20,11 @@ public class IotDataBridgePageReqVO extends PageParam { | ||
| 20 | @Schema(description = "桥梁名称", example = "赵六") | 20 | @Schema(description = "桥梁名称", example = "赵六") |
| 21 | private String name; | 21 | private String name; |
| 22 | 22 | ||
| 23 | - // TODO @puhui999:description、direction、type 不过滤哈 | ||
| 24 | - @Schema(description = "桥梁描述", example = "随便") | ||
| 25 | - private String description; | ||
| 26 | - | ||
| 27 | @Schema(description = "桥梁状态", example = "2") | 23 | @Schema(description = "桥梁状态", example = "2") |
| 28 | private Integer status; | 24 | private Integer status; |
| 29 | 25 | ||
| 30 | - @Schema(description = "桥梁方向") | ||
| 31 | - private Integer direction; | ||
| 32 | - | ||
| 33 | - @Schema(description = "桥梁类型", example = "1") | ||
| 34 | - private Integer type; | ||
| 35 | - | ||
| 36 | @Schema(description = "创建时间") | 26 | @Schema(description = "创建时间") |
| 37 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 27 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 38 | private LocalDateTime[] createTime; | 28 | private LocalDateTime[] createTime; |
| 39 | 29 | ||
| 40 | - | ||
| 41 | } | 30 | } |
| 42 | \ No newline at end of file | 31 | \ 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
| 1 | package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge; | 1 | package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | ||
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | ||
| 5 | import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig; | 3 | import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig; |
| 6 | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | 4 | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| 7 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 8 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | import lombok.Data; | 6 | import lombok.Data; |
| 10 | 7 | ||
| 11 | import java.time.LocalDateTime; | 8 | import java.time.LocalDateTime; |
| 12 | 9 | ||
| 13 | -import static cn.iocoder.yudao.module.iot.enums.DictTypeConstants.IOT_DATA_BRIDGE_DIRECTION_ENUM; | ||
| 14 | -import static cn.iocoder.yudao.module.iot.enums.DictTypeConstants.IOT_DATA_BRIDGE_TYPE_ENUM; | ||
| 15 | -import static cn.iocoder.yudao.module.system.enums.DictTypeConstants.COMMON_STATUS; | ||
| 16 | - | ||
| 17 | @Schema(description = "管理后台 - IoT 数据桥梁 Response VO") | 10 | @Schema(description = "管理后台 - IoT 数据桥梁 Response VO") |
| 18 | @Data | 11 | @Data |
| 19 | @ExcelIgnoreUnannotated | 12 | @ExcelIgnoreUnannotated |
| 20 | public class IotDataBridgeRespVO { | 13 | public class IotDataBridgeRespVO { |
| 21 | 14 | ||
| 22 | @Schema(description = "桥梁编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18564") | 15 | @Schema(description = "桥梁编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18564") |
| 23 | - @ExcelProperty("桥梁编号") | ||
| 24 | private Long id; | 16 | private Long id; |
| 25 | 17 | ||
| 26 | @Schema(description = "桥梁名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | 18 | @Schema(description = "桥梁名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") |
| 27 | - @ExcelProperty("桥梁名称") | ||
| 28 | private String name; | 19 | private String name; |
| 29 | 20 | ||
| 30 | @Schema(description = "桥梁描述", example = "随便") | 21 | @Schema(description = "桥梁描述", example = "随便") |
| 31 | - @ExcelProperty("桥梁描述") | ||
| 32 | private String description; | 22 | private String description; |
| 33 | 23 | ||
| 34 | @Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 24 | @Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 35 | - @ExcelProperty(value = "桥梁状态", converter = DictConvert.class) | ||
| 36 | - @DictFormat(COMMON_STATUS) | ||
| 37 | private Integer status; | 25 | private Integer status; |
| 38 | 26 | ||
| 39 | @Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED) | 27 | @Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED) |
| 40 | - @ExcelProperty(value = "桥梁方向", converter = DictConvert.class) | ||
| 41 | - @DictFormat(IOT_DATA_BRIDGE_DIRECTION_ENUM) | ||
| 42 | private Integer direction; | 28 | private Integer direction; |
| 43 | 29 | ||
| 44 | @Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | 30 | @Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 45 | - @ExcelProperty(value = "桥梁类型", converter = DictConvert.class) | ||
| 46 | - @DictFormat(IOT_DATA_BRIDGE_TYPE_ENUM) | ||
| 47 | private Integer type; | 31 | private Integer type; |
| 48 | 32 | ||
| 49 | @Schema(description = "桥梁配置") | 33 | @Schema(description = "桥梁配置") |
| 50 | - @ExcelProperty("桥梁配置") | ||
| 51 | private IotDataBridgeAbstractConfig config; | 34 | private IotDataBridgeAbstractConfig config; |
| 52 | 35 | ||
| 53 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 36 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 54 | - @ExcelProperty("创建时间") | ||
| 55 | private LocalDateTime createTime; | 37 | private LocalDateTime createTime; |
| 56 | 38 | ||
| 57 | } | 39 | } |
| 58 | \ No newline at end of file | 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/IotDataBridgeSaveReqVO.java
| 1 | package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge; | 1 | package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 3 | import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig; | 5 | import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig; |
| 6 | +import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeDirectionEnum; | ||
| 7 | +import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeTypeEnum; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import jakarta.validation.constraints.NotEmpty; | 9 | import jakarta.validation.constraints.NotEmpty; |
| 6 | import jakarta.validation.constraints.NotNull; | 10 | import jakarta.validation.constraints.NotNull; |
| @@ -22,15 +26,17 @@ public class IotDataBridgeSaveReqVO { | @@ -22,15 +26,17 @@ public class IotDataBridgeSaveReqVO { | ||
| 22 | 26 | ||
| 23 | @Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | 27 | @Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 24 | @NotNull(message = "桥梁状态不能为空") | 28 | @NotNull(message = "桥梁状态不能为空") |
| 29 | + @InEnum(CommonStatusEnum.class) | ||
| 25 | private Integer status; | 30 | private Integer status; |
| 26 | 31 | ||
| 27 | - // TODO @puhui999:枚举的校验 | ||
| 28 | @Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED) | 32 | @Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED) |
| 29 | @NotNull(message = "桥梁方向不能为空") | 33 | @NotNull(message = "桥梁方向不能为空") |
| 34 | + @InEnum(IotDataBridgeDirectionEnum.class) | ||
| 30 | private Integer direction; | 35 | private Integer direction; |
| 31 | 36 | ||
| 32 | @Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | 37 | @Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 33 | @NotNull(message = "桥梁类型不能为空") | 38 | @NotNull(message = "桥梁类型不能为空") |
| 39 | + @InEnum(IotDataBridgeTypeEnum.class) | ||
| 34 | private Integer type; | 40 | private Integer type; |
| 35 | 41 | ||
| 36 | @Schema(description = "桥梁配置") | 42 | @Schema(description = "桥梁配置") |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/rule/IotDataBridgeDO.java
| 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.rule; | 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.rule; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig; | 5 | import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig; |
| 5 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeDirectionEnum; | 6 | import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeDirectionEnum; |
| @@ -42,7 +43,7 @@ public class IotDataBridgeDO extends BaseDO { | @@ -42,7 +43,7 @@ public class IotDataBridgeDO extends BaseDO { | ||
| 42 | /** | 43 | /** |
| 43 | * 桥梁状态 | 44 | * 桥梁状态 |
| 44 | * | 45 | * |
| 45 | - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | 46 | + * 枚举 {@link CommonStatusEnum} |
| 46 | */ | 47 | */ |
| 47 | private Integer status; | 48 | private Integer status; |
| 48 | /** | 49 | /** |