【功能新增】IoT:设备注册 sub register 逻辑
This commit is contained in:
@@ -53,6 +53,15 @@ public interface IotDeviceUpstreamApi {
|
||||
@PostMapping(PREFIX + "/register")
|
||||
CommonResult<Boolean> registerDevice(@Valid @RequestBody IotDeviceRegisterReqDTO registerReqDTO);
|
||||
|
||||
// TODO @芋艿:这个需要 plugins 接入下
|
||||
/**
|
||||
* 注册子设备
|
||||
*
|
||||
* @param registerReqDTO 注册子设备 DTO
|
||||
*/
|
||||
@PostMapping(PREFIX + "/register-sub")
|
||||
CommonResult<Boolean> registerSubDevice(@Valid @RequestBody IotDeviceRegisterSubReqDTO registerReqDTO);
|
||||
|
||||
// ========== 插件相关 ==========
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* IoT 设备【注册】注册 Request DTO
|
||||
* IoT 设备【注册】自己 Request DTO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
|
@@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IoT 设备【注册】子设备 Request DTO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class IotDeviceRegisterSubReqDTO extends IotDeviceUpstreamAbstractReqDTO {
|
||||
|
||||
/**
|
||||
* 子设备数组
|
||||
*/
|
||||
@NotEmpty(message = "子设备不能为空")
|
||||
private List<Device> params;
|
||||
|
||||
/**
|
||||
* 设备信息
|
||||
*/
|
||||
@Data
|
||||
public static class Device {
|
||||
|
||||
/**
|
||||
* 产品标识
|
||||
*/
|
||||
@NotEmpty(message = "产品标识不能为空")
|
||||
private String productKey;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@NotEmpty(message = "设备名称不能为空")
|
||||
private String deviceName;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -29,8 +29,8 @@ public enum IotDeviceMessageIdentifierEnum {
|
||||
OTA_REPORT("report"), // 上行
|
||||
|
||||
REGISTER_REGISTER("register"), // 上行
|
||||
REGISTER_SUB_REGISTER("sub_register"), // 上行
|
||||
REGISTER_SUB_UNREGISTER("sub_unregister"),; // 下行
|
||||
REGISTER_REGISTER_SUB("register_sub"), // 上行
|
||||
REGISTER_UNREGISTER_SUB("unregister_sub"),; // 下行
|
||||
|
||||
/**
|
||||
* 标志符
|
||||
|
@@ -46,4 +46,14 @@ public enum IotProductDeviceTypeEnum implements ArrayValuable<Integer> {
|
||||
return GATEWAY.getType().equals(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是网关子设备
|
||||
*
|
||||
* @param type 类型
|
||||
* @return 是否是网关子设备
|
||||
*/
|
||||
public static boolean isGatewaySub(Integer type) {
|
||||
return GATEWAY_SUB.getType().equals(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user