优化设备注册接口代码结构
This commit is contained in:
parent
501205c445
commit
36523de816
@ -59,12 +59,22 @@ public class DeviceController {
|
||||
return Mono.error(ex);
|
||||
}
|
||||
//设备类型是否匹配暂时不做限制
|
||||
DeviceTypeEnum entryTypeEnum = DeviceTypeEnum.getEnumWithCode(type);
|
||||
if(entryTypeEnum == null){
|
||||
BusinessException ex = new BusinessException("不支持的设备类型");
|
||||
return Mono.error(ex);
|
||||
}
|
||||
//验签
|
||||
String wifiMd5 = MD5.create().digestHex(wifiMac).toLowerCase();
|
||||
String btMd5 = MD5.create().digestHex(btMac).toLowerCase();
|
||||
String md5 = MD5.create().digestHex(wifiMd5 + btMd5 + type + time + key).toLowerCase();
|
||||
if (md5.equals(signature)) {
|
||||
String wifiMd5 = MD5.create().digestHex(wifiMac);
|
||||
String btMd5 = MD5.create().digestHex(btMac);
|
||||
String md5 = MD5.create().digestHex(wifiMd5 + btMd5 + type + time + key);
|
||||
if (!md5.equals(signature.toLowerCase())) {
|
||||
//
|
||||
//验签失败
|
||||
BusinessException ex = new BusinessException("验签失败");
|
||||
return Mono.error(ex);
|
||||
}
|
||||
|
||||
DeviceInfoRequest request = new DeviceInfoRequest();
|
||||
request.setWifiMac(wifiMac);
|
||||
request.setBtMac(btMac);
|
||||
@ -72,7 +82,7 @@ public class DeviceController {
|
||||
|
||||
return mono.defaultIfEmpty(new DeviceInfoEntity()).flatMap(entity -> {
|
||||
if(entity.getId() == null){
|
||||
DeviceTypeEnum entryTypeEnum = DeviceTypeEnum.getEnumWithCode(type);
|
||||
|
||||
entity = new DeviceInfoEntity();
|
||||
entity.setWifiMac(wifiMac);
|
||||
entity.setBtMac(btMac);
|
||||
@ -94,10 +104,7 @@ public class DeviceController {
|
||||
resp.setSn(o.getSn());
|
||||
return resp;
|
||||
});
|
||||
}
|
||||
//验签失败
|
||||
BusinessException ex = new BusinessException("验签失败");
|
||||
return Mono.error(ex);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user