|
@@ -103,24 +103,37 @@ public class UserController {
|
|
|
String roleKey="disableRole:"+roleId;
|
|
|
String companyKey="disableCompany:"+currentUser.getCompanyId();
|
|
|
String departmentKey="department:"+currentUser.getDepartmentId();
|
|
|
+ String userKey="disableUser:" + currentUser.getId();
|
|
|
byte[] bytes = redisUtil.get(roleKey.getBytes());
|
|
|
byte[] bytes2 = redisUtil.get(companyKey.getBytes());
|
|
|
byte[] bytes3 = redisUtil.get(departmentKey.getBytes());
|
|
|
+ byte[] bytes4 = redisUtil.get(userKey.getBytes());
|
|
|
String authorization = request.getHeader("Authorization");
|
|
|
String token =authorization.substring(authorization.indexOf("Bearer")+6).trim();
|
|
|
String tokenKey = "offlineStatus:" + token;
|
|
|
+ boolean flag=false;
|
|
|
int status=0;
|
|
|
- if(bytes==null){
|
|
|
+ if(bytes!=null){
|
|
|
status=2;
|
|
|
+ flag=true;
|
|
|
}
|
|
|
- if(bytes2==null){
|
|
|
+ if(bytes2!=null){
|
|
|
status=3;
|
|
|
+ flag=true;
|
|
|
}
|
|
|
if((currentUser.getDepartmentId()!=null&&bytes3!=null)){
|
|
|
status=4;
|
|
|
+ flag=true;
|
|
|
}
|
|
|
- redisUtil.setExpire(tokenKey.getBytes(),
|
|
|
- ByteArrayUtils.objectToBytes(status).get(), 1800);//15分钟过期
|
|
|
+ if(bytes4!=null){
|
|
|
+ status=5;
|
|
|
+ flag=true;
|
|
|
+ }
|
|
|
+ if(flag){
|
|
|
+ redisUtil.setExpire(tokenKey.getBytes(),
|
|
|
+ ByteArrayUtils.objectToBytes(status).get(), 1800);//15分钟过期
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if(bytes!=null||bytes2!=null||(currentUser.getDepartmentId()!=null&&bytes3!=null)){
|
|
|
return null;
|
|
@@ -149,8 +162,8 @@ public class UserController {
|
|
|
return new AjaxMessage<>(ResultStatus.OK, result);
|
|
|
}
|
|
|
@RequestMapping(value = "getUserStatus", method = RequestMethod.POST)
|
|
|
- @ApiOperation(value = "获取用户当前状态")
|
|
|
- public AjaxMessage<Integer> getUserStatus(@ApiParam(value = "token", required = true)@RequestParam String accessToken) {
|
|
|
+ @ApiOperation(value = "获取用户当前状态",notes = "返回0代表超时,其他代表用户被禁用了")
|
|
|
+ public AjaxMessage<Integer> getUserStatus(@ApiParam(value = "accessToken", required = true)@RequestParam String accessToken) {
|
|
|
String key="offlineStatus:"+ accessToken;
|
|
|
byte[] bytes = redisUtil.get(key.getBytes());
|
|
|
Optional<Integer> status = ByteArrayUtils.bytesToObject(bytes);
|