【代码评审】IoT:物模型日志
This commit is contained in:
parent
f580383267
commit
e01d03eefb
|
@ -14,7 +14,6 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode PRODUCT_KEY_EXISTS = new ErrorCode(1_050_001_001, "产品标识已经存在");
|
||||
ErrorCode PRODUCT_STATUS_NOT_DELETE = new ErrorCode(1_050_001_002, "产品状是发布状态,不允许删除");
|
||||
ErrorCode PRODUCT_STATUS_NOT_ALLOW_THING_MODEL = new ErrorCode(1_050_001_003, "产品状是发布状态,不允许操作物模型");
|
||||
ErrorCode PRODUCT_DEVICE_NOT_EXISTS = new ErrorCode(1_050_001_004, "产品设备类型不存在");
|
||||
|
||||
// ========== 产品物模型 1-050-002-000 ============
|
||||
ErrorCode THING_MODEL_NOT_EXISTS = new ErrorCode(1_050_002_000, "产品物模型不存在");
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package cn.iocoder.yudao.module.iot.mq.consumer.simulatesend;
|
||||
|
||||
/**
|
||||
* TODO @alwayssuper:记得实现,还有类注释哈
|
||||
*
|
||||
* @author alwayssuper
|
||||
* @date 2024/12/20 8:04
|
||||
* @since 2024/12/20 8:04
|
||||
*/
|
||||
public class SimulateSendConsumer {
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package cn.iocoder.yudao.module.iot.util;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.iot.enums.IotConstants;
|
||||
import cn.iocoder.yudao.module.iot.enums.product.IotProductDeviceTypeEnum;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_DEVICE_NOT_EXISTS;
|
||||
|
||||
// TODO @芋艿:可能要思索下,有没更好的处理方式
|
||||
// TODO @芋艿:怎么改成无状态
|
||||
|
@ -34,20 +30,17 @@ public class IotTdDatabaseUtils {
|
|||
* @return 产品超级表表名
|
||||
*/
|
||||
public static String getProductSuperTableName(Integer deviceType, String productKey) {
|
||||
// TODO @alwayssuper:枚举字段,不要 1、2、3;不符合预期,抛出异常
|
||||
if (deviceType == null) {
|
||||
throw exception(PRODUCT_DEVICE_NOT_EXISTS);
|
||||
}
|
||||
Assert.notNull(deviceType, "deviceType 不能为空");
|
||||
if (IotProductDeviceTypeEnum.GATEWAY_SUB.getType().equals(deviceType)) {
|
||||
return String.format(IotConstants.GATEWAY_SUB_STABLE_NAME_FORMAT, productKey).toLowerCase();
|
||||
} else if (IotProductDeviceTypeEnum.GATEWAY.getType().equals(deviceType)) {
|
||||
}
|
||||
if (IotProductDeviceTypeEnum.GATEWAY.getType().equals(deviceType)) {
|
||||
return String.format(IotConstants.GATEWAY_STABLE_NAME_FORMAT, productKey).toLowerCase();
|
||||
} else if (IotProductDeviceTypeEnum.DIRECT.getType().equals(deviceType)){
|
||||
}
|
||||
if (IotProductDeviceTypeEnum.DIRECT.getType().equals(deviceType)){
|
||||
return String.format(IotConstants.DEVICE_STABLE_NAME_FORMAT, productKey).toLowerCase();
|
||||
}
|
||||
else{
|
||||
throw exception(PRODUCT_DEVICE_NOT_EXISTS);
|
||||
}
|
||||
throw new IllegalArgumentException("deviceType 不正确");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +51,6 @@ public class IotTdDatabaseUtils {
|
|||
*
|
||||
*/
|
||||
public static String getThingModelMessageSuperTableName(String productKey) {
|
||||
// TODO @alwayssuper:是不是应该 + 拼接就好,不用 format
|
||||
return "thing_model_message_" + productKey.toLowerCase();
|
||||
}
|
||||
|
||||
|
@ -70,7 +62,8 @@ public class IotTdDatabaseUtils {
|
|||
* @return 物模型日志设备表名
|
||||
*/
|
||||
public static String getThingModelMessageDeviceTableName(String productKey, String deviceName) {
|
||||
return String.format(IotConstants.THING_MODEL_MESSAGE_TABLE_NAME_FORMAT, productKey.toLowerCase(), deviceName.toLowerCase());
|
||||
return String.format(IotConstants.THING_MODEL_MESSAGE_TABLE_NAME_FORMAT,
|
||||
productKey.toLowerCase(), deviceName.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.TdThingModelMessageMapper">
|
||||
|
||||
<!-- 创建物模型消息日志超级表 -->
|
||||
<!-- TODO @芋艿:捉摸下字段,特别是 sys、ts 这种缩写 -->
|
||||
<update id="createSuperTable">
|
||||
CREATE STABLE ${dataBaseName}.${superTableName}(
|
||||
ts TIMESTAMP,
|
||||
|
|
Loading…
Reference in New Issue