删除用户和角色解绑关联
parent
fb480530c8
commit
ded17a552d
|
@ -170,16 +170,9 @@ public class SysRoleController extends BaseController
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
return toAjax(roleService.deleteRoleByIds(ids));
|
return toAjax(roleService.deleteRoleByIds(ids));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return error(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验角色名称
|
* 校验角色名称
|
||||||
|
|
|
@ -239,16 +239,9 @@ public class SysUserController extends BaseController
|
||||||
@PostMapping("/remove")
|
@PostMapping("/remove")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult remove(String ids)
|
public AjaxResult remove(String ids)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
return toAjax(userService.deleteUserByIds(ids));
|
return toAjax(userService.deleteUserByIds(ids));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return error(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户名
|
* 校验用户名
|
||||||
|
|
|
@ -308,7 +308,7 @@
|
||||||
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
|
<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/ry-ui.js?v=4.5.1}"></script>
|
||||||
<script th:src="@{/ruoyi/js/common.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="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
|
||||||
<script th:src="@{/js/resize-tabs.js}"></script>
|
<script th:src="@{/js/resize-tabs.js}"></script>
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
|
|
|
@ -258,7 +258,7 @@
|
||||||
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
|
<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/ry-ui.js?v=4.5.1}"></script>
|
||||||
<script th:src="@{/ruoyi/js/common.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:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
window.history.forward(1);
|
window.history.forward(1);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public interface ISysRoleService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws Exception 异常
|
* @throws Exception 异常
|
||||||
*/
|
*/
|
||||||
public int deleteRoleByIds(String ids) throws Exception;
|
public int deleteRoleByIds(String ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存角色信息
|
* 新增保存角色信息
|
||||||
|
|
|
@ -90,7 +90,7 @@ public interface ISysUserService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* @throws Exception 异常
|
* @throws Exception 异常
|
||||||
*/
|
*/
|
||||||
public int deleteUserByIds(String ids) throws Exception;
|
public int deleteUserByIds(String ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存用户信息
|
* 保存用户信息
|
||||||
|
|
|
@ -133,8 +133,13 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public boolean deleteRoleById(Long roleId)
|
public boolean deleteRoleById(Long roleId)
|
||||||
{
|
{
|
||||||
|
// 删除角色与菜单关联
|
||||||
|
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
|
||||||
|
// 删除角色与部门关联
|
||||||
|
roleDeptMapper.deleteRoleDeptByRoleId(roleId);
|
||||||
return roleMapper.deleteRoleById(roleId) > 0 ? true : false;
|
return roleMapper.deleteRoleById(roleId) > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +150,8 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteRoleByIds(String ids) throws BusinessException
|
@Transactional
|
||||||
|
public int deleteRoleByIds(String ids)
|
||||||
{
|
{
|
||||||
Long[] roleIds = Convert.toLongArray(ids);
|
Long[] roleIds = Convert.toLongArray(ids);
|
||||||
for (Long roleId : roleIds)
|
for (Long roleId : roleIds)
|
||||||
|
@ -157,6 +163,10 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||||
throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
throw new BusinessException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 删除角色与菜单关联
|
||||||
|
roleMenuMapper.deleteRoleMenu(roleIds);
|
||||||
|
// 删除角色与部门关联
|
||||||
|
roleDeptMapper.deleteRoleDept(roleIds);
|
||||||
return roleMapper.deleteRoleByIds(roleIds);
|
return roleMapper.deleteRoleByIds(roleIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public int deleteUserById(Long userId)
|
public int deleteUserById(Long userId)
|
||||||
{
|
{
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
|
@ -176,13 +177,18 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteUserByIds(String ids) throws BusinessException
|
@Transactional
|
||||||
|
public int deleteUserByIds(String ids)
|
||||||
{
|
{
|
||||||
Long[] userIds = Convert.toLongArray(ids);
|
Long[] userIds = Convert.toLongArray(ids);
|
||||||
for (Long userId : userIds)
|
for (Long userId : userIds)
|
||||||
{
|
{
|
||||||
checkUserAllowed(new SysUser(userId));
|
checkUserAllowed(new SysUser(userId));
|
||||||
}
|
}
|
||||||
|
// 删除用户与角色关联
|
||||||
|
userRoleMapper.deleteUserRole(userIds);
|
||||||
|
// 删除用户与岗位关联
|
||||||
|
userPostMapper.deleteUserPost(userIds);
|
||||||
return userMapper.deleteUserByIds(userIds);
|
return userMapper.deleteUserByIds(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue