Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
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
s_guodong
gjjs-bd-common
Commits
99297dde
Commit
99297dde
authored
May 30, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update-多数据源切换
parent
d9de10b4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
+23
-11
Platform.java
...iness/src/main/java/com/ceb/gjjs/mda/global/Platform.java
+2
-9
MdaContext.java
...ava/com/brilliance/mda/runtime/mda/driver/MdaContext.java
+21
-2
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/global/Platform.java
View file @
99297dde
...
...
@@ -1509,8 +1509,6 @@ public class Platform {
ctx
.
setErrorCode
(
NO_ERROR
);
if
(
db
!=
null
)
{
ctx
.
storeData
(
"LastDB."
+
Platform
.
getModuleRoot
(),
db
);
DynamicDataSourceContextHolder
.
setDataSourceType
(
db
);
}
}
...
...
@@ -1589,7 +1587,6 @@ public class Platform {
ctx
.
setErrorCode
(
NO_ERROR
);
String
tableName
=
MdaUtils
.
getTableNameFromSQL
(
sql
);
String
tableDB
=
Platform
.
getTableDB
(
tableName
);
// Platform.setDefaultDB(tableDB);
DynamicDataSourceContextHolder
.
setDataSourceType
(
tableDB
);
ctx
.
getDaoSession
().
dbExecuteSQL
(
sql
);
}
...
...
@@ -1641,7 +1638,7 @@ public class Platform {
//取得上下文
IContext
ctx
=
MdaEnv
.
getContext
();
ctx
.
setErrorCode
(
NO_ERROR
);
String
db
=
(
String
)
Platform
.
getStoredData
(
"DefaultDB."
+
Platform
.
getModuleRoot
()
.
getClass
()
+
MdaEnv
.
getLoginUser
()
);
String
db
=
(
String
)
Platform
.
getStoredData
(
"DefaultDB."
+
Platform
.
getModuleRoot
());
if
(
db
==
null
)
{
//从前手交易获取默认数据库
String
caller
=
(
String
)
ctx
.
restoreData
(
ctx
.
getTransName
()
+
".caller"
);
...
...
@@ -1702,8 +1699,7 @@ public class Platform {
IContext
ctx
=
MdaEnv
.
getContext
();
ctx
.
setErrorCode
(
NO_ERROR
);
if
(
db
!=
null
)
{
ctx
.
storeData
(
"DefaultDB."
+
Platform
.
getModuleRoot
().
getClass
()
+
MdaEnv
.
getLoginUser
(),
db
);
DynamicDataSourceContextHolder
.
setDataSourceType
(
db
);
ctx
.
storeData
(
"DefaultDB."
+
Platform
.
getModuleRoot
(),
db
);
log
.
debug
(
"{}"
,
"DefaultDB change to "
+
db
);
}
}
...
...
@@ -1780,7 +1776,6 @@ public class Platform {
ctx
.
setErrorCode
(
NO_ERROR
);
// 切换数据源
String
moduleDB
=
Platform
.
getModuleDB
(
module
);
//Platform.setDefaultDB(moduleDB);
DynamicDataSourceContextHolder
.
setDataSourceType
(
moduleDB
);
ctx
.
getDaoSession
().
dbRead
(
module
,
arguments
);
}
...
...
@@ -1884,7 +1879,6 @@ public class Platform {
ctx
.
setErrorCode
(
NO_ERROR
);
// 切换数据源
String
db
=
Platform
.
getModuleListsDB
(
lists
);
// Platform.setDefaultDB(db);
DynamicDataSourceContextHolder
.
setDataSourceType
(
db
);
ctx
.
getDaoSession
().
dbReadset
(
lists
,
maxSize
,
whereClause
,
datas
);
}
...
...
@@ -2019,7 +2013,6 @@ public class Platform {
ctx
.
setErrorCode
(
NO_ERROR
);
String
tableName
=
MdaUtils
.
getTableNameFromSQL
(
sql
);
String
tableDB
=
Platform
.
getTableDB
(
tableName
);
// Platform.setDefaultDB(tableDB);
DynamicDataSourceContextHolder
.
setDataSourceType
(
tableDB
);
ctx
.
getDaoSession
().
dbExecuteSQL
(
sql
,
value
);
}
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/MdaContext.java
View file @
99297dde
...
...
@@ -3,6 +3,7 @@ package com.brilliance.mda.runtime.mda.driver;
import
com.brilliance.mda.runtime.annotation.Transaction
;
import
com.brilliance.mda.runtime.mda.*
;
import
com.brilliance.mda.runtime.mda.impl.EnvConfig
;
import
com.brilliance.mda.runtime.request.BaseVO
;
import
java.util.*
;
...
...
@@ -17,6 +18,7 @@ public class MdaContext implements IContext {
private
transient
final
ILocker
locker
;
private
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
private
Map
<
String
,
Object
>
globleParams
=
new
HashMap
<
String
,
Object
>();
private
String
displayStr
;
private
transient
IRuleEmitter
emmiter
;
...
...
@@ -206,11 +208,28 @@ public class MdaContext implements IContext {
}
public
Object
restoreData
(
String
key
)
{
return
this
.
params
.
get
(
key
);
Object
o
=
this
.
params
.
get
(
key
);
if
(
o
==
null
&&
key
.
startsWith
(
"DefaultDB."
))
{
IContext
ctx
=
MdaEnv
.
getContext
();
BaseVO
baseVO
=
(
BaseVO
)
ctx
.
restoreData
(
IContext
.
DISPLAY_KEY
);
if
(
baseVO
!=
null
)
{
String
substring
=
key
.
substring
(
0
,
key
.
indexOf
(
"@"
));
return
this
.
globleParams
.
get
(
substring
+
baseVO
.
getPageId
());
}
}
return
o
;
}
@Override
public
void
storeData
(
String
key
,
Object
data
)
{
if
(
key
.
startsWith
(
"DefaultDB."
))
{
IContext
ctx
=
MdaEnv
.
getContext
();
BaseVO
baseVO
=
(
BaseVO
)
ctx
.
restoreData
(
IContext
.
DISPLAY_KEY
);
if
(
baseVO
!=
null
)
{
String
substring
=
key
.
substring
(
0
,
key
.
indexOf
(
"@"
));
this
.
globleParams
.
put
(
substring
+
baseVO
.
getPageId
(),
data
);
}
}
this
.
params
.
put
(
key
,
data
);
}
...
...
@@ -349,7 +368,7 @@ public class MdaContext implements IContext {
@Override
public
void
resetParams
(
Map
<
String
,
Object
>
params
)
{
//
this.params.clear();
this
.
params
.
clear
();
if
(
params
!=
null
)
this
.
params
.
putAll
(
params
);
}
...
...
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