Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王飞
vehicle-quality-review
Commits
dd2fe721
Commit
dd2fe721
authored
Apr 07, 2024
by
盖献康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug - 71010
parent
6dd5e021
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
32 deletions
+81
-32
SysUserController.java
...va/com/ruoyi/web/controller/system/SysUserController.java
+1
-1
ISysUserService.java
...c/main/java/com/ruoyi/system/service/ISysUserService.java
+6
-0
SysUserServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+74
-31
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
View file @
dd2fe721
...
...
@@ -90,7 +90,7 @@ public class SysUserController extends BaseController
role
.
setRoleName
(
request
.
getRoleName
());
List
<
SysRole
>
roleList
=
roleService
.
selectRoleList
(
role
);
if
(
CollUtil
.
isNotEmpty
(
roleList
))
{
List
<
SysUser
>
list
=
userService
.
selectUser
ListByRoleId
(
roleList
.
get
(
0
).
getRoleId
());
List
<
SysUser
>
list
=
userService
.
selectUser
ByRoleInDept
(
roleList
.
get
(
0
).
getRoleId
());
return
R
.
ok
(
list
);
}
else
{
return
R
.
fail
(
"角色不存在"
);
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
View file @
dd2fe721
...
...
@@ -219,4 +219,10 @@ public interface ISysUserService
*/
public
String
importUser
(
List
<
SysUser
>
userList
,
Boolean
isUpdateSupport
,
String
operName
);
/**
* 通过角色ID查询在同部门下的所有用户
* @param roleId
* @return
*/
List
<
SysUser
>
selectUserByRoleInDept
(
Long
roleId
);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
View file @
dd2fe721
...
...
@@ -4,6 +4,9 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.validation.Validator
;
import
com.ruoyi.common.core.domain.entity.SysDept
;
import
com.ruoyi.system.mapper.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -22,17 +25,12 @@ import com.ruoyi.common.utils.spring.SpringUtils;
import
com.ruoyi.system.domain.SysPost
;
import
com.ruoyi.system.domain.SysUserPost
;
import
com.ruoyi.system.domain.SysUserRole
;
import
com.ruoyi.system.mapper.SysPostMapper
;
import
com.ruoyi.system.mapper.SysRoleMapper
;
import
com.ruoyi.system.mapper.SysUserMapper
;
import
com.ruoyi.system.mapper.SysUserPostMapper
;
import
com.ruoyi.system.mapper.SysUserRoleMapper
;
import
com.ruoyi.system.service.ISysConfigService
;
import
com.ruoyi.system.service.ISysUserService
;
/**
* 用户 业务层处理
*
*
* @author ruoyi
*/
@Service
...
...
@@ -61,6 +59,9 @@ public class SysUserServiceImpl implements ISysUserService
@Autowired
protected
Validator
validator
;
@Autowired
private
SysDeptMapper
sysDeptMapper
;
@Override
public
List
<
SysUser
>
selectUserListByRoleId
(
Long
roleId
)
{
return
userMapper
.
selectUserListByRoleId
(
roleId
);
...
...
@@ -68,7 +69,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 根据条件分页查询用户列表
*
*
* @param user 用户信息
* @return 用户信息集合信息
*/
...
...
@@ -81,7 +82,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 根据条件分页查询已分配用户角色列表
*
*
* @param user 用户信息
* @return 用户信息集合信息
*/
...
...
@@ -100,7 +101,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 根据条件分页查询未分配用户角色列表
*
*
* @param user 用户信息
* @return 用户信息集合信息
*/
...
...
@@ -113,7 +114,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 通过用户名查询用户
*
*
* @param userName 用户名
* @return 用户对象信息
*/
...
...
@@ -125,7 +126,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 通过用户ID查询用户
*
*
* @param userId 用户ID
* @return 用户对象信息
*/
...
...
@@ -137,7 +138,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 查询用户所属角色组
*
*
* @param userName 用户名
* @return 结果
*/
...
...
@@ -154,7 +155,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 查询用户所属岗位组
*
*
* @param userName 用户名
* @return 结果
*/
...
...
@@ -171,7 +172,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 校验用户名称是否唯一
*
*
* @param user 用户信息
* @return 结果
*/
...
...
@@ -225,7 +226,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 校验用户是否允许操作
*
*
* @param user 用户信息
*/
@Override
...
...
@@ -239,7 +240,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 校验用户是否有数据权限
*
*
* @param userId 用户id
*/
@Override
...
...
@@ -259,7 +260,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 新增保存用户信息
*
*
* @param user 用户信息
* @return 结果
*/
...
...
@@ -278,7 +279,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 注册用户信息
*
*
* @param user 用户信息
* @return 结果
*/
...
...
@@ -290,7 +291,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 修改保存用户信息
*
*
* @param user 用户信息
* @return 结果
*/
...
...
@@ -312,7 +313,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 用户授权角色
*
*
* @param userId 用户ID
* @param roleIds 角色组
*/
...
...
@@ -326,7 +327,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 修改用户状态
*
*
* @param user 用户信息
* @return 结果
*/
...
...
@@ -338,7 +339,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 修改用户基本信息
*
*
* @param user 用户信息
* @return 结果
*/
...
...
@@ -350,7 +351,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 修改用户头像
*
*
* @param userName 用户名
* @param avatar 头像地址
* @return 结果
...
...
@@ -363,7 +364,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 重置用户密码
*
*
* @param user 用户信息
* @return 结果
*/
...
...
@@ -375,7 +376,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 重置用户密码
*
*
* @param userName 用户名
* @param password 密码
* @return 结果
...
...
@@ -388,7 +389,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 新增用户角色信息
*
*
* @param user 用户对象
*/
public
void
insertUserRole
(
SysUser
user
)
...
...
@@ -398,7 +399,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 新增用户岗位信息
*
*
* @param user 用户对象
*/
public
void
insertUserPost
(
SysUser
user
)
...
...
@@ -421,7 +422,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 新增用户角色信息
*
*
* @param userId 用户ID
* @param roleIds 角色组
*/
...
...
@@ -444,7 +445,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 通过用户ID删除用户
*
*
* @param userId 用户ID
* @return 结果
*/
...
...
@@ -461,7 +462,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 批量删除用户信息
*
*
* @param userIds 需要删除的用户ID
* @return 结果
*/
...
...
@@ -483,7 +484,7 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 导入用户数据
*
*
* @param userList 用户数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @param operName 操作用户
...
...
@@ -552,4 +553,46 @@ public class SysUserServiceImpl implements ISysUserService
}
return
successMsg
.
toString
();
}
/**
* 通过角色ID查询在同部门下的所有用户
* @param roleId
* @return
*/
@Override
public
List
<
SysUser
>
selectUserByRoleInDept
(
Long
roleId
)
{
List
<
SysUser
>
list
=
new
ArrayList
<>();
// 获取当前登陆用户的部门
Long
deptId
=
SecurityUtils
.
getDeptId
();
// 获取当前角色下的所有用户
List
<
SysUser
>
userList
=
selectUserListByRoleId
(
roleId
);
// 查询出当前用户所在部门以及所有子部门
List
<
SysDept
>
deptList
=
sysDeptMapper
.
selectDeptList
(
new
SysDept
());
List
<
Long
>
userListInDept
=
new
ArrayList
<>();
userListInDept
.
add
(
deptId
);
getAllDeptId
(
deptList
,
deptId
,
userListInDept
);
for
(
SysUser
user
:
userList
)
{
if
(
userListInDept
.
contains
(
user
.
getDeptId
()))
{
list
.
add
(
user
);
}
}
return
list
;
}
/**
* 递归
* 查询出当前用户所在部门以及所有子部门
* @param deptList 传入的部门集合
* @param deptId 查询需要的部门ID
* @param userListInDept 存入的指定部门集合
*/
private
void
getAllDeptId
(
List
<
SysDept
>
deptList
,
Long
deptId
,
List
<
Long
>
userListInDept
)
{
deptList
.
stream
()
.
filter
(
dept
->
dept
.
getParentId
().
equals
(
deptId
))
.
forEach
(
dept
->
{
userListInDept
.
add
(
dept
.
getDeptId
());
getAllDeptId
(
deptList
,
dept
.
getDeptId
(),
userListInDept
);
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment