【功能新增】IoT: 增加产品脚本语言、状态和类型枚举,更新相关请求和响应对象以支持新的枚举类型
This commit is contained in:
parent
e26903b06b
commit
9b2389356f
|
@ -0,0 +1,46 @@
|
|||
package cn.iocoder.yudao.module.iot.enums.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* IoT 产品脚本语言枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum IotProductScriptLanguageEnum implements ArrayValuable<String> {
|
||||
|
||||
JAVASCRIPT("javascript", "JavaScript"),
|
||||
JAVA("java", "Java"),
|
||||
PYTHON("python", "Python"),
|
||||
;
|
||||
|
||||
public static final String[] ARRAYS = Arrays.stream(values()).map(IotProductScriptLanguageEnum::getCode)
|
||||
.toArray(String[]::new);
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private final String code;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public String[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static IotProductScriptLanguageEnum getByCode(String code) {
|
||||
return Arrays.stream(values())
|
||||
.filter(type -> type.getCode().equals(code))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package cn.iocoder.yudao.module.iot.enums.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* IoT 产品脚本状态枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum IotProductScriptStatusEnum implements ArrayValuable<Integer> {
|
||||
|
||||
ENABLE(0, "启用"),
|
||||
DISABLE(1, "禁用"),
|
||||
;
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotProductScriptStatusEnum::getStatus)
|
||||
.toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
* 状态值
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static IotProductScriptStatusEnum getByStatus(Integer status) {
|
||||
return Arrays.stream(values())
|
||||
.filter(type -> type.getStatus().equals(status))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public static boolean isEnable(Integer status) {
|
||||
return ENABLE.getStatus().equals(status);
|
||||
}
|
||||
|
||||
public static boolean isDisable(Integer status) {
|
||||
return DISABLE.getStatus().equals(status);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package cn.iocoder.yudao.module.iot.enums.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* IoT 产品脚本类型枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum IotProductScriptTypeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
PROPERTY_PARSER(1, "property_parser", "属性解析"),
|
||||
EVENT_PARSER(2, "event_parser", "事件解析"),
|
||||
COMMAND_ENCODER(3, "command_encoder", "命令编码"),
|
||||
;
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotProductScriptTypeEnum::getCode)
|
||||
.toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private final Integer code;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String type;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static IotProductScriptTypeEnum getByCode(Integer code) {
|
||||
return Arrays.stream(values())
|
||||
.filter(type -> type.getCode().equals(code))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.product.vo.script;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptLanguageEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptStatusEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -23,13 +27,16 @@ public class IotProductScriptPageReqVO extends PageParam {
|
|||
@Schema(description = "产品唯一标识符")
|
||||
private String productKey;
|
||||
|
||||
@Schema(description = "脚本类型(property_parser=属性解析,event_parser=事件解析,command_encoder=命令编码)", example = "2")
|
||||
private String scriptType;
|
||||
@Schema(description = "脚本类型", example = "1")
|
||||
@InEnum(IotProductScriptTypeEnum.class)
|
||||
private Integer scriptType;
|
||||
|
||||
@Schema(description = "脚本语言")
|
||||
@InEnum(IotProductScriptLanguageEnum.class)
|
||||
private String scriptLanguage;
|
||||
|
||||
@Schema(description = "状态(0=禁用 1=启用)", example = "2")
|
||||
@Schema(description = "状态", example = "0")
|
||||
@InEnum(IotProductScriptStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注说明", example = "你说的对")
|
||||
|
|
|
@ -24,9 +24,9 @@ public class IotProductScriptRespVO {
|
|||
@ExcelProperty("产品唯一标识符")
|
||||
private String productKey;
|
||||
|
||||
@Schema(description = "脚本类型(property_parser=属性解析,event_parser=事件解析,command_encoder=命令编码)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("脚本类型(property_parser=属性解析,event_parser=事件解析,command_encoder=命令编码)")
|
||||
private String scriptType;
|
||||
@Schema(description = "脚本类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("脚本类型")
|
||||
private Integer scriptType;
|
||||
|
||||
@Schema(description = "脚本内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("脚本内容")
|
||||
|
@ -36,8 +36,8 @@ public class IotProductScriptRespVO {
|
|||
@ExcelProperty("脚本语言")
|
||||
private String scriptLanguage;
|
||||
|
||||
@Schema(description = "状态(0=禁用 1=启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("状态(0=禁用 1=启用)")
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@ExcelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注说明", example = "你说的对")
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.product.vo.script;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptLanguageEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptStatusEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
@ -20,9 +24,10 @@ public class IotProductScriptSaveReqVO {
|
|||
@NotEmpty(message = "产品唯一标识符不能为空")
|
||||
private String productKey;
|
||||
|
||||
@Schema(description = "脚本类型(property_parser=属性解析,event_parser=事件解析,command_encoder=命令编码)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "脚本类型(property_parser=属性解析,event_parser=事件解析,command_encoder=命令编码)不能为空")
|
||||
private String scriptType;
|
||||
@Schema(description = "脚本类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "脚本类型不能为空")
|
||||
@InEnum(IotProductScriptTypeEnum.class)
|
||||
private Integer scriptType;
|
||||
|
||||
@Schema(description = "脚本内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "脚本内容不能为空")
|
||||
|
@ -30,10 +35,12 @@ public class IotProductScriptSaveReqVO {
|
|||
|
||||
@Schema(description = "脚本语言", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "脚本语言不能为空")
|
||||
@InEnum(IotProductScriptLanguageEnum.class)
|
||||
private String scriptLanguage;
|
||||
|
||||
@Schema(description = "状态(0=禁用 1=启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "状态(0=禁用 1=启用)不能为空")
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(IotProductScriptStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注说明", example = "你说的对")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.product.vo.script;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
@ -16,9 +18,10 @@ public class IotProductScriptTestReqVO {
|
|||
@NotNull(message = "产品ID不能为空")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "脚本类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "property_parser")
|
||||
@NotEmpty(message = "脚本类型不能为空")
|
||||
private String scriptType;
|
||||
@Schema(description = "脚本类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "脚本类型不能为空")
|
||||
@InEnum(value = IotProductScriptTypeEnum.class)
|
||||
private Integer scriptType;
|
||||
|
||||
@Schema(description = "脚本内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "脚本内容不能为空")
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.product.vo.script;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductScriptStatusEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
@ -12,8 +14,9 @@ public class IotProductScriptUpdateStatusReqVO {
|
|||
@NotNull(message = "脚本ID不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "状态(0=禁用 1=启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(IotProductScriptStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -147,14 +147,14 @@ public class IotProductScriptServiceImpl implements IotProductScriptService {
|
|||
|
||||
// 根据脚本类型设置特定参数
|
||||
switch (testReqVO.getScriptType()) {
|
||||
case "property_parser":
|
||||
case 1: // PROPERTY_PARSER
|
||||
params.put("method", "property");
|
||||
break;
|
||||
case "event_parser":
|
||||
case 2: // EVENT_PARSER
|
||||
params.put("method", "event");
|
||||
params.put("identifier", "default");
|
||||
break;
|
||||
case "command_encoder":
|
||||
case 3: // COMMAND_ENCODER
|
||||
params.put("method", "command");
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue