fix: 设备属性接口
parent
90672fe6a9
commit
fd799f331f
|
@ -225,7 +225,7 @@ public interface Constants {
|
||||||
/**
|
/**
|
||||||
* 设备-属性获取
|
* 设备-属性获取
|
||||||
*/
|
*/
|
||||||
String INVOKE_SERVICE_PROPERTY_GET = "/{deviceId}/service/property/get";
|
String INVOKE_SERVICE_PROPERTY_GET = "/service/property/get";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OTA升级
|
* OTA升级
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||||
* 平台API调用工具类
|
* 平台API调用工具类
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Deprecated
|
||||||
public class ApiTool {
|
public class ApiTool {
|
||||||
|
|
||||||
private final Vertx vertx;
|
private final Vertx vertx;
|
||||||
|
|
|
@ -63,50 +63,26 @@ public class DeviceController {
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "服务调用", notes = "服务调用", httpMethod = "POST")
|
@ApiOperation(value = "服务调用", notes = "服务调用", httpMethod = "POST")
|
||||||
@ApiImplicitParams({
|
@PostMapping("/service/invoke")
|
||||||
@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
|
public InvokeResult invokeService(@RequestBody @Validated Request<ServiceInvokeBo> request) {
|
||||||
@ApiImplicitParam(name = "service", value = "服务", dataTypeClass = String.class),
|
return new InvokeResult(deviceService.invokeService(request.getData().getDeviceId(), request.getData().getService(), request.getData().getArgs()));
|
||||||
@ApiImplicitParam(name = "args", value = "参数", dataTypeClass = Map.class),
|
|
||||||
})
|
|
||||||
@PostMapping(Constants.API_DEVICE.INVOKE_SERVICE)
|
|
||||||
public InvokeResult invokeService(@PathVariable("deviceId") String deviceId,
|
|
||||||
@PathVariable("service") String service,
|
|
||||||
@RequestBody Map<String, Object> args) {
|
|
||||||
if (StringUtils.isBlank(deviceId) || StringUtils.isBlank(service)) {
|
|
||||||
throw new BizException(ErrCode.PARAMS_EXCEPTION);
|
|
||||||
}
|
|
||||||
return new InvokeResult(deviceService.invokeService(deviceId, service, args));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "属性获取", notes = "属性获取", httpMethod = "POST")
|
@ApiOperation(value = "属性获取", notes = "属性获取", httpMethod = "POST")
|
||||||
@ApiImplicitParams({
|
@PostMapping("/service/property/get")
|
||||||
@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
|
public InvokeResult invokeServicePropertySet(@RequestBody @Validated Request<GetDeviceServicePorpertyBo> request) {
|
||||||
@ApiImplicitParam(name = "propertyNames", value = "属性列表", dataTypeClass = ArrayList.class)
|
return new InvokeResult(deviceService.getProperty(request.getData().getDeviceId(), request.getData().getPropertyNames(), true));
|
||||||
})
|
|
||||||
@PostMapping(Constants.API_DEVICE.INVOKE_SERVICE_PROPERTY_GET)
|
|
||||||
public InvokeResult invokeServicePropertySet(@PathVariable("deviceId") String deviceId,
|
|
||||||
@RequestBody List<String> propertyNames) {
|
|
||||||
if (StringUtils.isBlank(deviceId)) {
|
|
||||||
throw new BizException(ErrCode.PARAMS_EXCEPTION);
|
|
||||||
}
|
|
||||||
return new InvokeResult(deviceService.getProperty(deviceId, propertyNames, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "属性设置", notes = "属性设置", httpMethod = "POST")
|
@ApiOperation(value = "属性设置", notes = "属性设置", httpMethod = "POST")
|
||||||
@ApiImplicitParams({
|
@PostMapping("/service/property/set")
|
||||||
@ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
|
public InvokeResult setProperty(@RequestBody @Validated Request<SetDeviceServicePorpertyBo> request) {
|
||||||
@ApiImplicitParam(name = "args", value = "参数", dataTypeClass = Map.class)
|
return new InvokeResult(deviceService.setProperty(request.getData().getDeviceId(), request.getData().getArgs()));
|
||||||
})
|
|
||||||
@PostMapping(Constants.API_DEVICE.SET_PROPERTIES)
|
|
||||||
public InvokeResult setProperty(@PathVariable("deviceId") String deviceId,
|
|
||||||
@RequestBody Map<String, Object> args) {
|
|
||||||
return new InvokeResult(deviceService.setProperty(deviceId, args));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "设备列表", notes = "设备列表", httpMethod = "POST")
|
@ApiOperation(value = "设备列表", notes = "设备列表", httpMethod = "POST")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public Paging<DeviceInfo> getDevices(@Validated @RequestBody PageRequest<DeviceQueryBo> pageRequest) {
|
public Paging<DeviceInfo> getDevices(@Validated @RequestBody PageRequest<DeviceQueryBo> pageRequest) {
|
||||||
|
|
||||||
return deviceServiceImpl.getDevices(pageRequest);
|
return deviceServiceImpl.getDevices(pageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +97,6 @@ public class DeviceController {
|
||||||
@PostMapping("/children/list")
|
@PostMapping("/children/list")
|
||||||
public List<DeviceInfoVo> getChildren(@Validated @RequestBody PageRequest<String> request) {
|
public List<DeviceInfoVo> getChildren(@Validated @RequestBody PageRequest<String> request) {
|
||||||
String deviceId = request.getData();
|
String deviceId = request.getData();
|
||||||
|
|
||||||
return deviceServiceImpl.selectChildrenPageList(deviceId);
|
return deviceServiceImpl.selectChildrenPageList(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +215,7 @@ public class DeviceController {
|
||||||
* 删除分组
|
* 删除分组
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "删除分组")
|
@ApiOperation(value = "删除分组")
|
||||||
@DeleteMapping("/group/delete")
|
@PostMapping("/group/delete")
|
||||||
public boolean deleteGroup(@Validated @RequestBody Request<String> request) {
|
public boolean deleteGroup(@Validated @RequestBody Request<String> request) {
|
||||||
String id = request.getData();
|
String id = request.getData();
|
||||||
return deviceServiceImpl.deleteGroup(id);
|
return deviceServiceImpl.deleteGroup(id);
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class SpaceController {
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delSpace/{id}")
|
@PostMapping("/delSpace/{id}")
|
||||||
public void delSpace(@PathVariable("id") String id) {
|
public void delSpace(@PathVariable("id") String id) {
|
||||||
checkExistAndOwner(id);
|
checkExistAndOwner(id);
|
||||||
spaceData.deleteById(id);
|
spaceData.deleteById(id);
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package cc.iotkit.manager.dto.bo.device;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: regan
|
||||||
|
* @description:
|
||||||
|
* @date:created in 2023/6/17 12:17
|
||||||
|
* @modificed by:
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "GetDeviceServicePorpertyBo")
|
||||||
|
@Data
|
||||||
|
public class GetDeviceServicePorpertyBo {
|
||||||
|
@ApiModelProperty(value="设备id",required = true)
|
||||||
|
@NotBlank
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value="属性列表")
|
||||||
|
private List<String> propertyNames;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package cc.iotkit.manager.dto.bo.device;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: regan
|
||||||
|
* @description:
|
||||||
|
* @date:created in 2023/6/17 12:17
|
||||||
|
* @modificed by:
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "ServiceInvokeBo")
|
||||||
|
@Data
|
||||||
|
public class ServiceInvokeBo {
|
||||||
|
@ApiModelProperty(value="设备id",required = true)
|
||||||
|
@NotBlank
|
||||||
|
private String deviceId;
|
||||||
|
@ApiModelProperty(value="服务",required = true)
|
||||||
|
@NotBlank
|
||||||
|
private String service;
|
||||||
|
@ApiModelProperty(value="参数")
|
||||||
|
private Map<String, Object> args;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package cc.iotkit.manager.dto.bo.device;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: regan
|
||||||
|
* @description:
|
||||||
|
* @date:created in 2023/6/17 12:17
|
||||||
|
* @modificed by:
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "SetDeviceServicePorpertyBo")
|
||||||
|
@Data
|
||||||
|
public class SetDeviceServicePorpertyBo {
|
||||||
|
@ApiModelProperty(value="设备id",required = true)
|
||||||
|
@NotBlank
|
||||||
|
private String deviceId;
|
||||||
|
@ApiModelProperty(value="参数")
|
||||||
|
private Map<String, Object> args;
|
||||||
|
|
||||||
|
}
|
13
待优化项.md
13
待优化项.md
|
@ -1,4 +1,4 @@
|
||||||
# **待优化项**
|
# **后端待优化项**
|
||||||
|
|
||||||
## **主键**
|
## **主键**
|
||||||
统一主键名称id,属性Long
|
统一主键名称id,属性Long
|
||||||
|
@ -6,6 +6,13 @@
|
||||||
## **sonerlint扫描**
|
## **sonerlint扫描**
|
||||||
sonerlint扫描,按建议修改相关不规范的代码
|
sonerlint扫描,按建议修改相关不规范的代码
|
||||||
|
|
||||||
|
## **接口路径**
|
||||||
|
尽量不用路径参数、且路径直接放在接口上,不放在常量里
|
||||||
|
|
||||||
|
## **冗余方法、类**
|
||||||
|
删除掉不用的冗余方法、类
|
||||||
|
|
||||||
|
## **日志**
|
||||||
|
sql 日志打印的话加个拦截器,简化sql
|
||||||
|
增加requestid 基于MDC
|
||||||
|
|
||||||
## **xx**
|
|
||||||
xxxxxxxxxxxx
|
|
Loading…
Reference in New Issue