Browse Source

操作物联平台api接口添加物联设备id非空判断

develop
xiepufeng 1 year ago
parent
commit
a726fc0518
  1. 36
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

36
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.Parameter;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -166,6 +167,10 @@ public class DcDeviceController extends BaseController {
@GetMapping("/properties/latest/{deviceId}")
public AjaxResult getDeviceLatestProperties(@PathVariable @Parameter(description = "设备ID") String deviceId) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
Response response // 请求响应
= okHttp
@ -187,6 +192,11 @@ public class DcDeviceController extends BaseController {
public AjaxResult queryDeviceProperties(@PathVariable @Parameter(description = "设备ID") String deviceId,
@PathVariable @Parameter(description = "属性ID") String propertyId,
@Parameter(hidden = true) HashMap<String, Object> props) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(propertyId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(props);
@ -210,6 +220,11 @@ public class DcDeviceController extends BaseController {
@GetMapping("/properties/latest/{deviceId}/{propertyId}")
public AjaxResult getDeviceLatestProperty(@PathVariable @Parameter(description = "设备ID") String deviceId,
@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(propertyId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
Response response // 请求响应
= okHttp
@ -232,6 +247,10 @@ public class DcDeviceController extends BaseController {
@PathVariable String propertyId,
@RequestParam HashMap<String, Object> props) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(propertyId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(props);
@ -257,6 +276,10 @@ public class DcDeviceController extends BaseController {
@PathVariable String deviceId,
@RequestBody DeviceGetPropertiesOperateRequest props) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
@ -286,6 +309,11 @@ public class DcDeviceController extends BaseController {
@PathVariable String deviceId,
@RequestBody HashMap<String, Object> props
) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(props);
@ -313,6 +341,10 @@ public class DcDeviceController extends BaseController {
@PathVariable String functionId,
@RequestBody HashMap<String, Object> props) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(functionId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(props);
@ -343,6 +375,10 @@ public class DcDeviceController extends BaseController {
@Parameter(hidden = true) HashMap<String, Object> queryParam
) throws HttpException, IOException {
if (!StringUtils.hasText(deviceId) || !StringUtils.hasText(eventId)) {
return AjaxResult.error("设备未接入");
}
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(queryParam);

Loading…
Cancel
Save