【update】添加注释与重命名变量
This commit is contained in:
+11
-11
@@ -65,7 +65,7 @@ public class DbReadTableUtil {
|
|||||||
log.info(" connect databaseName : " + catalog);
|
log.info(" connect databaseName : " + catalog);
|
||||||
if (CodeConfigProperties.databaseType.equals(DbConvertDef.MYSQL)) {
|
if (CodeConfigProperties.databaseType.equals(DbConvertDef.MYSQL)) {
|
||||||
// mysql查询所有表的sql
|
// mysql查询所有表的sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.MYSQL_ALLTABLES_SQL, TableConvert.c(catalog));
|
sqlStr = MessageFormat.format(DbConvertDef.MYSQL_ALLTABLES_SQL, TableConvert.formatStr(catalog));
|
||||||
}
|
}
|
||||||
if (CodeConfigProperties.databaseType.equals(DbConvertDef.ORACLE)) {
|
if (CodeConfigProperties.databaseType.equals(DbConvertDef.ORACLE)) {
|
||||||
// oracle查询所有表的sql
|
// oracle查询所有表的sql
|
||||||
@@ -130,22 +130,22 @@ public class DbReadTableUtil {
|
|||||||
log.info(" connect databaseName : " + catalog);
|
log.info(" connect databaseName : " + catalog);
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.MYSQL)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.MYSQL)) {
|
||||||
// mysql查询表的所有列信息sql
|
// mysql查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.MYSQL_ALLCOLUMNS_SQL, TableConvert.c(tableName), TableConvert.c(catalog));
|
sqlStr = MessageFormat.format(DbConvertDef.MYSQL_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName), TableConvert.formatStr(catalog));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.ORACLE)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.ORACLE)) {
|
||||||
// oracle查询表的所有列信息sql
|
// oracle查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.ORACLE_ALLCOLUMNS_SQL, TableConvert.c(tableName.toUpperCase()));
|
sqlStr = MessageFormat.format(DbConvertDef.ORACLE_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName.toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.POSTGRESQL)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.POSTGRESQL)) {
|
||||||
// postgresql查询表的所有列信息sql
|
// postgresql查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.POSTGRESQL_ALLCOLUMNS_SQL, TableConvert.c(tableName), TableConvert.c(tableName));
|
sqlStr = MessageFormat.format(DbConvertDef.POSTGRESQL_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName), TableConvert.formatStr(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.SQLSERVER)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.SQLSERVER)) {
|
||||||
// sqlserver查询表的所有列信息sql
|
// sqlserver查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.SQLSERVER_ALLCOLUMNS_SQL, TableConvert.c(tableName));
|
sqlStr = MessageFormat.format(DbConvertDef.SQLSERVER_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("--------------sql-------------" + sqlStr);
|
log.debug("--------------sql-------------" + sqlStr);
|
||||||
@@ -262,22 +262,22 @@ public class DbReadTableUtil {
|
|||||||
log.info(" connect databaseName : " + catalog);
|
log.info(" connect databaseName : " + catalog);
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.MYSQL)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.MYSQL)) {
|
||||||
// mysql查询表的所有列信息sql
|
// mysql查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.MYSQL_ALLCOLUMNS_SQL, TableConvert.c(tableName), TableConvert.c(catalog));
|
sqlStr = MessageFormat.format(DbConvertDef.MYSQL_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName), TableConvert.formatStr(catalog));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.ORACLE)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.ORACLE)) {
|
||||||
// oracle查询表的所有列信息sql
|
// oracle查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.ORACLE_ALLCOLUMNS_SQL, TableConvert.c(tableName.toUpperCase()));
|
sqlStr = MessageFormat.format(DbConvertDef.ORACLE_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName.toUpperCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.POSTGRESQL)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.POSTGRESQL)) {
|
||||||
// postgresql查询表的所有列信息sql
|
// postgresql查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.POSTGRESQL_ALLCOLUMNS_SQL, TableConvert.c(tableName), TableConvert.c(tableName));
|
sqlStr = MessageFormat.format(DbConvertDef.POSTGRESQL_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName), TableConvert.formatStr(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.SQLSERVER)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.SQLSERVER)) {
|
||||||
// sqlserver查询表的所有列信息sql
|
// sqlserver查询表的所有列信息sql
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.SQLSERVER_ALLCOLUMNS_SQL, TableConvert.c(tableName));
|
sqlStr = MessageFormat.format(DbConvertDef.SQLSERVER_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet = statement.executeQuery(sqlStr);
|
resultSet = statement.executeQuery(sqlStr);
|
||||||
@@ -391,11 +391,11 @@ public class DbReadTableUtil {
|
|||||||
}
|
}
|
||||||
// postgresql获取表的列信息sql
|
// postgresql获取表的列信息sql
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.POSTGRESQL)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.POSTGRESQL)) {
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.POSTGRESQL_ALLCOLUMNS_SQL, TableConvert.c(tableName), TableConvert.c(tableName));
|
sqlStr = MessageFormat.format(DbConvertDef.POSTGRESQL_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName), TableConvert.formatStr(tableName));
|
||||||
}
|
}
|
||||||
// sqlserver获取表的列信息sql
|
// sqlserver获取表的列信息sql
|
||||||
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.SQLSERVER)) {
|
if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.SQLSERVER)) {
|
||||||
sqlStr = MessageFormat.format(DbConvertDef.SQLSERVER_ALLCOLUMNS_SQL, TableConvert.c(tableName));
|
sqlStr = MessageFormat.format(DbConvertDef.SQLSERVER_ALLCOLUMNS_SQL, TableConvert.formatStr(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet resultSet = statement.executeQuery(sqlStr);
|
ResultSet resultSet = statement.executeQuery(sqlStr);
|
||||||
|
|||||||
+48
-29
@@ -14,7 +14,7 @@ public class SimpleFormat {
|
|||||||
public SimpleFormat() {
|
public SimpleFormat() {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 将下划线字符串转换为驼峰字符串
|
* 下划线字符串转换为驼峰字符串
|
||||||
* @date 2021/4/6 9:55
|
* @date 2021/4/6 9:55
|
||||||
* @param str 字符串
|
* @param str 字符串
|
||||||
* @return java.lang.String
|
* @return java.lang.String
|
||||||
@@ -42,35 +42,48 @@ public class SimpleFormat {
|
|||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public static String humpToUnderline(String para) {
|
* 驼峰字符串转换为下划线字符串
|
||||||
StringBuilder var1 = new StringBuilder(para);
|
* @date 2021/4/6 10:01
|
||||||
int var2 = 0;
|
* @param str 字符串
|
||||||
if (!para.contains("_")) {
|
* @return java.lang.String
|
||||||
for(int var3 = 0; var3 < para.length(); ++var3) {
|
*/
|
||||||
if (Character.isUpperCase(para.charAt(var3))) {
|
public static String humpToUnderline(String str) {
|
||||||
var1.insert(var3 + var2, "_");
|
StringBuilder sb = new StringBuilder(str);
|
||||||
++var2;
|
// 随着下划线的增加,偏移量也会增加
|
||||||
|
int addUnderlineCount = 0;
|
||||||
|
// 不包含下划线
|
||||||
|
if (!str.contains("_")) {
|
||||||
|
for(int i = 0; i < str.length(); ++i) {
|
||||||
|
// 如果字母大写
|
||||||
|
if (Character.isUpperCase(str.charAt(i))) {
|
||||||
|
sb.insert(i + addUnderlineCount, "_");
|
||||||
|
++addUnderlineCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return var1.toString().toLowerCase().startsWith("_") ? var1.toString().toLowerCase().substring(1) : var1.toString().toLowerCase();
|
return sb.toString().toLowerCase().startsWith("_") ? sb.toString().toLowerCase().substring(1) : sb.toString().toLowerCase();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public static String humpToShortbar(String para) {
|
* 驼峰字符串转换为下划线字符串 ps:方法可能重复了
|
||||||
StringBuilder var1 = new StringBuilder(para);
|
* @date 2021/4/6 10:17
|
||||||
int var2 = 0;
|
* @param str 字符串
|
||||||
if (!para.contains("-")) {
|
* @return java.lang.String
|
||||||
for(int var3 = 0; var3 < para.length(); ++var3) {
|
*/
|
||||||
if (Character.isUpperCase(para.charAt(var3))) {
|
public static String humpToShortbar(String str) {
|
||||||
var1.insert(var3 + var2, "-");
|
StringBuilder sb = new StringBuilder(str);
|
||||||
++var2;
|
int addUnderlineCount = 0;
|
||||||
|
if (!str.contains("-")) {
|
||||||
|
for(int i = 0; i < str.length(); ++i) {
|
||||||
|
if (Character.isUpperCase(str.charAt(i))) {
|
||||||
|
sb.insert(i + addUnderlineCount, "-");
|
||||||
|
++addUnderlineCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return var1.toString().toLowerCase().startsWith("-") ? var1.toString().toLowerCase().substring(1) : var1.toString().toLowerCase();
|
return sb.toString().toLowerCase().startsWith("-") ? sb.toString().toLowerCase().substring(1) : sb.toString().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String number(Object obj) {
|
public String number(Object obj) {
|
||||||
@@ -92,23 +105,29 @@ public class SimpleFormat {
|
|||||||
obj = obj != null && obj.toString().length() != 0 ? obj : 0;
|
obj = obj != null && obj.toString().length() != 0 ? obj : 0;
|
||||||
return NumberFormat.getCurrencyInstance(Locale.CHINA).format(obj);
|
return NumberFormat.getCurrencyInstance(Locale.CHINA).format(obj);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* timeStamp转换为日期格式化String
|
||||||
|
* @date 2021/4/6 10:22
|
||||||
|
* @param obj
|
||||||
|
* @param pattern
|
||||||
|
* @return java.lang.String
|
||||||
|
*/
|
||||||
public String timestampToString(Object obj, String pattern) {
|
public String timestampToString(Object obj, String pattern) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
SimpleDateFormat var3 = new SimpleDateFormat("dd-MM月 -yy");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM月 -yy");
|
||||||
SimpleDateFormat var4 = new SimpleDateFormat(pattern);
|
SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat(pattern);
|
||||||
Date var5 = null;
|
Date date = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var5 = var3.parse(obj.toString());
|
date = simpleDateFormat.parse(obj.toString());
|
||||||
} catch (ParseException var7) {
|
} catch (ParseException e) {
|
||||||
var7.printStackTrace();
|
e.printStackTrace();
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
return var4.format(var5);
|
return simpleDateFormat1.format(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-10
@@ -5,20 +5,35 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
public class TableConvert {
|
public class TableConvert {
|
||||||
public TableConvert() {
|
public TableConvert() {
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public static String getNullable(String var0) {
|
* 校验字段为 '是' 或 '否'
|
||||||
if (!"YES".equals(var0) && !"yes".equals(var0) && !"y".equals(var0) && !"Y".equals(var0) && !"f".equals(var0)) {
|
* @date 2021/4/6 10:46
|
||||||
return !"NO".equals(var0) && !"N".equals(var0) && !"no".equals(var0) && !"n".equals(var0) && !"t".equals(var0) ? null : "N";
|
* @param s
|
||||||
|
* @return java.lang.String
|
||||||
|
*/
|
||||||
|
public static String getNullable(String s) {
|
||||||
|
if (!"YES".equals(s) && !"yes".equals(s) && !"y".equals(s) && !"Y".equals(s) && !"f".equals(s)) {
|
||||||
|
return !"NO".equals(s) && !"N".equals(s) && !"no".equals(s) && !"n".equals(s) && !"t".equals(s) ? null : "N";
|
||||||
} else {
|
} else {
|
||||||
return "Y";
|
return "Y";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public static String isFieldValueBlank(String var0) {
|
* 校验字符串是否为空字符串
|
||||||
return StringUtils.isBlank(var0) ? "" : var0;
|
* @date 2021/4/6 10:44
|
||||||
|
* @param s 字符串
|
||||||
|
* @return java.lang.String
|
||||||
|
*/
|
||||||
|
public static String isFieldValueBlank(String s) {
|
||||||
|
return StringUtils.isBlank(s) ? "" : s;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public static String c(String var0) {
|
* 格式化字符串,加单引号
|
||||||
return "'" + var0 + "'";
|
* @date 2021/4/6 10:45
|
||||||
|
* @param s 字符串
|
||||||
|
* @return java.lang.String
|
||||||
|
*/
|
||||||
|
public static String formatStr(String s) {
|
||||||
|
return "'" + s + "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user