【update】添加注释与重命名变量
This commit is contained in:
+1
-1
@@ -103,7 +103,7 @@ public class CodeGenerateOne extends BaseCodeGenerate implements IGenerate {
|
||||
@Override
|
||||
public List<String> generateCodeFile(String projectPath, String templatePath, String stylePath) throws Exception {
|
||||
if (projectPath != null && !"".equals(projectPath)) {
|
||||
com.jero.codegenerate.properties.CodeConfigProperties.a(projectPath);
|
||||
com.jero.codegenerate.properties.CodeConfigProperties.setProjectPath(projectPath);
|
||||
}
|
||||
|
||||
if (templatePath != null && !"".equals(templatePath)) {
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ public class CodeGenerateOneToMany extends BaseCodeGenerate implements IGenerate
|
||||
@Override
|
||||
public List<String> generateCodeFile(String projectPath, String templatePath, String stylePath) throws Exception {
|
||||
if (projectPath != null && !"".equals(projectPath)) {
|
||||
com.jero.codegenerate.properties.CodeConfigProperties.a(projectPath);
|
||||
com.jero.codegenerate.properties.CodeConfigProperties.setProjectPath(projectPath);
|
||||
}
|
||||
|
||||
if (templatePath != null && !"".equals(templatePath)) {
|
||||
|
||||
+3
-3
@@ -87,7 +87,7 @@ public class BaseCodeGenerate {
|
||||
log.debug("-------java----outputFilepath--" + outputFilepath);
|
||||
this.a(templateFilePath, outputFilepath, configMap, createFileConfig);
|
||||
} else if (outputFilepath.startsWith("webapp")) {
|
||||
packageDir = projectPath + File.separator + com.jero.codegenerate.properties.CodeConfigProperties.i.replace(".", File.separator);
|
||||
packageDir = projectPath + File.separator + com.jero.codegenerate.properties.CodeConfigProperties.webrootPackage.replace(".", File.separator);
|
||||
outputFilepath = outputFilepath.substring("webapp".length());
|
||||
outputFilepath = packageDir + outputFilepath;
|
||||
log.debug("-------webapp---outputFilepath---" + outputFilepath);
|
||||
@@ -210,8 +210,8 @@ public class BaseCodeGenerate {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException var21) {
|
||||
var21.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+92
-43
@@ -6,81 +6,130 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
|
||||
/**
|
||||
* Nonce Number Once 只使用一次的数字相关工具类
|
||||
*/
|
||||
public class NonceUtils {
|
||||
private static final SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
private static final String[] b = new String[]{"0", "00", "0000", "00000000"};
|
||||
private static Date c;
|
||||
private static int d = 0;
|
||||
private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||
private static final String[] NUMBER_STRINGS = new String[]{"0", "00", "0000", "00000000"};
|
||||
private static Date date;
|
||||
private static int count = 0;
|
||||
|
||||
public NonceUtils() {
|
||||
}
|
||||
|
||||
public static String a(int var0) {
|
||||
return RandomStringUtils.randomAlphanumeric(var0);
|
||||
/**
|
||||
* 生成指定长度随机字符串
|
||||
* @date 2021/4/6 9:01
|
||||
* @param count 长度
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String getRandomString(int count) {
|
||||
return RandomStringUtils.randomAlphanumeric(count);
|
||||
}
|
||||
|
||||
public static int a() {
|
||||
/**
|
||||
* 生成真随机数整型
|
||||
* @date 2021/4/6 9:06
|
||||
* @return int
|
||||
*/
|
||||
public static int getSecureRandom() {
|
||||
return (new SecureRandom()).nextInt();
|
||||
}
|
||||
|
||||
public static String b() {
|
||||
return Integer.toHexString(a());
|
||||
/**
|
||||
* 生成真随机整型数的16进制字符串
|
||||
* @date 2021/4/6 9:08
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String getSecureRandomOfHexString() {
|
||||
return Integer.toHexString(getSecureRandom());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成真随机数的长整型
|
||||
* @date 2021/4/6 9:09
|
||||
* @return long
|
||||
*/
|
||||
public static long getSecureRandomLong() {
|
||||
return (new SecureRandom()).nextLong();
|
||||
}
|
||||
|
||||
public static String d() {
|
||||
/**
|
||||
* 生成真随机长整型数的16进制字符串
|
||||
* @date 2021/4/6 9:10
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String getSecureRandomLongOfHexString() {
|
||||
return Long.toHexString(getSecureRandomLong());
|
||||
}
|
||||
|
||||
public static String e() {
|
||||
/**
|
||||
* 生成uuid
|
||||
* @date 2021/4/6 9:13
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String getUuid() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public static String f() {
|
||||
Date var0 = new Date();
|
||||
return a.format(var0);
|
||||
/**
|
||||
* 获取当前格式化日期
|
||||
* @date 2021/4/6 9:13
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String getNow() {
|
||||
Date date = new Date();
|
||||
return SIMPLE_DATE_FORMAT.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取毫秒
|
||||
* @date 2021/4/6 9:15
|
||||
* @return long
|
||||
*/
|
||||
public static long getCurrentTimeMillis() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static String h() {
|
||||
/**
|
||||
* 获取毫秒的16进制字符串
|
||||
* @date 2021/4/6 9:17
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String getCurrentTimeMillisHexString() {
|
||||
return Long.toHexString(getCurrentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 待补充
|
||||
* @date 2021/4/6 9:36
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static synchronized String i() {
|
||||
Date var0 = new Date();
|
||||
if (var0.equals(c)) {
|
||||
++d;
|
||||
Date now = new Date();
|
||||
if (now.equals(date)) {
|
||||
++count;
|
||||
} else {
|
||||
c = var0;
|
||||
d = 0;
|
||||
date = now;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
return Integer.toHexString(d);
|
||||
return Integer.toHexString(count);
|
||||
}
|
||||
/**
|
||||
* todo 待补充
|
||||
* @date 2021/4/6 9:39
|
||||
* @param var0
|
||||
* @param length
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String a(String var0, int length) {
|
||||
int var2 = length - var0.length();
|
||||
|
||||
public static String a(String var0, int var1) {
|
||||
int var2 = var1 - var0.length();
|
||||
|
||||
StringBuilder var3;
|
||||
for(var3 = new StringBuilder(); var2 >= 8; var2 -= 8) {
|
||||
var3.append(b[3]);
|
||||
StringBuilder sb;
|
||||
for(sb = new StringBuilder(); var2 >= 8; var2 -= 8) {
|
||||
sb.append(NUMBER_STRINGS[3]);
|
||||
}
|
||||
|
||||
for(int var4 = 2; var4 >= 0; --var4) {
|
||||
if ((var2 & 1 << var4) != 0) {
|
||||
var3.append(b[var4]);
|
||||
for(int i = 2; i >= 0; --i) {
|
||||
if ((var2 & 1 << i) != 0) {
|
||||
sb.append(NUMBER_STRINGS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var3.append(var0);
|
||||
return var3.toString();
|
||||
sb.append(var0);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
+39
-26
@@ -13,26 +13,34 @@ import java.util.Locale;
|
||||
public class SimpleFormat {
|
||||
public SimpleFormat() {
|
||||
}
|
||||
/**
|
||||
* 将下划线字符串转换为驼峰字符串
|
||||
* @date 2021/4/6 9:55
|
||||
* @param str 字符串
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public static String underlineToHump(String str) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String[] strArray = str.split("_");
|
||||
String[] newStringArray = strArray;
|
||||
int length = strArray.length;
|
||||
|
||||
public static String underlineToHump(String para) {
|
||||
StringBuilder var1 = new StringBuilder();
|
||||
String[] var2 = para.split("_");
|
||||
String[] var3 = var2;
|
||||
int var4 = var2.length;
|
||||
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
String var6 = var3[var5];
|
||||
if (!para.contains("_")) {
|
||||
var1.append(var6);
|
||||
} else if (var1.length() == 0) {
|
||||
var1.append(var6.toLowerCase());
|
||||
for(int i = 0; i < length; ++i) {
|
||||
String s = newStringArray[i];
|
||||
// 原字符串不包含 -
|
||||
if (!str.contains("_")) {
|
||||
sb.append(s);
|
||||
//首次添加不首字母大写
|
||||
} else if (sb.length() == 0) {
|
||||
sb.append(s.toLowerCase());
|
||||
} else {
|
||||
var1.append(var6.substring(0, 1).toUpperCase());
|
||||
var1.append(var6.substring(1).toLowerCase());
|
||||
// 首字母大写
|
||||
sb.append(s.substring(0, 1).toUpperCase());
|
||||
sb.append(s.substring(1).toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
return var1.toString();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String humpToUnderline(String para) {
|
||||
@@ -124,22 +132,27 @@ public class SimpleFormat {
|
||||
public String datetime(Object obj) {
|
||||
return obj == null ? "" : DateFormat.getDateTimeInstance(1, 3, Locale.CHINA).format(obj);
|
||||
}
|
||||
/**
|
||||
* 将字符串集合转换为 'string', 间隔格式的字符串
|
||||
* @date 2021/4/6 9:41
|
||||
* @param stringList 字符串集合
|
||||
* @return java.lang.String
|
||||
*/
|
||||
public String getInStrs(List<String> stringList) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Iterator iterator = stringList.iterator();
|
||||
|
||||
public String getInStrs(List<String> params) {
|
||||
StringBuffer var2 = new StringBuffer();
|
||||
Iterator var3 = params.iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
String var4 = (String)var3.next();
|
||||
var2.append("'" + var4 + "',");
|
||||
while(iterator.hasNext()) {
|
||||
String s = (String)iterator.next();
|
||||
sb.append("'" + s + "',");
|
||||
}
|
||||
|
||||
String var5 = var2.toString();
|
||||
if ("".equals(var5) && !var5.endsWith(",")) {
|
||||
String string = sb.toString();
|
||||
if ("".equals(string) && !string.endsWith(",")) {
|
||||
return null;
|
||||
} else {
|
||||
var5 = var5.substring(0, var5.length() - 1);
|
||||
return var5;
|
||||
string = string.substring(0, string.length() - 1);
|
||||
return string;
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
-38
@@ -11,16 +11,14 @@ import java.util.ResourceBundle;
|
||||
/**
|
||||
* 配置文件
|
||||
* @date 2021/4/2 11:01
|
||||
* @param null
|
||||
* @return
|
||||
*/
|
||||
@Slf4j
|
||||
public class CodeConfigProperties {
|
||||
|
||||
private static final String dataBaseFileUrl = "jero/jero_database";
|
||||
private static final String configFileUrl = "jero/jero_config";
|
||||
private static ResourceBundle databaseDatasourcePropties = getDatasourcePropties(CodeConfigProperties.dataBaseFileUrl);
|
||||
private static ResourceBundle configDatasourcePropties = getDatasourcePropties(CodeConfigProperties.configFileUrl);
|
||||
private static final String DATA_BASE_FILE_URL = "jero/jero_database";
|
||||
private static final String CONFIG_FILE_URL = "jero/jero_config";
|
||||
private static ResourceBundle databaseDatasourcePropties = getDatasourcePropties(CodeConfigProperties.DATA_BASE_FILE_URL);
|
||||
private static ResourceBundle configDatasourcePropties = getDatasourcePropties(CodeConfigProperties.CONFIG_FILE_URL);
|
||||
public static String databaseType;
|
||||
public static String driverName;
|
||||
public static String databaseUrl;
|
||||
@@ -29,7 +27,7 @@ public class CodeConfigProperties {
|
||||
public static String projectPath;
|
||||
public static String packageName;
|
||||
public static String sourceRootPackage;
|
||||
public static String i;
|
||||
public static String webrootPackage;
|
||||
public static String templateUrl;
|
||||
public static boolean dbFiledConvert;
|
||||
public static String dbTableId;
|
||||
@@ -38,31 +36,31 @@ public class CodeConfigProperties {
|
||||
public static String pageFilterFields;
|
||||
public static String fieldRowNum;
|
||||
|
||||
private static ResourceBundle getDatasourcePropties(String var0) {
|
||||
PropertyResourceBundle var1 = null;
|
||||
BufferedInputStream var2 = null;
|
||||
String var3 = System.getProperty("user.dir") + File.separator + "config" + File.separator + var0 + ".properties";
|
||||
private static ResourceBundle getDatasourcePropties(String url) {
|
||||
PropertyResourceBundle propertyResourceBundle = null;
|
||||
BufferedInputStream bufferedInputStream = null;
|
||||
String configPath = System.getProperty("user.dir") + File.separator + "config" + File.separator + url + ".properties";
|
||||
|
||||
try {
|
||||
var2 = new BufferedInputStream(new FileInputStream(var3));
|
||||
var1 = new PropertyResourceBundle(var2);
|
||||
var2.close();
|
||||
if (var1 != null) {
|
||||
log.info(" JAR方式部署,通过config目录读取配置:" + var3);
|
||||
bufferedInputStream = new BufferedInputStream(new FileInputStream(configPath));
|
||||
propertyResourceBundle = new PropertyResourceBundle(bufferedInputStream);
|
||||
bufferedInputStream.close();
|
||||
if (propertyResourceBundle != null) {
|
||||
log.info(" JAR方式部署,通过config目录读取配置:" + configPath);
|
||||
}
|
||||
} catch (IOException var13) {
|
||||
} catch (IOException e) {
|
||||
} finally {
|
||||
if (var2 != null) {
|
||||
if (bufferedInputStream != null) {
|
||||
try {
|
||||
var2.close();
|
||||
} catch (IOException var12) {
|
||||
var12.printStackTrace();
|
||||
bufferedInputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return var1;
|
||||
return propertyResourceBundle;
|
||||
}
|
||||
|
||||
public static final String getDriverName() {
|
||||
@@ -73,15 +71,15 @@ public class CodeConfigProperties {
|
||||
return databaseDatasourcePropties.getString("url");
|
||||
}
|
||||
|
||||
public static final String c() {
|
||||
public static final String getUsername() {
|
||||
return databaseDatasourcePropties.getString("username");
|
||||
}
|
||||
|
||||
public static final String d() {
|
||||
public static final String getPassword() {
|
||||
return databaseDatasourcePropties.getString("password");
|
||||
}
|
||||
|
||||
public static final String e() {
|
||||
public static final String getDatabaseName() {
|
||||
return databaseDatasourcePropties.getString("database_name");
|
||||
}
|
||||
|
||||
@@ -90,7 +88,7 @@ public class CodeConfigProperties {
|
||||
return !dbFiledConvert.toString().equals("false");
|
||||
}
|
||||
|
||||
private static String o() {
|
||||
private static String getBussiPackage() {
|
||||
return configDatasourcePropties.getString("bussi_package");
|
||||
}
|
||||
|
||||
@@ -102,7 +100,7 @@ public class CodeConfigProperties {
|
||||
return configDatasourcePropties.getString("source_root_package");
|
||||
}
|
||||
|
||||
public static final String h() {
|
||||
public static final String getWebrootPackage() {
|
||||
return configDatasourcePropties.getString("webroot_package");
|
||||
}
|
||||
|
||||
@@ -118,7 +116,7 @@ public class CodeConfigProperties {
|
||||
return configDatasourcePropties.getString("page_search_filed_num");
|
||||
}
|
||||
|
||||
public static final String l() {
|
||||
public static final String getPageFieldRequiredNum() {
|
||||
return configDatasourcePropties.getString("page_field_required_num");
|
||||
}
|
||||
|
||||
@@ -131,8 +129,8 @@ public class CodeConfigProperties {
|
||||
return projectPath;
|
||||
}
|
||||
|
||||
public static void a(String var0) {
|
||||
projectPath = var0;
|
||||
public static void setProjectPath(String projectPath) {
|
||||
CodeConfigProperties.projectPath = projectPath;
|
||||
}
|
||||
|
||||
public static void setTemplateUrl(String templateUrl) {
|
||||
@@ -141,11 +139,11 @@ public class CodeConfigProperties {
|
||||
|
||||
static {
|
||||
if (databaseDatasourcePropties == null) {
|
||||
databaseDatasourcePropties = ResourceBundle.getBundle(CodeConfigProperties.dataBaseFileUrl);
|
||||
databaseDatasourcePropties = ResourceBundle.getBundle(CodeConfigProperties.DATA_BASE_FILE_URL);
|
||||
}
|
||||
|
||||
if (configDatasourcePropties == null) {
|
||||
configDatasourcePropties = ResourceBundle.getBundle(CodeConfigProperties.configFileUrl);
|
||||
configDatasourcePropties = ResourceBundle.getBundle(CodeConfigProperties.CONFIG_FILE_URL);
|
||||
}
|
||||
|
||||
databaseType = "mysql";
|
||||
@@ -156,7 +154,7 @@ public class CodeConfigProperties {
|
||||
projectPath = "c:/workspace/jero";
|
||||
packageName = "com.jero";
|
||||
sourceRootPackage = "src";
|
||||
i = "WebRoot";
|
||||
webrootPackage = "WebRoot";
|
||||
templateUrl = "/jero/code-template/";
|
||||
dbFiledConvert = true;
|
||||
fieldRequiredNum = "4";
|
||||
@@ -164,11 +162,11 @@ public class CodeConfigProperties {
|
||||
fieldRowNum = "1";
|
||||
driverName = getDriverName();
|
||||
databaseUrl = getDatabaseUrl();
|
||||
username = c();
|
||||
password = d();
|
||||
username = getUsername();
|
||||
password = getPassword();
|
||||
sourceRootPackage = getSourceRootPackage();
|
||||
i = h();
|
||||
packageName = o();
|
||||
webrootPackage = getWebrootPackage();
|
||||
packageName = getBussiPackage();
|
||||
templateUrl = getTemplateUrl();
|
||||
projectPath = getProjectPath();
|
||||
dbTableId = getDBTableId();
|
||||
@@ -192,6 +190,6 @@ public class CodeConfigProperties {
|
||||
}
|
||||
|
||||
sourceRootPackage = sourceRootPackage.replace(".", "/");
|
||||
i = i.replace(".", "/");
|
||||
webrootPackage = webrootPackage.replace(".", "/");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user