删除用户和角色解绑关联

pull/235/head
RuoYi 4 years ago
parent fb480530c8
commit ded17a552d

@ -171,14 +171,7 @@ public class SysRoleController extends BaseController
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(roleService.deleteRoleByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
return toAjax(roleService.deleteRoleByIds(ids));
}
/**

@ -240,14 +240,7 @@ public class SysUserController extends BaseController
@ResponseBody
public AjaxResult remove(String ids)
{
try
{
return toAjax(userService.deleteUserByIds(ids));
}
catch (Exception e)
{
return error(e.getMessage());
}
return toAjax(userService.deleteUserByIds(ids));
}
/**

@ -308,7 +308,7 @@
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ruoyi/js/ry-ui.js?v=4.5.1}"></script>
<script th:src="@{/ruoyi/js/common.js?v=4.5.1}"></script>
<script th:src="@{/ruoyi/index.js?v=20200902}"></script>
<script th:src="@{/ruoyi/index.js?v=20201208}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
<script th:src="@{/js/resize-tabs.js}"></script>
<script th:inline="javascript">

@ -258,7 +258,7 @@
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ruoyi/js/ry-ui.js?v=4.5.1}"></script>
<script th:src="@{/ruoyi/js/common.js?v=4.5.1}"></script>
<script th:src="@{/ruoyi/index.js}"></script>
<script th:src="@{/ruoyi/index.js?v=20201208}"></script>
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
<script th:inline="javascript">
window.history.forward(1);

@ -66,7 +66,7 @@ public interface ISysRoleService
* @return
* @throws Exception
*/
public int deleteRoleByIds(String ids) throws Exception;
public int deleteRoleByIds(String ids);
/**
*

@ -90,7 +90,7 @@ public interface ISysUserService
* @return
* @throws Exception
*/
public int deleteUserByIds(String ids) throws Exception;
public int deleteUserByIds(String ids);
/**
*

@ -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);
}

@ -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);
}

Loading…
Cancel
Save