Commit 1d454a17 authored by ma's avatar ma

Merge remote-tracking branch 'remotes/origin/master' into for-yx

parents 7f895196 a01e923e
...@@ -80,9 +80,14 @@ public class AuthManager { ...@@ -80,9 +80,14 @@ public class AuthManager {
log.info("in black..."); log.info("in black...");
return false; return false;
} }
Apply apply = allApply.get(appId); String theAppId = device.getAppId();
if (theAppId == null) {
log.info("no real valid appId...");
return false;
}
Apply apply = allApply.get(theAppId);
String appKey = apply.getAppKey(); String appKey = apply.getAppKey();
String input = "app_id=" + appId + "&sn=" + sn; String input = "app_id=" + theAppId + "&sn=" + sn;
String valSHA1 = HmacUtil.encrypt(input, appKey, HmacUtil.HMAC_SHA1).toUpperCase(); String valSHA1 = HmacUtil.encrypt(input, appKey, HmacUtil.HMAC_SHA1).toUpperCase();
if (CommonUtil.toUpperCaseByEnglish(sign).equals(CommonUtil.toUpperCaseByEnglish(valSHA1))) { if (CommonUtil.toUpperCaseByEnglish(sign).equals(CommonUtil.toUpperCaseByEnglish(valSHA1))) {
return true; return true;
...@@ -112,9 +117,14 @@ public class AuthManager { ...@@ -112,9 +117,14 @@ public class AuthManager {
log.info("in black..."); log.info("in black...");
return false; return false;
} }
Apply apply = allApply.get(appId); String theAppId = device.getAppId();
if (theAppId == null) {
log.info("no real valid appId...");
return false;
}
Apply apply = allApply.get(theAppId);
String appKey = apply.getAppKey(); String appKey = apply.getAppKey();
String input = "app_id=" + appId + "&sn=" + sn + "&sn_bind=" + device.getSnBind(); String input = "app_id=" + theAppId + "&sn=" + sn + "&sn_bind=" + device.getSnBind();
String valSHA1 = HmacUtil.encrypt(input, appKey, HmacUtil.HMAC_SHA1).toUpperCase(); String valSHA1 = HmacUtil.encrypt(input, appKey, HmacUtil.HMAC_SHA1).toUpperCase();
if (CommonUtil.toUpperCaseByEnglish(sign).equals(CommonUtil.toUpperCaseByEnglish(valSHA1))) { if (CommonUtil.toUpperCaseByEnglish(sign).equals(CommonUtil.toUpperCaseByEnglish(valSHA1))) {
return true; return true;
......
...@@ -16,6 +16,9 @@ public class DeviceVo implements Serializable { ...@@ -16,6 +16,9 @@ public class DeviceVo implements Serializable {
@ApiModelProperty("设备Id") @ApiModelProperty("设备Id")
private int deviceId; private int deviceId;
@ApiModelProperty("应用Id")
private String appId;
@ApiModelProperty("应用名") @ApiModelProperty("应用名")
private String appName; private String appName;
......
...@@ -119,7 +119,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme ...@@ -119,7 +119,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
queryWrapper.eq(Device::getSnBind, snBind).last("limit 1"); queryWrapper.eq(Device::getSnBind, snBind).last("limit 1");
Device device = deviceMapper.selectOne(queryWrapper); Device device = deviceMapper.selectOne(queryWrapper);
if (device != null) { if (device != null) {
device.setSn(CommonUtil.genRandomNum(18)); if (snBind.equals(device.getSn())) {
device.setSn(null);
}
device.setSnBind(null); device.setSnBind(null);
device.setStatus(0); device.setStatus(0);
device.setUpdateTime(new Date()); device.setUpdateTime(new Date());
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="iot.sixiang.license.mapper.DeviceMapper"> <mapper namespace="iot.sixiang.license.mapper.DeviceMapper">
<select id="getDeviceList" resultType="iot.sixiang.license.model.vo.DeviceVo"> <select id="getDeviceList" resultType="iot.sixiang.license.model.vo.DeviceVo">
SELECT de.device_id,app_name,user_name,sn,sn_bind,de.status,de.create_time,de.update_time,de.device_id IN (select SELECT de.device_id, de.app_id, app_name,user_name,sn,sn_bind,de.status,de.create_time,de.update_time,de.device_id IN (select
device_id from device_black) AS blackFlag FROM device AS de device_id from device_black) AS blackFlag FROM device AS de
JOIN apply AS app ON de.app_id = app.app_id JOIN apply AS app ON de.app_id = app.app_id
JOIN `user` AS us ON us.user_id = app.user_id JOIN `user` AS us ON us.user_id = app.user_id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment