Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
28b9fbb4
Commit
28b9fbb4
authored
Jul 19, 2022
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化多个相同角色数据导致权限SQL重复问题
parent
2c79dc90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
...ain/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
+10
-1
No files found.
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
View file @
28b9fbb4
package
com.ruoyi.framework.aspectj
;
package
com.ruoyi.framework.aspectj
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.aspectj.lang.annotation.Before
;
...
@@ -79,15 +81,21 @@ public class DataScopeAspect
...
@@ -79,15 +81,21 @@ public class DataScopeAspect
*
*
* @param joinPoint 切点
* @param joinPoint 切点
* @param user 用户
* @param user 用户
* @param userAlias 别名
* @param deptAlias 部门别名
* @param userAlias 用户别名
*/
*/
public
static
void
dataScopeFilter
(
JoinPoint
joinPoint
,
SysUser
user
,
String
deptAlias
,
String
userAlias
)
public
static
void
dataScopeFilter
(
JoinPoint
joinPoint
,
SysUser
user
,
String
deptAlias
,
String
userAlias
)
{
{
StringBuilder
sqlString
=
new
StringBuilder
();
StringBuilder
sqlString
=
new
StringBuilder
();
List
<
String
>
conditions
=
new
ArrayList
<
String
>();
for
(
SysRole
role
:
user
.
getRoles
())
for
(
SysRole
role
:
user
.
getRoles
())
{
{
String
dataScope
=
role
.
getDataScope
();
String
dataScope
=
role
.
getDataScope
();
if
(
conditions
.
contains
(
dataScope
))
{
continue
;
}
if
(
DATA_SCOPE_ALL
.
equals
(
dataScope
))
if
(
DATA_SCOPE_ALL
.
equals
(
dataScope
))
{
{
sqlString
=
new
StringBuilder
();
sqlString
=
new
StringBuilder
();
...
@@ -121,6 +129,7 @@ public class DataScopeAspect
...
@@ -121,6 +129,7 @@ public class DataScopeAspect
sqlString
.
append
(
StringUtils
.
format
(
" OR {}.dept_id = 0 "
,
deptAlias
));
sqlString
.
append
(
StringUtils
.
format
(
" OR {}.dept_id = 0 "
,
deptAlias
));
}
}
}
}
conditions
.
add
(
dataScope
);
}
}
if
(
StringUtils
.
isNotBlank
(
sqlString
.
toString
()))
if
(
StringUtils
.
isNotBlank
(
sqlString
.
toString
()))
...
...
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