Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
work_service
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
work_service
Commits
efd6b198
Commit
efd6b198
authored
Mar 17, 2021
by
cq990612
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码结构
parent
25e74661
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
WorkRole.java
...-model/src/main/java/cn/wisenergy/model/app/WorkRole.java
+1
-1
WorkUserServiceImpl.java
...n/java/cn/wisenergy/service/impl/WorkUserServiceImpl.java
+1
-1
UserRoleLevelUtils.java
...n/java/cn/wisenergy/service/utils/UserRoleLevelUtils.java
+10
-8
No files found.
wisenergy-model/src/main/java/cn/wisenergy/model/app/WorkRole.java
View file @
efd6b198
...
...
@@ -19,6 +19,6 @@ public class WorkRole {
@ApiModelProperty
(
name
=
"name"
,
value
=
"角色名"
)
private
String
name
;
@ApiModelProperty
(
name
=
"onlyOne"
,
value
=
"
是否只能有一个:0:多个,1:一个
"
)
@ApiModelProperty
(
name
=
"onlyOne"
,
value
=
"
大于0且相同就重复
"
)
private
Integer
onlyOne
;
}
wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkUserServiceImpl.java
View file @
efd6b198
...
...
@@ -215,7 +215,7 @@ public class WorkUserServiceImpl implements WorkUserService {
if
(
CollectionUtils
.
isEmpty
(
roleIds
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
CHOOSEATLEASTONEROLE
);
}
if
(
UserRoleLevelUtils
.
level
IsRepeat
(
roleIds
))
{
if
(
UserRoleLevelUtils
.
role
IsRepeat
(
roleIds
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
DUPLICATEROLEPERMISSIONS
);
}
if
(
null
==
userId
)
{
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/utils/UserRoleLevelUtils.java
View file @
efd6b198
...
...
@@ -163,17 +163,19 @@ public class UserRoleLevelUtils {
/**
* 判断权限是否重复
*/
public
static
Boolean
level
IsRepeat
(
List
<
Integer
>
roles
)
{
public
static
Boolean
role
IsRepeat
(
List
<
Integer
>
roles
)
{
if
(
CollectionUtils
.
isEmpty
(
roles
))
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
ROLE_CANNOTBE_EMPTY
);
}
List
<
Integer
>
getlevelIds
=
getlevelIds
(
roles
);
Set
<
Integer
>
hashSet
=
new
HashSet
<>();
if
(!
CollectionUtils
.
isEmpty
(
getlevelIds
))
{
for
(
Integer
id
:
getlevelIds
)
{
if
(!
hashSet
.
add
(
id
)){
//有重复值
return
true
;
List
<
WorkRole
>
workRoles
=
utils
.
workRoleMapper
.
selectBatchIds
(
roles
);
if
(
CollectionUtils
.
isEmpty
(
workRoles
))
{
Set
<
Integer
>
hashSet
=
new
HashSet
<>();
for
(
WorkRole
workRole
:
workRoles
)
{
if
(
workRole
.
getOnlyOne
()>
0
)
{
if
(!
hashSet
.
add
(
workRole
.
getOnlyOne
())){
//有重复值
return
true
;
}
}
}
}
...
...
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