|
|
|
@ -1,13 +1,17 @@ |
|
|
|
package com.hxhq.system.controller; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import com.hxhq.system.domain.SysUserRole; |
|
|
|
import com.hxhq.system.form.RoleUserSaveForm; |
|
|
|
import com.hxhq.system.service.ISysDeptService; |
|
|
|
import com.hxhq.system.service.ISysRoleService; |
|
|
|
import com.hxhq.system.service.ISysUserService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
@ -91,7 +95,7 @@ public class SysRoleController extends BaseController |
|
|
|
} |
|
|
|
else if (!roleService.checkRoleKeyUnique(role)) |
|
|
|
{ |
|
|
|
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
|
return error("新增角色'" + role.getRoleName() + "'失败,角色编码已存在"); |
|
|
|
} |
|
|
|
role.setCreateBy(SecurityUtils.getUsername()); |
|
|
|
return toAjax(roleService.insertRole(role)); |
|
|
|
@ -114,7 +118,7 @@ public class SysRoleController extends BaseController |
|
|
|
} |
|
|
|
else if (!roleService.checkRoleKeyUnique(role)) |
|
|
|
{ |
|
|
|
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
|
return error("修改角色'" + role.getRoleName() + "'失败,角色编码已存在"); |
|
|
|
} |
|
|
|
role.setUpdateBy(SecurityUtils.getUsername()); |
|
|
|
return toAjax(roleService.updateRole(role)); |
|
|
|
@ -172,11 +176,12 @@ public class SysRoleController extends BaseController |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:role:list") |
|
|
|
@GetMapping("/authUser/allocatedList") |
|
|
|
public TableDataInfo allocatedList(SysUser user) |
|
|
|
public AjaxResult allocatedList(Long roleId) |
|
|
|
{ |
|
|
|
startPage(); |
|
|
|
List<SysUser> list = userService.selectAllocatedList(user); |
|
|
|
return getDataTable(list); |
|
|
|
AjaxResult ajax = AjaxResult.success(); |
|
|
|
ajax.put("selected", userService.selectAllocatedListSimple(roleId)); |
|
|
|
ajax.put("list", userService.selectTransferAllList()); |
|
|
|
return ajax; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -226,6 +231,28 @@ public class SysRoleController extends BaseController |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 批量设置角色的用户 |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:role:edit") |
|
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT) |
|
|
|
@PostMapping("/authUser/setAll") |
|
|
|
@Transactional |
|
|
|
public AjaxResult setAll(@RequestBody RoleUserSaveForm form) |
|
|
|
{ |
|
|
|
List<Long> existsUserIds = userService.selectAllocatedListSimple(form.getRoleId()); |
|
|
|
List<Long> deleteIds = existsUserIds.stream().filter(o->!form.getUserIdList().contains(o)).collect(Collectors.toList()); |
|
|
|
List<Long> addList = form.getUserIdList().stream().filter(o->!existsUserIds.contains(o)).collect(Collectors.toList()); |
|
|
|
if(deleteIds.size()>0){ |
|
|
|
roleService.deleteAuthUsers(form.getRoleId(), deleteIds.toArray(new Long[0])); |
|
|
|
} |
|
|
|
if(addList.size()>0){ |
|
|
|
roleService.insertAuthUsers(form.getRoleId(), addList.toArray(new Long[0])); |
|
|
|
} |
|
|
|
|
|
|
|
return AjaxResult.success("操作成功"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取对应角色部门树列表 |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:role:query") |
|
|
|
|