删除用户和角色解绑关联

This commit is contained in:
RuoYi
2020-12-09 10:14:10 +08:00
parent fb480530c8
commit ded17a552d
8 changed files with 24 additions and 22 deletions

View File

@ -66,7 +66,7 @@ public interface ISysRoleService
* @return 结果
* @throws Exception 异常
*/
public int deleteRoleByIds(String ids) throws Exception;
public int deleteRoleByIds(String ids);
/**
* 新增保存角色信息

View File

@ -90,7 +90,7 @@ public interface ISysUserService
* @return 结果
* @throws Exception 异常
*/
public int deleteUserByIds(String ids) throws Exception;
public int deleteUserByIds(String ids);
/**
* 保存用户信息

View File

@ -133,8 +133,13 @@ public class SysRoleServiceImpl implements ISysRoleService
* @return 结果
*/
@Override
@Transactional
public boolean deleteRoleById(Long roleId)
{
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
// 删除角色与部门关联
roleDeptMapper.deleteRoleDeptByRoleId(roleId);
return roleMapper.deleteRoleById(roleId) > 0 ? true : false;
}
@ -145,7 +150,8 @@ public class SysRoleServiceImpl implements ISysRoleService
* @throws Exception
*/
@Override
public int deleteRoleByIds(String ids) throws BusinessException
@Transactional
public int deleteRoleByIds(String ids)
{
Long[] roleIds = Convert.toLongArray(ids);
for (Long roleId : roleIds)
@ -157,6 +163,10 @@ public class SysRoleServiceImpl implements ISysRoleService
throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenu(roleIds);
// 删除角色与部门关联
roleDeptMapper.deleteRoleDept(roleIds);
return roleMapper.deleteRoleByIds(roleIds);
}

View File

@ -160,6 +160,7 @@ public class SysUserServiceImpl implements ISysUserService
* @return 结果
*/
@Override
@Transactional
public int deleteUserById(Long userId)
{
// 删除用户与角色关联
@ -176,13 +177,18 @@ public class SysUserServiceImpl implements ISysUserService
* @return 结果
*/
@Override
public int deleteUserByIds(String ids) throws BusinessException
@Transactional
public int deleteUserByIds(String ids)
{
Long[] userIds = Convert.toLongArray(ids);
for (Long userId : userIds)
{
checkUserAllowed(new SysUser(userId));
}
// 删除用户与角色关联
userRoleMapper.deleteUserRole(userIds);
// 删除用户与岗位关联
userPostMapper.deleteUserPost(userIds);
return userMapper.deleteUserByIds(userIds);
}