Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
2e1ee2a6
Commit
2e1ee2a6
authored
Mar 30, 2019
by
eddie.woo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
样式
parent
584a7aae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
MenuServiceImpl.java
...n/java/pwc/taxtech/atms/service/impl/MenuServiceImpl.java
+32
-17
No files found.
atms-api/src/main/java/pwc/taxtech/atms/service/impl/MenuServiceImpl.java
View file @
2e1ee2a6
...
...
@@ -7,23 +7,22 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.StringUtils
;
import
pwc.taxtech.atms.common.CommonConstants
;
import
pwc.taxtech.atms.common.CommonUtils
;
import
pwc.taxtech.atms.dao.MenuMapper
;
import
pwc.taxtech.atms.dao.PermissionMapper
;
import
pwc.taxtech.atms.dao.RolePermissionMapper
;
import
pwc.taxtech.atms.dao.UserRoleMapper
;
import
pwc.taxtech.atms.dao.*
;
import
pwc.taxtech.atms.dto.MenuDisplayDto
;
import
pwc.taxtech.atms.dto.MenuDto
;
import
pwc.taxtech.atms.entity.*
;
import
pwc.taxtech.atms.exception.ApplicationException
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
*/
@Service
public
class
MenuServiceImpl
{
public
class
MenuServiceImpl
extends
BaseService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MenuServiceImpl
.
class
);
...
...
@@ -38,6 +37,8 @@ public class MenuServiceImpl {
@Autowired
private
PermissionMapper
permissionMapper
;
@Resource
private
UserMapper
userMapper
;
public
List
<
MenuDisplayDto
>
getMenusForDisplay
(
Integer
moduleId
,
String
userId
)
{
logger
.
debug
(
"Start to get menus for display"
);
...
...
@@ -108,19 +109,33 @@ public class MenuServiceImpl {
}
private
List
<
String
>
getMenuIds
(
Integer
moduleId
,
String
userId
){
UserRoleExample
userRoleExample
=
new
UserRoleExample
();
userRoleExample
.
createCriteria
().
andUserIdEqualTo
(
userId
);
List
<
String
>
userRoleIdList
=
userRoleMapper
.
selectByExample
(
userRoleExample
).
stream
().
map
(
UserRole:
:
getRoleId
).
collect
(
Collectors
.
toList
());
List
<
String
>
permissionIds
=
rolePermissionMapper
.
selectByRoleId
(
userRoleIdList
.
get
(
0
))
.
stream
().
map
(
RolePermission:
:
getPermissionId
).
collect
(
Collectors
.
toList
());
PermissionExample
permissionExample
=
new
PermissionExample
();
permissionExample
.
createCriteria
().
andIdIn
(
permissionIds
);
List
<
String
>
menuIds
=
permissionMapper
.
selectByExample
(
permissionExample
)
.
stream
().
map
(
Permission:
:
getMenuId
).
collect
(
Collectors
.
toList
());
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
return
menuIds
;
private
List
<
String
>
getMenuIds
(
Integer
moduleId
,
String
userId
)
{
//fix superAdmin 返回所有权限
userId
=
authUserHelper
.
getCurrentUserId
();
if
(!
StringUtils
.
hasText
(
userId
))
{
return
Collections
.
emptyList
();
}
User
user
=
userMapper
.
selectByPrimaryKey
(
userId
);
if
(
user
==
null
)
{
return
Collections
.
emptyList
();
}
if
(
user
.
getIsSuperAdmin
())
{
return
permissionMapper
.
selectByExample
(
null
).
stream
().
map
(
Permission:
:
getMenuId
)
.
collect
(
Collectors
.
toList
());
}
else
{
UserRoleExample
userRoleExample
=
new
UserRoleExample
();
userRoleExample
.
createCriteria
().
andUserIdEqualTo
(
userId
);
List
<
String
>
userRoleIdList
=
userRoleMapper
.
selectByExample
(
userRoleExample
).
stream
().
map
(
UserRole:
:
getRoleId
).
collect
(
Collectors
.
toList
());
List
<
String
>
permissionIds
=
rolePermissionMapper
.
selectByRoleId
(
userRoleIdList
.
get
(
0
))
.
stream
().
map
(
RolePermission:
:
getPermissionId
).
collect
(
Collectors
.
toList
());
PermissionExample
permissionExample
=
new
PermissionExample
();
permissionExample
.
createCriteria
().
andIdIn
(
permissionIds
);
List
<
String
>
menuIds
=
permissionMapper
.
selectByExample
(
permissionExample
)
.
stream
().
map
(
Permission:
:
getMenuId
).
collect
(
Collectors
.
toList
());
// List<MenuDto> menus = getMenus(moduleId).stream().filter(x -> permissionNames.contains(x.getName())).collect(Collectors.toList());
return
menuIds
;
}
}
public
List
<
MenuDto
>
getMenus
(
Integer
moduleId
)
{
...
...
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