diff --git a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java index d32ed79c..8bc8097c 100644 --- a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java +++ b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/controller/OpenDeviceController.java @@ -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 bo) { + public OpenDeviceInfoVo createDevice(@RequestBody @Validated Request bo) { return openDeviceService.addDevice(bo.getData()); } diff --git a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/vo/OpenDeviceInfoVo.java b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/vo/OpenDeviceInfoVo.java new file mode 100644 index 00000000..94b0f6b6 --- /dev/null +++ b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/dto/vo/OpenDeviceInfoVo.java @@ -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; +} diff --git a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/OpenDeviceService.java b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/OpenDeviceService.java index dae8239f..c5e2e4fc 100644 --- a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/OpenDeviceService.java +++ b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/OpenDeviceService.java @@ -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); diff --git a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenDeviceServiceImpl.java b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenDeviceServiceImpl.java index 49e79148..39831979 100644 --- a/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenDeviceServiceImpl.java +++ b/iot-module/iot-openapi/src/main/java/cc/iotkit/openapi/service/impl/OpenDeviceServiceImpl.java @@ -15,6 +15,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