Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
aserver
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
15所TongWeb
aserver
Commits
a3606b89
Commit
a3606b89
authored
Mar 19, 2021
by
胡文斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
构建实体类之前执行数据库升级语句
parent
91046688
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
11 deletions
+30
-11
pom.xml
pom.xml
+0
-0
MainConfig.java
...in/java/com/archser/aserver/common/config/MainConfig.java
+2
-11
DBUpgrade.java
.../com/archser/aserver/common/config/plugins/DBUpgrade.java
+28
-0
No files found.
pom.xml
View file @
a3606b89
This diff is collapsed.
Click to expand it.
src/main/java/com/archser/aserver/common/config/MainConfig.java
View file @
a3606b89
package
com
.
archser
.
aserver
.
common
.
config
;
import
com.alibaba.druid.filter.stat.StatFilter
;
import
com.archser.aserver.common.config.plugins.DBUpgrade
;
import
com.archser.aserver.common.config.plugins.RedisConfig
;
import
com.archser.aserver.controller.*
;
import
com.archser.aserver.interceptor.JwtInterceptor
;
import
com.archser.aserver.itask.GoodSync
;
import
com.archser.aserver.model._MappingKit
;
import
com.archser.aserver.service.DBService
;
import
com.archser.aserver.util.SharedDisk
;
import
com.archser.aserver.websocket.MessageWebSocket
;
import
com.jfinal.config.*
;
...
...
@@ -167,6 +167,7 @@ public class MainConfig extends JFinalConfig {
arp
.
setContainerFactory
(
new
CaseInsensitiveContainerFactory
(
true
));
arp
.
setDialect
(
DialectFactory
.
getDialect
());
arp
.
addSqlTemplate
(
"oracle.sql"
);
arp
.
setTableBuilderHandler
(
new
DBUpgrade
());
/******** 在此添加数据库 表-Model 映射 *********/
// 如果使用了JFinal Model 生成器 生成了BaseModel 把下面注释解开即可
_MappingKit
.
mapping
(
arp
);
...
...
@@ -209,16 +210,6 @@ public class MainConfig extends JFinalConfig {
*/
@Override
public
void
onStart
()
{
String
dbType
=
p
.
get
(
"dbType"
);
if
(
dbType
==
null
||
""
.
equals
(
dbType
.
trim
()))
{
System
.
out
.
println
(
"数据库配置文件中dbType不能为空值"
);
return
;
}
dbType
=
dbType
.
trim
();
dbType
=
dbType
.
toUpperCase
();
String
configPath
=
PathKit
.
getRootClassPath
()
+
"/DBUpdate/"
;
DBService
dbService
=
new
DBService
();
dbService
.
upgrade
(
configPath
,
dbType
);
new
GoodSync
().
run
();
}
...
...
src/main/java/com/archser/aserver/common/config/plugins/DBUpgrade.java
0 → 100644
View file @
a3606b89
package
com
.
archser
.
aserver
.
common
.
config
.
plugins
;
import
com.archser.aserver.service.DBService
;
import
com.jfinal.kit.PathKit
;
import
com.jfinal.kit.PropKit
;
import
com.jfinal.plugin.activerecord.ITableBuilderHandler
;
/**
* 执行数据库升级语句
* @Auther: huwenbin
* @Date: 2021/3/19 10:06
*/
public
class
DBUpgrade
implements
ITableBuilderHandler
{
@Override
public
void
beforeBuilder
()
{
String
dbType
=
PropKit
.
get
(
"dbType"
);
if
(
dbType
==
null
||
""
.
equals
(
dbType
.
trim
()))
{
System
.
out
.
println
(
"数据库配置文件中dbType不能为空值"
);
throw
new
RuntimeException
(
"数据库配置文件中dbType不能为空值"
);
}
dbType
=
dbType
.
trim
();
dbType
=
dbType
.
toUpperCase
();
String
configPath
=
PathKit
.
getRootClassPath
()
+
"/DBUpdate/"
;
DBService
dbService
=
new
DBService
();
dbService
.
upgrade
(
configPath
,
dbType
);
}
}
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