Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vehicle-quality-review
Project
Project
Details
Activity
Releases
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
王飞
vehicle-quality-review
Commits
5d1f63ec
Commit
5d1f63ec
authored
Mar 07, 2024
by
王飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、修改日志级别为INFO
2、处理%转意
parent
13cc92c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
4 deletions
+77
-4
logback.xml
ruoyi-admin/src/main/resources/logback.xml
+4
-4
MybatisPlusConfig.java
...in/java/com/ruoyi/framework/config/MybatisPlusConfig.java
+13
-0
PercentEscapeInterceptor.java
.../com/ruoyi/framework/config/PercentEscapeInterceptor.java
+60
-0
No files found.
ruoyi-admin/src/main/resources/logback.xml
View file @
5d1f63ec
...
@@ -89,16 +89,16 @@
...
@@ -89,16 +89,16 @@
</appender>
</appender>
<!-- 系统模块日志级别控制 -->
<!-- 系统模块日志级别控制 -->
<logger
name=
"com.ruoyi"
level=
"
debug
"
/>
<logger
name=
"com.ruoyi"
level=
"
INFO
"
/>
<!-- Spring日志级别控制 -->
<!-- Spring日志级别控制 -->
<logger
name=
"org.springframework"
level=
"warn"
/>
<logger
name=
"org.springframework"
level=
"warn"
/>
<root
level=
"
debug
"
>
<root
level=
"
INFO
"
>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"console"
/>
</root>
</root>
<!--系统操作日志-->
<!--系统操作日志-->
<root
level=
"
debug
"
>
<root
level=
"
INFO
"
>
<appender-ref
ref=
"file_info"
/>
<appender-ref
ref=
"file_info"
/>
<appender-ref
ref=
"file_error"
/>
<appender-ref
ref=
"file_error"
/>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"console"
/>
...
@@ -106,7 +106,7 @@
...
@@ -106,7 +106,7 @@
</root>
</root>
<!--系统用户操作日志-->
<!--系统用户操作日志-->
<logger
name=
"sys-user"
level=
"
debug
"
>
<logger
name=
"sys-user"
level=
"
INFO
"
>
<appender-ref
ref=
"sys-user"
/>
<appender-ref
ref=
"sys-user"
/>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"console"
/>
</logger>
</logger>
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/config/MybatisPlusConfig.java
View file @
5d1f63ec
...
@@ -26,6 +26,9 @@ public class MybatisPlusConfig
...
@@ -26,6 +26,9 @@ public class MybatisPlusConfig
interceptor
.
addInnerInterceptor
(
optimisticLockerInnerInterceptor
());
interceptor
.
addInnerInterceptor
(
optimisticLockerInnerInterceptor
());
// 阻断插件
// 阻断插件
interceptor
.
addInnerInterceptor
(
blockAttackInnerInterceptor
());
interceptor
.
addInnerInterceptor
(
blockAttackInnerInterceptor
());
// %转意
interceptor
.
addInnerInterceptor
(
percentEscapeInterceptor
());
return
interceptor
;
return
interceptor
;
}
}
...
@@ -57,4 +60,14 @@ public class MybatisPlusConfig
...
@@ -57,4 +60,14 @@ public class MybatisPlusConfig
{
{
return
new
BlockAttackInnerInterceptor
();
return
new
BlockAttackInnerInterceptor
();
}
}
/**
* %转意
* @return
*/
public
PercentEscapeInterceptor
percentEscapeInterceptor
()
{
return
new
PercentEscapeInterceptor
();
}
}
}
\ No newline at end of file
ruoyi-framework/src/main/java/com/ruoyi/framework/config/PercentEscapeInterceptor.java
0 → 100644
View file @
5d1f63ec
package
com
.
ruoyi
.
framework
.
config
;
import
com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.apache.ibatis.executor.Executor
;
import
org.apache.ibatis.mapping.BoundSql
;
import
org.apache.ibatis.mapping.MappedStatement
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.apache.ibatis.session.ResultHandler
;
import
org.apache.ibatis.session.RowBounds
;
import
java.sql.SQLException
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
PercentEscapeInterceptor
implements
InnerInterceptor
{
@Override
public
void
beforeQuery
(
Executor
executor
,
MappedStatement
ms
,
Object
parameter
,
RowBounds
rowBounds
,
ResultHandler
resultHandler
,
BoundSql
boundSql
)
throws
SQLException
{
String
sql
=
boundSql
.
getSql
().
toLowerCase
();
// 判断是否包含 参数 及 like 查询
if
(!
sql
.
contains
(
" like "
)
||
!
sql
.
contains
(
"?"
))
{
return
;
}
// 获取关键字的个数(去重),获取 到 like 查询 的 key
String
[]
strList
=
sql
.
split
(
"\\?"
);
Set
<
String
>
keyNames
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
strList
.
length
;
i
++)
{
if
(
strList
[
i
].
toLowerCase
().
contains
(
" like "
))
{
String
keyName
=
boundSql
.
getParameterMappings
().
get
(
i
).
getProperty
();
keyNames
.
add
(
keyName
);
}
}
MetaObject
metaObject
=
ms
.
getConfiguration
().
newMetaObject
(
parameter
);
for
(
String
keyName
:
keyNames
)
{
Object
value
=
metaObject
.
getValue
(
keyName
);
if
(
value
instanceof
String
)
{
if
(
isconvert
((
String
)
value
))
{
metaObject
.
setValue
(
keyName
,
convert
((
String
)
value
));
}
}
}
}
private
String
convert
(
String
before
)
{
if
(
StringUtils
.
isNotBlank
(
before
))
{
before
=
before
.
replaceAll
(
"\\\\"
,
""
);
before
=
before
.
replaceAll
(
"_"
,
"\\\\_"
);
before
=
before
.
replaceAll
(
"%"
,
"\\\\%"
);
}
return
before
;
}
private
boolean
isconvert
(
String
str
)
{
return
str
.
contains
(
"\\"
)
||
str
.
contains
(
"_"
)
||
str
.
contains
(
"%"
);
}
}
\ No newline at end of file
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