【功能新增】IoT: 增加产品脚本语言、状态和类型枚举,更新相关请求和响应对象以支持新的枚举类型
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user