Former-commit-id: 7dba8c861e0d8e54a5d060e329df2ba178524528
master
wangbing 5 years ago
parent 050bdbd246
commit f09240c4f1

@ -238,6 +238,7 @@ public class SpringBootCallable implements Callable {
}
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("basePackage", project.getProjectBasePackage());
ctx.put("projectName", project.getProjectName());
ctx.put("author", project.getProjectAuthor());
ctx.put("date", new Date());
@ -245,6 +246,7 @@ public class SpringBootCallable implements Callable {
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ActionConfig.java"), option + "/java/config/ActionConfig.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "FreeMarkerConfig.java"), option + "/java/config/FreeMarkerConfig.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "SecurityConfig.java"), option + "/java/config/SecurityConfig.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "SQLiteConfig.java"), option + "/java/config/SQLiteConfig.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "TaskConfig.java"), option + "/java/config/TaskConfig.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "ThreadPoolConfig.java"), option + "/java/config/ThreadPoolConfig.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(root.getAbsolutePath(), "WebMvcConfig.java"), option + "/java/config/WebMvcConfig.java", ctx);
@ -616,7 +618,7 @@ public class SpringBootCallable implements Callable {
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "MapperUtil.java"), option + "/java/frame/utils/MapperUtil.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "MD5Util.java"), option + "/java/frame/utils/MD5Util.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ProcessUtil.java"), option + "/java/frame/utils/ProcessUtil.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ProcessUtil.java"), option + "/java/frame/utils/ProcessUtil.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ResourceUtil.java"), option + "/java/frame/utils/ResourceUtil.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "ResponseUtil.java"), option + "/java/frame/utils/ResponseUtil.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "RSAUtil.java"), option + "/java/frame/utils/RSAUtil.java", ctx);
freeMarkerManager.outputTemp(Tool.createFile(utils.getAbsolutePath(), "StringUtil.java"), option + "/java/frame/utils/StringUtil.java", ctx);
@ -700,20 +702,19 @@ public class SpringBootCallable implements Callable {
try {
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite:" + dbFile.getAbsolutePath());
statement = connection.createStatement();
for (Module module : project.getModules()) {
File tableDir = Tool.createPath(dbtool.getAbsolutePath(), module.getModuleName() + "_table");
File file = Tool.createFile(tableDir.getAbsolutePath(), "ALL_TABLE.sql");
String string = FileUtil.readFileToString(file);
statement.execute(string);
for (File fileModule : dbtool.listFiles()) {
if (!fileModule.isDirectory()) {
continue;
}
for (File file : fileModule.listFiles()) {
if (!file.getName().startsWith("ALL_") && file.getName().endsWith(".sql")) {
statement = connection.createStatement();
String sql = FileUtil.readFileToString(file);
statement.execute(sql);
statement.close();
}
}
{
File tableDir = Tool.createPath(dbtool.getAbsolutePath(),"system");
File file = Tool.createFile(tableDir.getAbsolutePath(), "ALL_TABLE.sql");
String string = FileUtil.readFileToString(file);
statement.execute(string);
}
} catch (ClassNotFoundException | SQLException | IOException e) {
e.printStackTrace();
@ -722,13 +723,13 @@ public class SpringBootCallable implements Callable {
if (statement != null) statement.close();
if (connection != null) connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
{
File system = Tool.createPath(dbtool.getAbsolutePath(), "system");
File system = Tool.createPath(dbtool.getAbsolutePath(), "system_table");
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "ALL_TABLE.sql"), option + "/resources/dbtool/system/ALL_TABLE.sql", ctx);
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DICT.sql"), option + "/resources/dbtool/system/DICT.sql", ctx);
freeMarkerManager.outputTemp(Tool.createFile(system.getAbsolutePath(), "DICT_ITEM.sql"), option + "/resources/dbtool/system/DICT_ITEM.sql", ctx);
@ -740,7 +741,7 @@ public class SpringBootCallable implements Callable {
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("basePackage", project.getProjectBasePackage());
ctx.put("moduleName", project.getProjectName());
ctx.put("projectName", project.getProjectName());
ctx.put("tool", Tool.class);
ctx.put("dataBase", dataBase.toString());
ctx.put("author", project.getProjectAuthor());

@ -12,7 +12,7 @@ public class SQLiteDBmapper extends AbstractDBmapper {
@Override
public String getFieldSql(Field field) {
StringBuffer sb = new StringBuffer("");
sb.append("`").append(field.getFieldName()).append("` ");
sb.append("\"").append(field.getFieldName()).append("\"");
FieldType type = field.getFieldType();

@ -0,0 +1,32 @@
package ${basePackage}.config;
import ${basePackage}.frame.utils.ResourceUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Configuration
public class SQLiteConfig {
@Value("${spring.datasource.url}")
private String url;
@PostConstruct
public void setSharedVariable() {
Pattern compile = Pattern.compile("jdbc:sqlite:(.*.db)");
Matcher matcher = compile.matcher(url);
if (matcher.find()) {
String group = matcher.group(1);
File file = new File(group);
if (!file.exists()) {
File path = file.getAbsoluteFile().getParentFile();
if (!path.exists()) path.mkdirs();
ResourceUtil.copyResource2File("${projectName}.db", file);
}
}
}
}

@ -9,7 +9,7 @@
<#elseif dataBase='MySQL'>
<sql id="table">`${module.modulePrefix?default("")}${table.tableName}`</sql>
<#elseif dataBase='SQLite'>
<sql id="table">${module.modulePrefix?default("")}${table.tableName}</sql>
<sql id="table">"${module.modulePrefix?default("")}${table.tableName}"</sql>
</#if>
<sql id="entityColumnList">
@ -18,7 +18,7 @@
<#elseif dataBase='MySQL'>
<#list table.fields as f>`${f.fieldName}`<#if f_has_next>,</#if></#list>
<#elseif dataBase='SQLite'>
<#list table.fields as f>${f.fieldName}<#if f_has_next>,</#if></#list>
<#list table.fields as f>"${f.fieldName}"<#if f_has_next>,</#if></#list>
</#if>
</sql>
@ -39,7 +39,7 @@
<#elseif dataBase='MySQL'>
`IS_DELETED` = 0
<#elseif dataBase='SQLite'>
IS_DELETED = 0
"IS_DELETED" = 0
</#if>
<#list table.fields as f>
<#if f.isQuery>

@ -40,7 +40,7 @@ mybatis.configuration.map-underscore-to-camel-case=true
<#if dataBase == 'SQLite'>
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.url=jdbc:sqlite:./example.db
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db
spring.datasource.username=test
spring.datasource.password=123456
# mybatis

@ -40,7 +40,7 @@ mybatis.configuration.map-underscore-to-camel-case=true
<#if dataBase == 'SQLite'>
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.url=jdbc:sqlite:./example.db
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db
spring.datasource.username=test
spring.datasource.password=123456
# mybatis

@ -172,26 +172,67 @@ COMMENT ON COLUMN "SYS_FILE"."LAST_UPDATE_BY" is '最后更新用户';
COMMENT ON COLUMN "SYS_FILE"."LAST_UPDATE_TIME" is '最后更新时间';
</#if>
<#if dataBase == 'SQLite'>
-- ----------------------------
-- Table structure for DICT - 字典
-- Target : SQLite
-- Author : wangbing
-- Date: : 2019-12-16
-- ----------------------------
CREATE TABLE IF NOT EXISTS "SYS_DICT" (
"ID" BIGINT PRIMARY KEY NOT NULL,
"DICT_NAME" VARCHAR(50) NOT NULL,
"DICT_COMMENT" VARCHAR(50) NOT NULL,
"VERSION" VARCHAR(50) NOT NULL,
"VALID" BOOLEAN NOT NULL,
"ROW_VERSION" BIGINT NOT NULL,
"IS_DELETED" BOOLEAN NOT NULL,
"CREATE_BY" BIGINT NOT NULL,
"CREATE_TIME" DATETIME NOT NULL,
"LAST_UPDATE_BY" BIGINT,
"LAST_UPDATE_TIME" DATETIME
);
-- ----------------------------
-- Table structure for DICT_ITEM - 字典项
-- Target : SQLite
-- Author : wangbing
-- Date: : 2019-12-16
-- ----------------------------
CREATE TABLE IF NOT EXISTS "SYS_DICT_ITEM" (
"ID" BIGINT PRIMARY KEY NOT NULL,
"DICT_NAME" BIGINT NOT NULL,
"KEY" CHAR(10) NOT NULL,
"VALUE" VARCHAR(100) NOT NULL,
"SORT" MEDIUMINT NOT NULL,
"VALID" BOOLEAN NOT NULL,
"ROW_VERSION" BIGINT NOT NULL,
"IS_DELETED" BOOLEAN NOT NULL,
"CREATE_BY" BIGINT NOT NULL,
"CREATE_TIME" DATETIME NOT NULL,
"LAST_UPDATE_BY" BIGINT,
"LAST_UPDATE_TIME" DATETIME
);
-- ----------------------------
-- Table structure for FILE - 文件
-- Target : SQLite
-- Author : wangbing
-- Date: : 2019-12-16
-- ----------------------------
CREATE TABLE IF NOT EXISTS `SYS_FILE` (
`ID` BIGINT PRIMARY KEY NOT NULL,
`NAME` VARCHAR(250),
`FILE_TYPE` VARCHAR(10),
`ATTRIBUTE1` VARCHAR(50),
`ATTRIBUTE2` VARCHAR(50),
`LOCATION` VARCHAR(500),
`URL` VARCHAR(500),
`URL_DOWNLOAD` VARCHAR(500),
`ROW_VERSION` BIGINT NOT NULL,
`IS_DELETED` BOOLEAN NOT NULL,
`CREATE_BY` BIGINT NOT NULL,
`CREATE_TIME` DATETIME NOT NULL,
`LAST_UPDATE_BY` BIGINT,
`LAST_UPDATE_TIME` DATETIME
CREATE TABLE IF NOT EXISTS "SYS_FILE" (
"ID" BIGINT PRIMARY KEY NOT NULL,
"NAME" VARCHAR(250),
"FILE_TYPE" VARCHAR(10),
"ATTRIBUTE1" VARCHAR(50),
"ATTRIBUTE2" VARCHAR(50),
"LOCATION" VARCHAR(500),
"URL" VARCHAR(500),
"URL_DOWNLOAD" VARCHAR(500),
"ROW_VERSION" BIGINT NOT NULL,
"IS_DELETED" BOOLEAN NOT NULL,
"CREATE_BY" BIGINT NOT NULL,
"CREATE_TIME" DATETIME NOT NULL,
"LAST_UPDATE_BY" BIGINT,
"LAST_UPDATE_TIME" DATETIME
);
</#if>

@ -61,17 +61,17 @@ COMMENT ON COLUMN "SYS_DICT"."LAST_UPDATE_TIME" is '最后更新时间';
-- Author : wangbing
-- Date: : 2019-12-16
-- ----------------------------
CREATE TABLE IF NOT EXISTS `SYS_DICT` (
`ID` BIGINT PRIMARY KEY NOT NULL,
`DICT_NAME` VARCHAR(50) NOT NULL,
`DICT_COMMENT` VARCHAR(50) NOT NULL,
`VERSION` VARCHAR(50) NOT NULL,
`VALID` BOOLEAN NOT NULL,
`ROW_VERSION` BIGINT NOT NULL,
`IS_DELETED` BOOLEAN NOT NULL,
`CREATE_BY` BIGINT NOT NULL,
`CREATE_TIME` DATETIME NOT NULL,
`LAST_UPDATE_BY` BIGINT,
`LAST_UPDATE_TIME` DATETIME
CREATE TABLE IF NOT EXISTS "SYS_DICT" (
"ID" BIGINT PRIMARY KEY NOT NULL,
"DICT_NAME" VARCHAR(50) NOT NULL,
"DICT_COMMENT" VARCHAR(50) NOT NULL,
"VERSION" VARCHAR(50) NOT NULL,
"VALID" BOOLEAN NOT NULL,
"ROW_VERSION" BIGINT NOT NULL,
"IS_DELETED" BOOLEAN NOT NULL,
"CREATE_BY" BIGINT NOT NULL,
"CREATE_TIME" DATETIME NOT NULL,
"LAST_UPDATE_BY" BIGINT,
"LAST_UPDATE_TIME" DATETIME
);
</#if>

@ -64,18 +64,18 @@ COMMENT ON COLUMN "SYS_DICT_ITEM"."LAST_UPDATE_TIME" is '最后更新时间';
-- Author : wangbing
-- Date: : 2019-12-16
-- ----------------------------
CREATE TABLE IF NOT EXISTS `SYS_DICT_ITEM` (
`ID` BIGINT PRIMARY KEY NOT NULL,
`DICT_NAME` BIGINT NOT NULL,
`KEY` CHAR(10) NOT NULL,
`VALUE` VARCHAR(100) NOT NULL,
`SORT` MEDIUMINT NOT NULL,
`VALID` BOOLEAN NOT NULL,
`ROW_VERSION` BIGINT NOT NULL,
`IS_DELETED` BOOLEAN NOT NULL,
`CREATE_BY` BIGINT NOT NULL,
`CREATE_TIME` DATETIME NOT NULL,
`LAST_UPDATE_BY` BIGINT,
`LAST_UPDATE_TIME` DATETIME
CREATE TABLE IF NOT EXISTS "SYS_DICT_ITEM" (
"ID" BIGINT PRIMARY KEY NOT NULL,
"DICT_NAME" BIGINT NOT NULL,
"KEY" CHAR(10) NOT NULL,
"VALUE" VARCHAR(100) NOT NULL,
"SORT" MEDIUMINT NOT NULL,
"VALID" BOOLEAN NOT NULL,
"ROW_VERSION" BIGINT NOT NULL,
"IS_DELETED" BOOLEAN NOT NULL,
"CREATE_BY" BIGINT NOT NULL,
"CREATE_TIME" DATETIME NOT NULL,
"LAST_UPDATE_BY" BIGINT,
"LAST_UPDATE_TIME" DATETIME
);
</#if>

@ -70,20 +70,20 @@ COMMENT ON COLUMN "SYS_FILE"."LAST_UPDATE_TIME" is '最后更新时间';
-- Author : wangbing
-- Date: : 2019-12-16
-- ----------------------------
CREATE TABLE IF NOT EXISTS `SYS_FILE` (
`ID` BIGINT PRIMARY KEY NOT NULL,
`NAME` VARCHAR(250),
`FILE_TYPE` VARCHAR(10),
`ATTRIBUTE1` VARCHAR(50),
`ATTRIBUTE2` VARCHAR(50),
`LOCATION` VARCHAR(500),
`URL` VARCHAR(500),
`URL_DOWNLOAD` VARCHAR(500),
`ROW_VERSION` BIGINT NOT NULL,
`IS_DELETED` BOOLEAN NOT NULL,
`CREATE_BY` BIGINT NOT NULL,
`CREATE_TIME` DATETIME NOT NULL,
`LAST_UPDATE_BY` BIGINT,
`LAST_UPDATE_TIME` DATETIME
CREATE TABLE IF NOT EXISTS "SYS_FILE" (
"ID" BIGINT PRIMARY KEY NOT NULL,
"NAME" VARCHAR(250),
"FILE_TYPE" VARCHAR(10),
"ATTRIBUTE1" VARCHAR(50),
"ATTRIBUTE2" VARCHAR(50),
"LOCATION" VARCHAR(500),
"URL" VARCHAR(500),
"URL_DOWNLOAD" VARCHAR(500),
"ROW_VERSION" BIGINT NOT NULL,
"IS_DELETED" BOOLEAN NOT NULL,
"CREATE_BY" BIGINT NOT NULL,
"CREATE_TIME" DATETIME NOT NULL,
"LAST_UPDATE_BY" BIGINT,
"LAST_UPDATE_TIME" DATETIME
);
</#if>

@ -39,7 +39,7 @@ PRIMARY KEY (`ID`)
-- Author : ${author}
-- Date: : ${date?string("yyyy-MM-dd")}
-- ----------------------------
CREATE TABLE IF NOT EXISTS `${module.modulePrefix?default("")}${table.tableName}` (
CREATE TABLE IF NOT EXISTS ${module.modulePrefix?default("")}${table.tableName} (
<#list table.fields as field>
${dBmapper.getFieldSql(field)}<#if field_has_next>,</#if>
</#list>

@ -44,7 +44,7 @@ PRIMARY KEY (`ID`)
-- Author : ${author}
-- Date: : ${date?string("yyyy-MM-dd")}
-- ----------------------------
CREATE TABLE IF NOT EXISTS `${module.modulePrefix?default("")}${table.tableName}` (
CREATE TABLE IF NOT EXISTS ${module.modulePrefix?default("")}${table.tableName} (
<#list table.fields as field>
${dBmapper.getFieldSql(field)}<#if field_has_next>,</#if>
</#list>

@ -40,7 +40,7 @@ mybatis.configuration.map-underscore-to-camel-case=true
<#if dataBase == 'SQLite'>
# SQLite spring.datasource.url=jdbc:sqlite::resource:example.db
spring.datasource.driver-class-name=org.sqlite.JDBC
spring.datasource.url=jdbc:sqlite:./example.db
spring.datasource.url=jdbc:sqlite:${projectName?default("SpringBoot")}.db
spring.datasource.username=test
spring.datasource.password=123456
# mybatis

Loading…
Cancel
Save

Powered by TurnKey Linux.