代码优化

pull/308/head
Elune 2020-02-10 14:45:51 +08:00
parent da006624a4
commit bc5187a7ad
2 changed files with 7 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.security.service.OnlineUserService;
import me.zhengjie.utils.EncryptUtils;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -48,6 +49,8 @@ public class OnlineController {
@PreAuthorize("@el.check()")
public ResponseEntity<Object> delete(@RequestBody Set<String> keys) throws Exception {
for (String key : keys) {
// 解密Key
key = EncryptUtils.desDecrypt(key);
onlineUserService.kickOut(key);
}
return new ResponseEntity<>(HttpStatus.OK);

View File

@ -90,8 +90,8 @@ public class OnlineUserService {
* @param key /
* @throws Exception /
*/
public void kickOut(String key) throws Exception {
key = properties.getOnlineKey() + EncryptUtils.desDecrypt(key);
public void kickOut(String key){
key = properties.getOnlineKey() + key;
redisUtils.del(key);
}
@ -148,9 +148,9 @@ public class OnlineUserService {
try {
String token =EncryptUtils.desDecrypt(onlineUser.getKey());
if(StringUtils.isNotBlank(igoreToken)&&!igoreToken.equals(token)){
this.kickOut(onlineUser.getKey());
this.kickOut(token);
}else if(StringUtils.isBlank(igoreToken)){
this.kickOut(onlineUser.getKey());
this.kickOut(token);
}
} catch (Exception e) {
log.error("checkUser is error",e);