Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
GeoFlyApi
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GeoFly
GeoFlyApi
Commits
325116da
Commit
325116da
authored
Jun 21, 2025
by
gdj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加项目管理员枚举类。
parent
40dd3182
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
3 deletions
+53
-3
sample/src/main/java/com/dji/sample/common/util/SecurityUtils.java
+45
-3
sample/src/main/java/com/dji/sample/manage/model/enums/RoleTypeEnum.java
+5
-0
sample/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java
+3
-0
No files found.
sample/src/main/java/com/dji/sample/common/util/SecurityUtils.java
View file @
325116da
...
...
@@ -118,6 +118,24 @@ public class SecurityUtils {
public
static
boolean
isNotAdminRole
()
{
return
!
isAdminRole
();
}
public
static
boolean
isProjectAdminRole
(
Integer
roleType
)
{
return
roleType
==
RoleTypeEnum
.
PROJECT_ADMIN
.
getVal
();
}
public
static
boolean
isNotProjectAdminRole
(
Integer
roleType
)
{
return
!
isProjectAdminRole
(
roleType
);
}
public
static
boolean
isProjectAdminRole
()
{
Integer
roleType
=
getRoleType
();
return
isProjectAdminRole
(
roleType
);
}
public
static
boolean
isNotProjectAdminRole
()
{
return
!
isProjectAdminRole
();
}
public
static
boolean
isAdminRole
(
Integer
roleType
)
{
return
roleType
==
RoleTypeEnum
.
ADMIN
.
getVal
();
}
...
...
@@ -171,7 +189,7 @@ public class SecurityUtils {
return
aboveMemberRole
(
roleType
);
}
public
static
boolean
aboveMemberRole
(
Integer
roleType
)
{
int
[]
roleArr
=
{
RoleTypeEnum
.
MEMBER
.
getVal
(),
RoleTypeEnum
.
PILOT
.
getVal
(),
RoleTypeEnum
.
ADMIN
.
getVal
(),
RoleTypeEnum
.
SYS_ADMIN
.
getVal
()};
int
[]
roleArr
=
{
RoleTypeEnum
.
MEMBER
.
getVal
(),
RoleTypeEnum
.
PILOT
.
getVal
(),
RoleTypeEnum
.
ADMIN
.
getVal
(),
RoleTypeEnum
.
PROJECT_ADMIN
.
getVal
(),
RoleTypeEnum
.
SYS_ADMIN
.
getVal
()};
for
(
int
role
:
roleArr
){
if
(
roleType
==
role
)
{
...
...
@@ -195,7 +213,7 @@ public class SecurityUtils {
}
public
static
boolean
abovePilotRole
(
Integer
roleType
)
{
int
[]
roleArr
=
{
RoleTypeEnum
.
PILOT
.
getVal
(),
RoleTypeEnum
.
ADMIN
.
getVal
(),
RoleTypeEnum
.
SYS_ADMIN
.
getVal
()};
int
[]
roleArr
=
{
RoleTypeEnum
.
PILOT
.
getVal
(),
RoleTypeEnum
.
ADMIN
.
getVal
(),
RoleTypeEnum
.
PROJECT_ADMIN
.
getVal
(),
RoleTypeEnum
.
SYS_ADMIN
.
getVal
()};
for
(
int
role
:
roleArr
){
if
(
roleType
==
role
)
{
...
...
@@ -219,7 +237,7 @@ public class SecurityUtils {
}
public
static
boolean
aboveAdminRole
(
Integer
roleType
)
{
int
[]
roleArr
=
{
RoleTypeEnum
.
ADMIN
.
getVal
(),
RoleTypeEnum
.
SYS_ADMIN
.
getVal
()};
int
[]
roleArr
=
{
RoleTypeEnum
.
ADMIN
.
getVal
(),
RoleTypeEnum
.
PROJECT_ADMIN
.
getVal
(),
RoleTypeEnum
.
SYS_ADMIN
.
getVal
()};
for
(
int
role
:
roleArr
){
if
(
roleType
==
role
)
{
...
...
@@ -229,6 +247,30 @@ public class SecurityUtils {
return
false
;
}
public
static
boolean
aboveProjectAdminRoleAndThrowError
()
{
boolean
result
=
aboveProjectAdminRole
();
if
(!
result
)
{
throw
new
RuntimeException
(
"The current role has no permissions"
);
}
return
true
;
}
public
static
boolean
aboveProjectAdminRole
()
{
Integer
roleType
=
getRoleType
();
return
aboveSysAdminRole
(
roleType
);
}
public
static
boolean
aboveProjectAdminRole
(
Integer
roleType
)
{
int
[]
roleArr
=
{
RoleTypeEnum
.
PROJECT_ADMIN
.
getVal
(),
RoleTypeEnum
.
SYS_ADMIN
.
getVal
()};
for
(
int
role
:
roleArr
)
{
if
(
roleType
==
role
)
{
return
true
;
}
}
return
false
;
}
public
static
boolean
aboveSysAdminRoleAndThrowError
()
{
boolean
result
=
aboveSysAdminRole
();
if
(!
result
)
{
...
...
sample/src/main/java/com/dji/sample/manage/model/enums/RoleTypeEnum.java
View file @
325116da
...
...
@@ -12,6 +12,8 @@ public enum RoleTypeEnum {
PILOT
(
2
,
"飞手"
),
PROJECT_ADMIN
(
50
,
"项目管理员"
),
SYS_ADMIN
(
100
,
"系统管理员"
),
UNKNOWN
(-
1
,
"Unknown"
);
...
...
@@ -37,6 +39,9 @@ public enum RoleTypeEnum {
if
(
val
==
SYS_ADMIN
.
val
)
{
return
SYS_ADMIN
;
}
if
(
val
==
PROJECT_ADMIN
.
val
)
{
return
PROJECT_ADMIN
;
}
if
(
val
==
ADMIN
.
val
)
{
return
ADMIN
;
}
...
...
sample/src/main/java/com/dji/sample/manage/service/impl/UserServiceImpl.java
View file @
325116da
...
...
@@ -202,6 +202,9 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, UserEntity> implem
// throw new RuntimeException("Failed to delete admin");
// }
// 然后 假如是删除管理员 不能删除 项目管理员
if
(
userEntity
.
getRoleType
()
==
RoleTypeEnum
.
PROJECT_ADMIN
.
getVal
())
{
throw
new
RuntimeException
(
"can't delete workspace project admin"
);
}
if
(
userEntity
.
getRoleType
()
==
RoleTypeEnum
.
ADMIN
.
getVal
())
{
LambdaQueryWrapper
<
WorkspaceEntity
>
workspaceWrapper
=
new
LambdaQueryWrapper
<>();
workspaceWrapper
.
eq
(
WorkspaceEntity:
:
getAdminUserId
,
userEntity
.
getUserId
());
...
...
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