|
@@ -19,7 +19,9 @@ import org.geek.szbay.assistant.code.generator.EntityMysqlMaker;
|
|
import org.geek.szbay.assistant.code.generator.MapperXmlMaker;
|
|
import org.geek.szbay.assistant.code.generator.MapperXmlMaker;
|
|
import org.geek.szbay.assistant.code.generator.ServiceImplMysqlMaker;
|
|
import org.geek.szbay.assistant.code.generator.ServiceImplMysqlMaker;
|
|
import org.geek.szbay.assistant.code.generator.ServiceMysqlMaker;
|
|
import org.geek.szbay.assistant.code.generator.ServiceMysqlMaker;
|
|
|
|
+import org.geek.szbay.assistant.code.generator.UpdateFtlMaker;
|
|
import org.geek.szbay.assistant.code.generator.helpper.TableHelpper;
|
|
import org.geek.szbay.assistant.code.generator.helpper.TableHelpper;
|
|
|
|
+import org.geek.szbay.assistant.utils.StringUtils;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author wutianbin
|
|
* @author wutianbin
|
|
@@ -28,18 +30,18 @@ import org.geek.szbay.assistant.code.generator.helpper.TableHelpper;
|
|
*/
|
|
*/
|
|
public class CodeHelpper {
|
|
public class CodeHelpper {
|
|
//private static final String DB_URL ="jdbc:mysql://127.0.0.1/demo?useEncodingUnicode=true&zeroDateTimeBehavior=convertToNull&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true";
|
|
//private static final String DB_URL ="jdbc:mysql://127.0.0.1/demo?useEncodingUnicode=true&zeroDateTimeBehavior=convertToNull&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true";
|
|
- private static final String DB_URL ="jdbc:mysql://127.0.0.1/demo?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull";
|
|
|
|
- private static final String DB_NAME = "root";
|
|
|
|
- private static final String DB_PASS = "admin";
|
|
|
|
|
|
+ private static final String DB_URL ="jdbc:mysql://121.43.149.208:3308/air_db?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull";
|
|
|
|
+ private static final String DB_NAME = "dhair";
|
|
|
|
+ private static final String DB_PASS = "pWt$9Ew4+ekJe84";
|
|
private static final String DB_DRIVER ="com.mysql.jdbc.Driver";
|
|
private static final String DB_DRIVER ="com.mysql.jdbc.Driver";
|
|
- private static final String DB_SCHEMA = "demo";
|
|
|
|
|
|
+ private static final String DB_SCHEMA = "air_db";
|
|
|
|
|
|
/** 作者名字 */
|
|
/** 作者名字 */
|
|
private String authorName = "wutianbin";
|
|
private String authorName = "wutianbin";
|
|
|
|
|
|
/** 表的前导字符 */
|
|
/** 表的前导字符 */
|
|
//private String preTableName = "*";
|
|
//private String preTableName = "*";
|
|
- private String preTableName = "oa\\_";
|
|
|
|
|
|
+ private String preTableName = "fp_exam";
|
|
//private String preTableName = "fp\\_exam";
|
|
//private String preTableName = "fp\\_exam";
|
|
//private String preTableName = "sys\\_";
|
|
//private String preTableName = "sys\\_";
|
|
|
|
|
|
@@ -61,6 +63,9 @@ public class CodeHelpper {
|
|
/** 指定Mapper生成所在包的路径 */
|
|
/** 指定Mapper生成所在包的路径 */
|
|
private String mapperOutPath = "mappers";
|
|
private String mapperOutPath = "mappers";
|
|
|
|
|
|
|
|
+ /** 指定ftl生成所在包的路径 */
|
|
|
|
+ private String ftlOutPath = "ftl";
|
|
|
|
+
|
|
public void generate() {
|
|
public void generate() {
|
|
Connection con = initDB();
|
|
Connection con = initDB();
|
|
if (con == null) {
|
|
if (con == null) {
|
|
@@ -90,6 +95,14 @@ public class CodeHelpper {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ System.out.println(tableName);
|
|
|
|
+ System.out.println(tableComment);
|
|
|
|
+ System.out.println(key);
|
|
|
|
+ System.out.println(attrNames);
|
|
|
|
+ System.out.println(colNames);
|
|
|
|
+ System.out.println(colTypes);
|
|
|
|
+ System.out.println(colComments);
|
|
|
|
+
|
|
generateEntity(tableName, tableComment, key, attrNames, colNames, colTypes, colComments);
|
|
generateEntity(tableName, tableComment, key, attrNames, colNames, colTypes, colComments);
|
|
|
|
|
|
// 不做读写分离的dao
|
|
// 不做读写分离的dao
|
|
@@ -102,9 +115,25 @@ public class CodeHelpper {
|
|
generateServiceImpl(tableName, tableComment, key, attrNames, colNames, colTypes, colComments);
|
|
generateServiceImpl(tableName, tableComment, key, attrNames, colNames, colTypes, colComments);
|
|
|
|
|
|
generateController(tableName, tableComment, key, attrNames, colNames, colTypes, colComments);
|
|
generateController(tableName, tableComment, key, attrNames, colNames, colTypes, colComments);
|
|
|
|
+
|
|
|
|
+ generateUpdateFtl(tableName, tableComment, key, attrNames, colNames, colTypes, colComments);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void generateUpdateFtl(String tableName, String tableComment, String key, List<String> attrNames,
|
|
|
|
+ List<String> colNames, List<String> colTypes, List<String> colComments) {
|
|
|
|
+ String tname = TableHelpper.tableNameToClassName(tableName);
|
|
|
|
+ String keyName = TableHelpper.columnNameToAttrName(key);
|
|
|
|
+ String path = ftlOutPath + "/" + StringUtils.firstToLowerCase(tname);
|
|
|
|
+
|
|
|
|
+ String content = UpdateFtlMaker.parse(true, tableComment, keyName, attrNames, colTypes, colComments);
|
|
|
|
+ saveToFile(tableName, path, content, "update.ftl");
|
|
|
|
+ content = UpdateFtlMaker.parse(false, tableComment, keyName, attrNames, colTypes, colComments);
|
|
|
|
+ saveToFile(tableName, path, content, "save.ftl");
|
|
|
|
+ content = UpdateFtlMaker.parseList(tableComment, keyName, attrNames, colTypes, colComments);
|
|
|
|
+ saveToFile(tableName, path, content, "list.ftl");
|
|
|
|
+ }
|
|
|
|
+
|
|
private Connection initDB() {
|
|
private Connection initDB() {
|
|
// 连接数据库
|
|
// 连接数据库
|
|
|
|
|