Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-usercenter
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit df2e2f6b
authored
May 09, 2022
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复选中组织节点获取可见用户bug
1 parent
58f89e56
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
16 deletions
src/main/java/cn/com/glsx/shield/modules/mapper/UserPathMapper.java
src/main/java/cn/com/glsx/shield/modules/service/permissionStrategy/SubOrdinateStrategy.java
src/main/resources/mapper/UserPathMapper.xml
src/main/java/cn/com/glsx/shield/modules/mapper/UserPathMapper.java
View file @
df2e2f6
...
@@ -98,14 +98,12 @@ public interface UserPathMapper extends CommonBaseMapper<UserPath> {
...
@@ -98,14 +98,12 @@ public interface UserPathMapper extends CommonBaseMapper<UserPath> {
* @param superiorId
* @param superiorId
* @param userIds
* @param userIds
* @param orgIds
* @param orgIds
* @param supOrgIds
* @param subOrgIds
* @param subOrgIds
* @return
* @return
*/
*/
List
<
DepartmentUserCount
>
selectSubordinateDepartmentList
(
@Param
(
"superiorId"
)
Long
superiorId
,
List
<
DepartmentUserCount
>
selectSubordinateDepartmentList
(
@Param
(
"superiorId"
)
Long
superiorId
,
@Param
(
"userIds"
)
Collection
<
Long
>
userIds
,
@Param
(
"userIds"
)
Collection
<
Long
>
userIds
,
@Param
(
"orgIds"
)
Collection
<
Long
>
orgIds
,
@Param
(
"orgIds"
)
Collection
<
Long
>
orgIds
,
@Param
(
"supOrgIds"
)
Collection
<
Long
>
supOrgIds
,
@Param
(
"subOrgIds"
)
Collection
<
Long
>
subOrgIds
);
@Param
(
"subOrgIds"
)
Collection
<
Long
>
subOrgIds
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/shield/modules/service/permissionStrategy/SubOrdinateStrategy.java
View file @
df2e2f6
...
@@ -136,7 +136,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
...
@@ -136,7 +136,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
}
}
//存在用户的下级部门
//存在用户的下级部门
List
<
DepartmentUserCount
>
departmentUserCountList
=
userPathMapper
.
selectSubordinateDepartmentList
(
userId
,
null
,
null
,
null
,
null
);
List
<
DepartmentUserCount
>
departmentUserCountList
=
userPathMapper
.
selectSubordinateDepartmentList
(
userId
,
null
,
null
,
null
);
Set
<
Long
>
hasUserDeptIdList
=
departmentUserCountList
.
stream
().
map
(
DepartmentUserCount:
:
getDepartmentId
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toSet
());
Set
<
Long
>
hasUserDeptIdList
=
departmentUserCountList
.
stream
().
map
(
DepartmentUserCount:
:
getDepartmentId
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toSet
());
...
@@ -165,9 +165,12 @@ public class SubOrdinateStrategy extends PermissionStrategy {
...
@@ -165,9 +165,12 @@ public class SubOrdinateStrategy extends PermissionStrategy {
Long
userId
=
ShieldContextHolder
.
getUserId
();
Long
userId
=
ShieldContextHolder
.
getUserId
();
//如果是搜索search.getUserIds()
//如果是搜索search.getUserIds()
List
<
DepartmentUserCount
>
departmentUserCountList
=
userPathMapper
.
selectSubordinateDepartmentList
(
userId
,
search
.
getUserIds
(),
List
<
DepartmentUserCount
>
departmentUserCountList
=
userPathMapper
.
selectSubordinateDepartmentList
(
userId
,
search
.
getOrgIds
(),
search
.
getSupOrgIds
(),
search
.
getSubOrgIds
());
search
.
getUserIds
(),
search
.
getOrgIds
(),
search
.
getSubOrgIds
());
//下级部门id
//下级部门id
Set
<
Long
>
subDepartmentIdList
=
departmentUserCountList
.
stream
().
map
(
DepartmentUserCount:
:
getDepartmentId
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toSet
());
Set
<
Long
>
subDepartmentIdList
=
departmentUserCountList
.
stream
().
map
(
DepartmentUserCount:
:
getDepartmentId
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toSet
());
...
@@ -203,7 +206,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
...
@@ -203,7 +206,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
//过滤一级层次组织
//过滤一级层次组织
Map
<
Long
,
Organization
>
organizationMap
=
organizationList
.
stream
().
filter
(
m
->
m
.
getDepth
()
==
1
).
collect
(
Collectors
.
toMap
(
Organization:
:
getSubId
,
treeModel
->
treeModel
));
Map
<
Long
,
Organization
>
organizationMap
=
organizationList
.
stream
().
filter
(
m
->
m
.
getDepth
()
==
1
).
collect
(
Collectors
.
toMap
(
Organization:
:
getSubId
,
treeModel
->
treeModel
));
Map
<
Long
,
Long
>
subordinate
Department
UserCountMap
=
departmentUserCountList
.
parallelStream
().
collect
(
Collectors
.
groupingBy
(
DepartmentUserCount:
:
getSuperiorId
,
Collectors
.
counting
()));
Map
<
Long
,
Long
>
subordinateUserCountMap
=
departmentUserCountList
.
parallelStream
().
collect
(
Collectors
.
groupingBy
(
DepartmentUserCount:
:
getSuperiorId
,
Collectors
.
counting
()));
List
<
OrgModel
>
modelList
=
allDepartmentList
.
stream
().
map
(
dep
->
{
List
<
OrgModel
>
modelList
=
allDepartmentList
.
stream
().
map
(
dep
->
{
OrgModel
orgModel
=
new
OrgModel
();
OrgModel
orgModel
=
new
OrgModel
();
...
@@ -212,7 +215,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
...
@@ -212,7 +215,7 @@ public class SubOrdinateStrategy extends PermissionStrategy {
orgModel
.
setOrgId
(
dep
.
getId
());
orgModel
.
setOrgId
(
dep
.
getId
());
orgModel
.
setOrgName
(
dep
.
getDepartmentName
());
orgModel
.
setOrgName
(
dep
.
getDepartmentName
());
orgModel
.
setTenantId
(
dep
.
getTenantId
());
orgModel
.
setTenantId
(
dep
.
getTenantId
());
Long
userNumber
=
subordinate
Department
UserCountMap
.
get
(
dep
.
getId
());
Long
userNumber
=
subordinateUserCountMap
.
get
(
dep
.
getId
());
orgModel
.
setUserNumber
(
userNumber
!=
null
?
Math
.
toIntExact
(
userNumber
)
:
0
);
orgModel
.
setUserNumber
(
userNumber
!=
null
?
Math
.
toIntExact
(
userNumber
)
:
0
);
orgModel
.
setOrderNum
(
dep
.
getOrderNum
());
orgModel
.
setOrderNum
(
dep
.
getOrderNum
());
orgModel
.
setIsRoot
(
dep
.
getIsRoot
());
orgModel
.
setIsRoot
(
dep
.
getIsRoot
());
...
@@ -231,10 +234,10 @@ public class SubOrdinateStrategy extends PermissionStrategy {
...
@@ -231,10 +234,10 @@ public class SubOrdinateStrategy extends PermissionStrategy {
for
(
int
i
=
0
;
i
<
treeSize
;
i
++)
{
for
(
int
i
=
0
;
i
<
treeSize
;
i
++)
{
OrgTreeModel
otm
=
orgTreeModelList
.
get
(
i
);
OrgTreeModel
otm
=
orgTreeModelList
.
get
(
i
);
Long
orgId
=
Long
.
valueOf
(
otm
.
getId
());
Long
orgId
=
Long
.
valueOf
(
otm
.
getId
());
Long
userNumber
=
subordinate
Department
UserCountMap
.
get
(
orgId
);
Long
userNumber
=
subordinateUserCountMap
.
get
(
orgId
);
otm
.
setUserNumber
(
userNumber
==
null
?
0
:
Math
.
toIntExact
(
userNumber
));
otm
.
setUserNumber
(
userNumber
==
null
?
0
:
Math
.
toIntExact
(
userNumber
));
//2021/8/19 设置下级用户子树
//2021/8/19 设置下级用户子树
if
(
search
.
getHasUserLeaf
()
&&
otm
.
getUserNumber
()
>
0
)
{
if
(
search
.
getHasUserLeaf
())
{
List
<
OrgModel
>
userList
=
groupByOrgIdUserMap
.
get
(
orgId
);
List
<
OrgModel
>
userList
=
groupByOrgIdUserMap
.
get
(
orgId
);
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
userList
))
{
List
<
OrgTreeModel
>
userTreeList
=
userList
.
stream
().
map
(
OrgTreeModel:
:
new
).
collect
(
Collectors
.
toList
());
List
<
OrgTreeModel
>
userTreeList
=
userList
.
stream
().
map
(
OrgTreeModel:
:
new
).
collect
(
Collectors
.
toList
());
...
...
src/main/resources/mapper/UserPathMapper.xml
View file @
df2e2f6
...
@@ -110,14 +110,8 @@
...
@@ -110,14 +110,8 @@
#{item}
#{item}
</foreach>
</foreach>
</if>
</if>
<if
test=
"supOrgIds != null and supOrgIds.size() > 0"
>
and to2.superior_id in
<foreach
collection=
"supOrgIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</if>
<if
test=
"subOrgIds != null and subOrgIds.size() > 0"
>
<if
test=
"subOrgIds != null and subOrgIds.size() > 0"
>
and to2.su
b
_id in
and to2.su
perior
_id in
<foreach
collection=
"subOrgIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
<foreach
collection=
"subOrgIds"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
#{item}
</foreach>
</foreach>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment