Commit 892afb9c authored by 赵啸非's avatar 赵啸非

修改缓存刷新

parent ea29f216
Pipeline #2717 failed with stages
...@@ -78,7 +78,7 @@ public interface IDeviceFeign extends IFeign { ...@@ -78,7 +78,7 @@ public interface IDeviceFeign extends IFeign {
* @return * @return
*/ */
@PostMapping(value = "/api/receive") @PostMapping(value = "/api/receive")
Rest<String> deviceCall(@RequestBody DeviceReq deviceReq, @RequestHeader("Authorization") String authorization); Rest<String> deviceCall(@RequestBody DeviceReq deviceReq);
} }
...@@ -115,7 +115,7 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> { ...@@ -115,7 +115,7 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
} }
@Override @Override
public Rest<String> deviceCall(DeviceReq deviceReq, String authorization) { public Rest<String> deviceCall(DeviceReq deviceReq) {
return Rest.fail("暂时无法保存设备,请稍后再试!"); return Rest.fail("暂时无法保存设备,请稍后再试!");
} }
}; };
......
...@@ -56,13 +56,11 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -56,13 +56,11 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
throw new AppException("当前设备已激活!"); throw new AppException("当前设备已激活!");
deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue()); deviceEntity.setDeviceStatus(DeviceStatusEnum.离线.getValue());
deviceEntity.setEnabled(EnabledEnum.启用.getValue()); deviceEntity.setEnabled(EnabledEnum.启用.getValue());
this.getDao().update(deviceEntity); this.update(deviceEntity);
String token = getToken();
DeviceReq deviceReq = new DeviceReq(); DeviceReq deviceReq = new DeviceReq();
deviceReq.setReceiveMethod(DeviceMethodEnum.ACTIVE.getValue()); deviceReq.setReceiveMethod(DeviceMethodEnum.ACTIVE.getValue());
deviceReq.setDeviceCode(deviceCode); deviceReq.setDeviceCode(deviceCode);
Rest<String> rest = deviceFeign.deviceCall(deviceReq, token); Rest<String> rest = deviceFeign.deviceCall(deviceReq);
log.info("激活结果:{}", JSON.toJSONString(rest)); log.info("激活结果:{}", JSON.toJSONString(rest));
} }
...@@ -73,26 +71,12 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -73,26 +71,12 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceEntity.setEnabled(enabled); deviceEntity.setEnabled(enabled);
deviceEntity.setUpdateTime(new Date()); deviceEntity.setUpdateTime(new Date());
deviceEntity.setUpdateUserId(getContextUserId(context)); deviceEntity.setUpdateUserId(getContextUserId(context));
this.getDao().update(deviceEntity); this.update(deviceEntity);
String token = getToken();
DeviceReq deviceReq = new DeviceReq(); DeviceReq deviceReq = new DeviceReq();
deviceReq.setReceiveMethod(DeviceMethodEnum.ENABLED.getValue()); deviceReq.setReceiveMethod(DeviceMethodEnum.ENABLED.getValue());
deviceReq.setDeviceCode(deviceEntity.getDeviceCode()); deviceReq.setDeviceCode(deviceEntity.getDeviceCode());
Rest<String> rest = deviceFeign.deviceCall(deviceReq, token); Rest<String> rest = deviceFeign.deviceCall(deviceReq);
log.info("启用结果:{}", JSON.toJSONString(rest)); log.info("启用结果:{}", JSON.toJSONString(rest));
} }
private String getToken() {
LoginForm loginForm = new LoginForm();
loginForm.setLoginName(loginName);
loginForm.setPassword(password);
Rest<String> rest = deviceFeign.getToken(loginForm);
if (YesNoEnum.YES.getValue() == rest.getCode()) {
String token = rest.getData();
return token;
} else {
throw new AppException("get token errors! " + rest.getMsg());
}
}
} }
\ No newline at end of file
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