【代码优化】IoT: 数据桥梁代码优化
This commit is contained in:
parent
966357b44e
commit
3756830b9c
|
@ -1,11 +1,8 @@
|
||||||
package cn.iocoder.yudao.module.iot.controller.admin.rule;
|
package cn.iocoder.yudao.module.iot.controller.admin.rule;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
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.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
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.rule.vo.databridge.IotDataBridgePageReqVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgePageReqVO;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeRespVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeRespVO;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeSaveReqVO;
|
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBridgeSaveReqVO;
|
||||||
|
@ -15,16 +12,11 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
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;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - IoT 数据桥梁")
|
@Tag(name = "管理后台 - IoT 数据桥梁")
|
||||||
|
@ -77,18 +69,4 @@ public class IotDataBridgeController {
|
||||||
return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class));
|
return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999:不用导出哈。相关的 IotDataBridgeRespVO 里的导出也注释掉哈
|
|
||||||
@GetMapping("/export-excel")
|
|
||||||
@Operation(summary = "导出数据桥梁 Excel")
|
|
||||||
@PreAuthorize("@ss.hasPermission('iot:data-bridge:export')")
|
|
||||||
@ApiAccessLog(operateType = EXPORT)
|
|
||||||
public void exportDataBridgeExcel(@Valid IotDataBridgePageReqVO pageReqVO,
|
|
||||||
HttpServletResponse response) throws IOException {
|
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
||||||
List<IotDataBridgeDO> list = dataBridgeService.getDataBridgePage(pageReqVO).getList();
|
|
||||||
// 导出 Excel
|
|
||||||
ExcelUtils.write(response, "IoT 数据桥梁.xls", "数据", IotDataBridgeRespVO.class,
|
|
||||||
BeanUtils.toBean(list, IotDataBridgeRespVO.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,22 +20,11 @@ public class IotDataBridgePageReqVO extends PageParam {
|
||||||
@Schema(description = "桥梁名称", example = "赵六")
|
@Schema(description = "桥梁名称", example = "赵六")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
// TODO @puhui999:description、direction、type 不过滤哈
|
|
||||||
@Schema(description = "桥梁描述", example = "随便")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@Schema(description = "桥梁状态", example = "2")
|
@Schema(description = "桥梁状态", example = "2")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "桥梁方向")
|
|
||||||
private Integer direction;
|
|
||||||
|
|
||||||
@Schema(description = "桥梁类型", example = "1")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间")
|
@Schema(description = "创建时间")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime[] createTime;
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,57 +1,39 @@
|
||||||
package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge;
|
package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig;
|
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig;
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.iot.enums.DictTypeConstants.IOT_DATA_BRIDGE_DIRECTION_ENUM;
|
|
||||||
import static cn.iocoder.yudao.module.iot.enums.DictTypeConstants.IOT_DATA_BRIDGE_TYPE_ENUM;
|
|
||||||
import static cn.iocoder.yudao.module.system.enums.DictTypeConstants.COMMON_STATUS;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - IoT 数据桥梁 Response VO")
|
@Schema(description = "管理后台 - IoT 数据桥梁 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
@ExcelIgnoreUnannotated
|
||||||
public class IotDataBridgeRespVO {
|
public class IotDataBridgeRespVO {
|
||||||
|
|
||||||
@Schema(description = "桥梁编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18564")
|
@Schema(description = "桥梁编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18564")
|
||||||
@ExcelProperty("桥梁编号")
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "桥梁名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
@Schema(description = "桥梁名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||||
@ExcelProperty("桥梁名称")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "桥梁描述", example = "随便")
|
@Schema(description = "桥梁描述", example = "随便")
|
||||||
@ExcelProperty("桥梁描述")
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
@Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
@ExcelProperty(value = "桥梁状态", converter = DictConvert.class)
|
|
||||||
@DictFormat(COMMON_STATUS)
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty(value = "桥梁方向", converter = DictConvert.class)
|
|
||||||
@DictFormat(IOT_DATA_BRIDGE_DIRECTION_ENUM)
|
|
||||||
private Integer direction;
|
private Integer direction;
|
||||||
|
|
||||||
@Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@ExcelProperty(value = "桥梁类型", converter = DictConvert.class)
|
|
||||||
@DictFormat(IOT_DATA_BRIDGE_TYPE_ENUM)
|
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@Schema(description = "桥梁配置")
|
@Schema(description = "桥梁配置")
|
||||||
@ExcelProperty("桥梁配置")
|
|
||||||
private IotDataBridgeAbstractConfig config;
|
private IotDataBridgeAbstractConfig config;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge;
|
package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig;
|
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig;
|
||||||
|
import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeDirectionEnum;
|
||||||
|
import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeTypeEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
@ -22,15 +26,17 @@ public class IotDataBridgeSaveReqVO {
|
||||||
|
|
||||||
@Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
@Schema(description = "桥梁状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
@NotNull(message = "桥梁状态不能为空")
|
@NotNull(message = "桥梁状态不能为空")
|
||||||
|
@InEnum(CommonStatusEnum.class)
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
// TODO @puhui999:枚举的校验
|
|
||||||
@Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "桥梁方向", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "桥梁方向不能为空")
|
@NotNull(message = "桥梁方向不能为空")
|
||||||
|
@InEnum(IotDataBridgeDirectionEnum.class)
|
||||||
private Integer direction;
|
private Integer direction;
|
||||||
|
|
||||||
@Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "桥梁类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "桥梁类型不能为空")
|
@NotNull(message = "桥梁类型不能为空")
|
||||||
|
@InEnum(IotDataBridgeTypeEnum.class)
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@Schema(description = "桥梁配置")
|
@Schema(description = "桥梁配置")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.iot.dal.dataobject.rule;
|
package cn.iocoder.yudao.module.iot.dal.dataobject.rule;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig;
|
import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.config.IotDataBridgeAbstractConfig;
|
||||||
import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeDirectionEnum;
|
import cn.iocoder.yudao.module.iot.enums.rule.IotDataBridgeDirectionEnum;
|
||||||
|
@ -42,7 +43,7 @@ public class IotDataBridgeDO extends BaseDO {
|
||||||
/**
|
/**
|
||||||
* 桥梁状态
|
* 桥梁状态
|
||||||
*
|
*
|
||||||
* 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
|
* 枚举 {@link CommonStatusEnum}
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue