1.修复openapi接口的一些bug

2.编辑设备name的时候添加判断不可重复名称
V0.5.x
dsy 2023-07-27 10:44:58 +08:00
parent 1f3afb77c1
commit 9fa0056fef
4 changed files with 9 additions and 40 deletions

View File

@ -415,6 +415,11 @@ public class DeviceServiceImpl implements IDeviceService {
DeviceInfo di=data.to(DeviceInfo.class);
di.setLocate(new DeviceInfo.Locate(data.getLongitude(),data.getLatitude()));
di.setState(data.getState());
//同产品不可重复设备名
DeviceInfo deviceRepetition = deviceInfoData.findByProductKeyAndDeviceName(data.getProductKey(), data.getDeviceName());
if (deviceRepetition != null && !deviceRepetition.getDeviceId().equals(di.getDeviceId())) {
throw new BizException(ErrCode.MODEL_DEVICE_ALREADY);
}
return deviceInfoData.save(di)!=null;
}

View File

@ -13,36 +13,13 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>it.ozimov</groupId>
<artifactId>embedded-redis</artifactId>
<exclusions>
<exclusion>
<artifactId>slf4j-simple</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
@ -59,20 +36,6 @@
<artifactId>iot-rule-engine</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-screen</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-server</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>
<artifactId>iot-component-converter</artifactId>
</dependency>
<dependency>
<groupId>cc.iotkit</groupId>

View File

@ -38,7 +38,7 @@ public class OpenDeviceController {
}
@ApiOperation(value = "单个设备注册")
@PostMapping("/v1/registerDevice ")
@PostMapping("/v1/registerDevice")
public boolean createDevice(@RequestBody @Validated Request<OpenapiDeviceBo> bo) {
return openDeviceService.addDevice(bo.getData());
}
@ -50,7 +50,7 @@ public class OpenDeviceController {
}
@ApiOperation(value = "设置设备的属性", notes = "设置设备的属性", httpMethod = "POST")
@PostMapping("/v1/setDeviceProperty ")
@PostMapping("/v1/setDeviceProperty")
public InvokeResult setProperty(@RequestBody @Validated Request<OpenapiSetDeviceServicePropertyBo> request) {
return new InvokeResult(openDeviceService.setProperty(request.getData().getProductKey(), request.getData().getDeviceName(), request.getData().getArgs()));
}

View File

@ -52,7 +52,8 @@ public class OpenBaseServiceImpl implements OpenBaseService {
// 校验租户
checkTenant(bo.getTenantId());
System.out.println("boAppid + password + boTimeStamp = " + boAppid + password + boTimeStamp);
System.out.println("boIdentifier = " + boIdentifier);
if (!CodecUtil.md5Str(boAppid + password + boTimeStamp).equals(boIdentifier)){
throw new BizException(ErrCode.IDENTIFIER_ERROR);
}