|
@@ -234,14 +234,28 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
private UmsAdminRoleRelationMapper umsAdminRoleRelationMapper;
|
|
|
@Override
|
|
|
public int delete(Long id) {
|
|
|
- adminCacheService.delAdmin(id);
|
|
|
- adminCacheService.delResourceList(id);
|
|
|
+ long userId = CurrUserUtil.getUserId();
|
|
|
+ if(id==userId){
|
|
|
+ throw new GlobalException("无法删除自己!");
|
|
|
+ }
|
|
|
int count = adminMapper.deleteByPrimaryKey(id);
|
|
|
+ //清楚redis数据
|
|
|
+ deleteRedisData(id);
|
|
|
+ //删除用户和角色相关数据
|
|
|
+ deleteUserRole(id);
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteUserRole(Long id) {
|
|
|
UmsAdminRoleRelationExample umsAdmin=new UmsAdminRoleRelationExample();
|
|
|
UmsAdminRoleRelationExample.Criteria criteria = umsAdmin.createCriteria();
|
|
|
criteria.andAdminIdEqualTo(id);
|
|
|
umsAdminRoleRelationMapper.deleteByExample(umsAdmin);
|
|
|
- return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deleteRedisData(Long id) {
|
|
|
+ adminCacheService.delAdmin(id);
|
|
|
+ adminCacheService.delResourceList(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -355,6 +369,9 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
UmsAdmin admin = getAdminByUsername(username);
|
|
|
Integer status = admin.getStatus();
|
|
|
if(status.intValue() ==0 ){
|
|
|
+ adminCacheService.delToken(admin.getUsername());
|
|
|
+ adminCacheService.delAdmin(admin.getId());
|
|
|
+ adminCacheService.delResourceList(admin.getId());
|
|
|
throw new UsernameNotFoundException("用户被禁用!");
|
|
|
}
|
|
|
if (admin != null) {
|
|
@@ -373,10 +390,18 @@ public class UmsAdminServiceImpl implements UmsAdminService {
|
|
|
|
|
|
@Override
|
|
|
public int updateStatus(Long id, UmsAdmin umsAdmin){
|
|
|
+ Integer status = umsAdmin.getStatus();
|
|
|
long userId = CurrUserUtil.getUserId();
|
|
|
if(id==userId){
|
|
|
throw new GlobalException("无法禁用自己!");
|
|
|
}
|
|
|
+ UmsAdmin umsAdminRe = adminMapper.selectByPrimaryKey(id);
|
|
|
+
|
|
|
+ if(status==0){
|
|
|
+// adminCacheService.delToken(umsAdminRe.getUsername());
|
|
|
+// adminCacheService.delAdmin(id);
|
|
|
+// adminCacheService.delResourceList(id);
|
|
|
+ }
|
|
|
umsAdmin.setId(id);
|
|
|
return adminMapper.updateByPrimaryKeySelective(umsAdmin);
|
|
|
}
|