Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yaru
fgqyxxlr
Commits
127b5328
Commit
127b5328
authored
Aug 05, 2018
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
若依 2.3
parent
92fffea4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
16 deletions
+24
-16
src/main/java/com/ruoyi/framework/aspectj/DsAspect.java
+5
-5
src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java
+2
-1
src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java
+15
-8
src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java
+2
-2
No files found.
src/main/java/com/ruoyi/framework/aspectj/DsAspect.java
View file @
127b5328
...
...
@@ -12,7 +12,7 @@ import org.springframework.core.annotation.Order;
import
org.springframework.stereotype.Component
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.framework.aspectj.lang.annotation.Ds
;
import
com.ruoyi.framework.datasource.DataSourceContextHolder
;
import
com.ruoyi.framework.datasource.D
ynamicD
ataSourceContextHolder
;
/**
* 多数据源处理
...
...
@@ -27,12 +27,12 @@ public class DsAspect
protected
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Pointcut
(
"@annotation(com.ruoyi.framework.aspectj.lang.annotation.Ds)"
)
public
void
d
ataSource
PointCut
()
public
void
d
s
PointCut
()
{
}
@Around
(
"d
ataSource
PointCut()"
)
@Around
(
"d
s
PointCut()"
)
public
Object
around
(
ProceedingJoinPoint
point
)
throws
Throwable
{
MethodSignature
signature
=
(
MethodSignature
)
point
.
getSignature
();
...
...
@@ -44,7 +44,7 @@ public class DsAspect
Ds
dataSource
=
method
.
getAnnotation
(
Ds
.
class
);
if
(
StringUtils
.
isNotNull
(
dataSource
)
&&
StringUtils
.
isNotEmpty
(
dataSource
.
name
()))
{
DataSourceContextHolder
.
setDB
(
dataSource
.
name
());
D
ynamicD
ataSourceContextHolder
.
setDB
(
dataSource
.
name
());
}
}
...
...
@@ -54,7 +54,7 @@ public class DsAspect
}
finally
{
DataSourceContextHolder
.
clearDB
();
D
ynamicD
ataSourceContextHolder
.
clearDB
();
}
}
}
src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java
View file @
127b5328
...
...
@@ -21,7 +21,7 @@ public class DynamicDataSource extends AbstractRoutingDataSource
@Override
protected
Object
determineCurrentLookupKey
()
{
return
DataSourceContextHolder
.
getDB
();
return
D
ynamicD
ataSourceContextHolder
.
getDB
();
}
}
\ No newline at end of file
src/main/java/com/ruoyi/framework/datasource/DataSourceContextHolder.java
→
src/main/java/com/ruoyi/framework/datasource/D
ynamicD
ataSourceContextHolder.java
View file @
127b5328
...
...
@@ -8,28 +8,35 @@ import org.slf4j.LoggerFactory;
*
* @author ruoyi
*/
public
class
DataSourceContextHolder
public
class
D
ynamicD
ataSourceContextHolder
{
public
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
DataSourceContextHolder
.
class
);
public
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
D
ynamicD
ataSourceContextHolder
.
class
);
private
static
final
ThreadLocal
<
String
>
contextHolder
=
new
ThreadLocal
<>();
private
static
final
ThreadLocal
<
String
>
CONTEXT_HOLDER
=
new
ThreadLocal
<>();
// 设置数据源名
/**
* 设置数据源名
*/
public
static
void
setDB
(
String
dbType
)
{
log
.
info
(
"切换到{}数据源"
,
dbType
);
contextHolder
.
set
(
dbType
);
CONTEXT_HOLDER
.
set
(
dbType
);
}
// 获取数据源名
/**
* 获取数据源名
*/
public
static
String
getDB
()
{
return
contextHolder
.
get
();
return
CONTEXT_HOLDER
.
get
();
}
/**
* 清理数据源名
*/
public
static
void
clearDB
()
{
contextHolder
.
remove
();
CONTEXT_HOLDER
.
remove
();
}
}
src/main/java/com/ruoyi/project/system/post/mapper/PostMapper.java
View file @
127b5328
...
...
@@ -69,7 +69,7 @@ public interface PostMapper
/**
* 校验岗位名称
*
* @param post
岗位信息
* @param post
Name 岗位名称
* @return 结果
*/
public
Post
checkPostNameUnique
(
String
postName
);
...
...
@@ -77,7 +77,7 @@ public interface PostMapper
/**
* 校验岗位编码
*
* @param post
岗位信息
* @param post
Code 岗位编码
* @return 结果
*/
public
Post
checkPostCodeUnique
(
String
postCode
);
...
...
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