Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
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
西魏
cms_sys
Commits
d68b4dd9
Commit
d68b4dd9
authored
Nov 02, 2020
by
sgjj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整配置
parent
8f5b0adf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
20 deletions
+43
-20
MybatisInterceptorConfig.java
...in/java/net/mingsoft/config/MybatisInterceptorConfig.java
+43
-0
WebConfig.java
src/main/java/net/mingsoft/config/WebConfig.java
+0
-20
No files found.
src/main/java/net/mingsoft/config/MybatisInterceptorConfig.java
0 → 100644
View file @
d68b4dd9
package
net
.
mingsoft
.
config
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler
;
import
com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor
;
import
com.baomidou.mybatisplus.extension.toolkit.JdbcUtils
;
import
net.mingsoft.interceptor.DMInnerInterceptor
;
import
net.mingsoft.interceptor.MysqlInnerInterceptor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
/**
* Mybatis 拦截器配置
*/
@Configuration
public
class
MybatisInterceptorConfig
{
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
(
DataSource
dataSource
,
@Autowired
(
required
=
false
)
TenantLineHandler
tenantLineHandler
)
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
if
(
tenantLineHandler
!=
null
){
interceptor
.
addInnerInterceptor
(
new
TenantLineInnerInterceptor
(
tenantLineHandler
));
}
try
{
//mysql 添加转换sql
DbType
dbType
=
JdbcUtils
.
getDbType
(
dataSource
.
getConnection
().
getMetaData
().
getURL
());
if
(
DbType
.
MYSQL
==
dbType
){
interceptor
.
addInnerInterceptor
(
new
MysqlInnerInterceptor
());
}
else
if
(
DbType
.
DM
==
dbType
){
interceptor
.
addInnerInterceptor
(
new
DMInnerInterceptor
());
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
interceptor
;
}
}
src/main/java/net/mingsoft/config/WebConfig.java
View file @
d68b4dd9
...
@@ -59,26 +59,6 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -59,26 +59,6 @@ public class WebConfig implements WebMvcConfigurer {
return
new
ActionInterceptor
();
return
new
ActionInterceptor
();
}
}
@Bean
public
MybatisPlusInterceptor
mybatisPlusInterceptor
(
DataSource
dataSource
,
@Autowired
(
required
=
false
)
TenantLineHandler
tenantLineHandler
)
{
MybatisPlusInterceptor
interceptor
=
new
MybatisPlusInterceptor
();
if
(
tenantLineHandler
!=
null
){
interceptor
.
addInnerInterceptor
(
new
TenantLineInnerInterceptor
(
tenantLineHandler
));
}
try
{
//mysql 添加转换sql
DbType
dbType
=
JdbcUtils
.
getDbType
(
dataSource
.
getConnection
().
getMetaData
().
getURL
());
if
(
DbType
.
MYSQL
==
dbType
){
interceptor
.
addInnerInterceptor
(
new
MysqlInnerInterceptor
());
}
else
if
(
DbType
.
DM
==
dbType
){
interceptor
.
addInnerInterceptor
(
new
DMInnerInterceptor
());
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
interceptor
;
}
@Bean
@Bean
public
ConfigurationCustomizer
configurationCustomizer
()
{
public
ConfigurationCustomizer
configurationCustomizer
()
{
return
configuration
->
configuration
.
setUseDeprecatedExecutor
(
false
);
return
configuration
->
configuration
.
setUseDeprecatedExecutor
(
false
);
...
...
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