1.修改registerDevice接口的数据返回格式
parent
444de0a35a
commit
7101975078
|
@ -5,6 +5,7 @@ import cc.iotkit.model.InvokeResult;
|
|||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiDeviceBo;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiSetDeviceServicePropertyBo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDeviceInfoVo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDevicePropertyVo;
|
||||
import cc.iotkit.openapi.service.OpenBaseService;
|
||||
import cc.iotkit.openapi.service.OpenDeviceService;
|
||||
|
@ -40,7 +41,7 @@ public class OpenDeviceController {
|
|||
|
||||
@ApiOperation(value = "单个设备注册")
|
||||
@PostMapping("/v1/registerDevice")
|
||||
public boolean createDevice(@RequestBody @Validated Request<OpenapiDeviceBo> bo) {
|
||||
public OpenDeviceInfoVo createDevice(@RequestBody @Validated Request<OpenapiDeviceBo> bo) {
|
||||
return openDeviceService.addDevice(bo.getData());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package cc.iotkit.openapi.dto.vo;
|
||||
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.product.ThingModel;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@ApiModel(value = "OpenDeviceInfoVo")
|
||||
@Data
|
||||
@AutoMapper(target = DeviceInfo.class)
|
||||
public class OpenDeviceInfoVo {
|
||||
private String id;
|
||||
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 产品key
|
||||
*/
|
||||
private String productKey;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备型号
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 设备密钥
|
||||
*/
|
||||
private String secret;
|
||||
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 所属平台用户ID
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
private Long createAt;
|
||||
}
|
|
@ -2,6 +2,7 @@ package cc.iotkit.openapi.service;
|
|||
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiDeviceBo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDeviceInfoVo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDevicePropertyVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -15,7 +16,7 @@ import java.util.Map;
|
|||
public interface OpenDeviceService {
|
||||
DeviceInfo getDetail(OpenapiDeviceBo bo);
|
||||
|
||||
boolean addDevice(OpenapiDeviceBo bo);
|
||||
OpenDeviceInfoVo addDevice(OpenapiDeviceBo bo);
|
||||
|
||||
boolean deleteDevice(OpenapiDeviceBo bo);
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import cc.iotkit.model.device.message.ThingModelMessage;
|
|||
import cc.iotkit.model.product.Product;
|
||||
import cc.iotkit.model.product.ThingModel;
|
||||
import cc.iotkit.openapi.dto.bo.device.OpenapiDeviceBo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDeviceInfoVo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenDevicePropertyVo;
|
||||
import cc.iotkit.openapi.dto.vo.OpenPropertyVo;
|
||||
import cc.iotkit.openapi.service.OpenDeviceService;
|
||||
|
@ -55,7 +56,7 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addDevice(OpenapiDeviceBo bo) {
|
||||
public OpenDeviceInfoVo addDevice(OpenapiDeviceBo bo) {
|
||||
String productKey = bo.getProductKey();
|
||||
String deviceName = bo.getDeviceName();
|
||||
String parentId = bo.getParentId();
|
||||
|
@ -91,7 +92,7 @@ public class OpenDeviceServiceImpl implements OpenDeviceService {
|
|||
device.setParentId(parentId);
|
||||
}
|
||||
deviceInfoData.save(device);
|
||||
return true;
|
||||
return MapstructUtils.convert(device, OpenDeviceInfoVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue