【代码评审】IOT:物模型

This commit is contained in:
YunaiV 2024-09-14 09:44:09 +08:00
parent 64fefaa630
commit 07b3ac20f6
19 changed files with 108 additions and 48 deletions

View File

@ -1,9 +0,0 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
import lombok.Data;
@Data
public class ThingModelArraySpecs {
private int size; // 数组长度
private ThingModelDataType item; // 数组元素的类型
}

View File

@ -1,14 +1,22 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArgument;
import lombok.Data;
import java.util.List;
@Data
public class ThingModelEvent {
private String identifier;
private String name;
private String type; // "info""alert""error"
/**
* 事件类型
*
* "info""alert""error"
*/
private String type;
private List<ThingModelArgument> outputData;
private String description;
private String method;
}

View File

@ -1,13 +1,16 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelDataType;
import lombok.Data;
@Data
public class ThingModelProperty {
private String identifier;
private String name;
private String accessMode; // "rw""r""w"
private boolean required;
private Boolean required;
private ThingModelDataType dataType;
private String description;
}

View File

@ -1,15 +1,23 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArgument;
import lombok.Data;
import java.util.List;
@Data
public class ThingModelService {
private String identifier;
private String name;
private String callType; // "sync""async"
/**
* 调用类型
*
* "sync""async"
*/
private String callType;
private List<ThingModelArgument> inputData;
private List<ThingModelArgument> outputData;
private String description;
private String method;
}

View File

@ -1,12 +1,17 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
@Data
public class ThingModelArgument {
private String identifier;
private String name;
private ThingModelDataType dataType;
private String direction; // 用于区分输入或输出参数"input" "output"
/**
* 用于区分输入或输出参数"input" "output"
*/
private String direction;
private String description;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
@Data
public class ThingModelArraySpecs {
/**
* 数组长度
*/
private int size;
/**
* 数组元素的类型
*/
private ThingModelDataType item;
}

View File

@ -1,11 +1,12 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
// TODO @haohao这个是不是和别的类不太统一哈
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelArrayType extends ThingModelDataType {
private ThingModelArraySpecs specs;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -6,5 +6,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelBoolType extends ThingModelDataType {
// Bool 类型一般不需要额外的 specs
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@ -18,5 +18,7 @@ import lombok.Data;
@JsonSubTypes.Type(value = ThingModelArrayType.class, name = "array")
})
public abstract class ThingModelDataType {
private String type;
}

View File

@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelDateType extends ThingModelDataType {
// Date 类型一般不需要额外的 specs
}

View File

@ -1,18 +1,18 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelDoubleType extends ThingModelDataType {
private ThingModelDoubleSpecs specs;
}
@Data
class ThingModelDoubleSpecs {
private Double min;
private Double max;
private Double step;
private String unit;
}

View File

@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Map;
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelEnumType extends ThingModelDataType {
private Map<String, String> specs; // 枚举值和描述的键值对
/**
* 枚举值和描述的键值对
*/
private Map<String, String> specs;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -11,8 +11,10 @@ public class ThingModelFloatType extends ThingModelDataType {
@Data
class ThingModelFloatSpecs {
private Float min;
private Float max;
private Float step;
private String unit;
}

View File

@ -1,18 +1,18 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelIntType extends ThingModelDataType {
private ThingModelIntSpecs specs;
}
@Data
class ThingModelIntSpecs {
private Integer min;
private Integer max;
private Integer step;
private String unit;
}

View File

@ -1,11 +1,13 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
@Data
public class ThingModelStructField {
private String identifier;
private String name;
private ThingModelDataType dataType;
private String description;
}

View File

@ -1,13 +1,14 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelStructType extends ThingModelDataType {
private List<ThingModelStructField> specs;
}

View File

@ -1,15 +1,20 @@
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class ThingModelTextType extends ThingModelDataType {
private ThingModelTextSpecs specs;
}
@Data
class ThingModelTextSpecs {
private Integer length; // 最大长度
/**
* 最大长度
*/
private Integer length;
}

View File

@ -1,42 +1,48 @@
package cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* IoT 产品物模型 DO
* IoT 产品物模型功能 DO
*
* 每个 {@link IotProductDO} {@link IotThinkModelFunctionDO} 一对多的关系它的每个属性事件服务都对应一条记录
*
* @author 芋道源码
*/
@TableName("iot_think_model_function")
@KeySequence("iot_think_model_function_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class IotThinkModelFunctionDO extends BaseDO {
/**
* 产品ID
* 物模型功能编号
*/
@TableId
private Long id;
// TODO @haohao是不是有一个 identifier需要要有哈
// TODO @haohaonamedescription 属性还有个类型
/**
* 产品标识
*
* 关联 {@link IotProductDO#getId()}
*/
private Long productId;
/**
* 产品标识
*
* 关联 {@link IotProductDO#getProductKey()}
*/
private String productKey;
// TODO @haohao是不是可以搞成 ThingModelPropertyThingModelEventThingModelService 进行存储
/**
* 属性列表
*/

View File

@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.iot.service.thinkmodelfunction;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.*;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArgument;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArraySpecs;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArrayType;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelTextType;
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO;
import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunctionConvert;
import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;