[代码优化](v2.6):禁用用户后踢出用户Bug修复

close https://github.com/elunez/eladmin/issues/551
pull/572/head
zhengjie 2020-12-24 16:45:08 +08:00
parent 1556f13379
commit a90bfac2cf
4 changed files with 6 additions and 5 deletions

View File

@ -179,11 +179,12 @@ public class OnlineUserService {
* @param username /
*/
@Async
public void kickOutForUsername(String username) {
public void kickOutForUsername(String username) throws Exception {
List<OnlineUserDto> onlineUsers = getAll(username);
for (OnlineUserDto onlineUser : onlineUsers) {
if (onlineUser.getUserName().equals(username)) {
kickOut(onlineUser.getKey());
String token =EncryptUtils.desDecrypt(onlineUser.getKey());
kickOut(token);
}
}
}

View File

@ -114,7 +114,7 @@ public class UserController {
@ApiOperation("修改用户")
@PutMapping
@PreAuthorize("@el.check('user:edit')")
public ResponseEntity<Object> update(@Validated(User.Update.class) @RequestBody User resources){
public ResponseEntity<Object> update(@Validated(User.Update.class) @RequestBody User resources) throws Exception {
checkLevel(resources);
userService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);

View File

@ -49,7 +49,7 @@ public interface UserService {
*
* @param resources /
*/
void update(User resources);
void update(User resources) throws Exception;
/**
*

View File

@ -98,7 +98,7 @@ public class UserServiceImpl implements UserService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(User resources) {
public void update(User resources) throws Exception {
User user = userRepository.findById(resources.getId()).orElseGet(User::new);
ValidationUtil.isNull(user.getId(), "User", "id", resources.getId());
User user1 = userRepository.findByUsername(resources.getUsername());