Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
0c2a628c
Commit
0c2a628c
authored
Jun 13, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expose find role by role name
parent
59ad9e90
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
RolePermissionService.java
...ramework/apollo/portal/service/RolePermissionService.java
+11
-4
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/RolePermissionService.java
View file @
0c2a628c
...
...
@@ -49,7 +49,7 @@ public class RolePermissionService {
*/
@Transactional
public
Role
createRoleWithPermissions
(
Role
role
,
Set
<
Long
>
permissionIds
)
{
Role
current
=
roleRepository
.
findTop
ByRoleName
(
role
.
getRoleName
());
Role
current
=
findRole
ByRoleName
(
role
.
getRoleName
());
Preconditions
.
checkState
(
current
==
null
,
"Role %s already exists!"
,
role
.
getRoleName
());
Role
createdRole
=
roleRepository
.
save
(
role
);
...
...
@@ -75,7 +75,7 @@ public class RolePermissionService {
*/
@Transactional
public
void
assignRoleToUsers
(
String
roleName
,
Set
<
String
>
userIds
,
String
operatorUserId
)
{
Role
role
=
roleRepository
.
findTop
ByRoleName
(
roleName
);
Role
role
=
findRole
ByRoleName
(
roleName
);
Preconditions
.
checkState
(
role
!=
null
,
"Role %s doesn't exist!"
,
roleName
);
List
<
UserRole
>
existedUserRoles
=
...
...
@@ -102,7 +102,7 @@ public class RolePermissionService {
*/
@Transactional
public
void
removeRoleFromUsers
(
String
roleName
,
Set
<
String
>
userIds
,
String
operatorUserId
)
{
Role
role
=
roleRepository
.
findTop
ByRoleName
(
roleName
);
Role
role
=
findRole
ByRoleName
(
roleName
);
Preconditions
.
checkState
(
role
!=
null
,
"Role %s doesn't exist!"
,
roleName
);
List
<
UserRole
>
existedUserRoles
=
...
...
@@ -121,7 +121,7 @@ public class RolePermissionService {
* Query users with role
*/
public
Set
<
UserInfo
>
queryUsersWithRole
(
String
roleName
)
{
Role
role
=
roleRepository
.
findTop
ByRoleName
(
roleName
);
Role
role
=
findRole
ByRoleName
(
roleName
);
if
(
role
==
null
)
{
return
Collections
.
emptySet
();
...
...
@@ -139,6 +139,13 @@ public class RolePermissionService {
}
/**
* Find role by role name, note that roleName should be unique
*/
public
Role
findRoleByRoleName
(
String
roleName
)
{
return
roleRepository
.
findTopByRoleName
(
roleName
);
}
/**
* Check whether user has the permission
*/
public
boolean
userHasPermission
(
String
userId
,
String
permissionType
,
String
targetId
)
{
...
...
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