|
|
|
@ -1,14 +1,13 @@
|
|
|
|
|
package org.dromara.generator.util;
|
|
|
|
|
|
|
|
|
|
import org.dromara.generator.constant.GenConstants;
|
|
|
|
|
import lombok.AccessLevel;
|
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
|
import org.apache.commons.lang3.RegExUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
import org.dromara.generator.config.GenConfig;
|
|
|
|
|
import org.dromara.generator.constant.GenConstants;
|
|
|
|
|
import org.dromara.generator.domain.GenTable;
|
|
|
|
|
import org.dromara.generator.domain.GenTableColumn;
|
|
|
|
|
import lombok.AccessLevel;
|
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
|
import org.apache.commons.lang3.RegExUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
@ -23,14 +22,14 @@ public class GenUtils {
|
|
|
|
|
/**
|
|
|
|
|
* 初始化表信息
|
|
|
|
|
*/
|
|
|
|
|
public static void initTable(GenTable genTable, String operName) {
|
|
|
|
|
public static void initTable(GenTable genTable, Long operId) {
|
|
|
|
|
genTable.setClassName(convertClassName(genTable.getTableName()));
|
|
|
|
|
genTable.setPackageName(GenConfig.getPackageName());
|
|
|
|
|
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
|
|
|
|
genTable.setBusinessName(getBusinessName(genTable.getTableName()));
|
|
|
|
|
genTable.setFunctionName(replaceText(genTable.getTableComment()));
|
|
|
|
|
genTable.setFunctionAuthor(GenConfig.getAuthor());
|
|
|
|
|
genTable.setCreateBy(LoginHelper.getUserId());
|
|
|
|
|
genTable.setCreateBy(operId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -185,7 +184,7 @@ public class GenUtils {
|
|
|
|
|
String text = replacementm;
|
|
|
|
|
for (String searchString : searchList) {
|
|
|
|
|
if (replacementm.startsWith(searchString)) {
|
|
|
|
|
text = replacementm.replaceFirst(searchString, "");
|
|
|
|
|
text = replacementm.replaceFirst(searchString, StringUtils.EMPTY);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -209,7 +208,7 @@ public class GenUtils {
|
|
|
|
|
* @return 截取后的列类型
|
|
|
|
|
*/
|
|
|
|
|
public static String getDbType(String columnType) {
|
|
|
|
|
if (StringUtils.indexOf(columnType, '(') > 0) {
|
|
|
|
|
if (StringUtils.indexOf(columnType, "(") > 0) {
|
|
|
|
|
return StringUtils.substringBefore(columnType, "(");
|
|
|
|
|
} else {
|
|
|
|
|
return columnType;
|
|
|
|
@ -223,7 +222,7 @@ public class GenUtils {
|
|
|
|
|
* @return 截取后的列类型
|
|
|
|
|
*/
|
|
|
|
|
public static Integer getColumnLength(String columnType) {
|
|
|
|
|
if (StringUtils.indexOf(columnType, '(') > 0) {
|
|
|
|
|
if (StringUtils.indexOf(columnType, "(") > 0) {
|
|
|
|
|
String length = StringUtils.substringBetween(columnType, "(", ")");
|
|
|
|
|
return Integer.valueOf(length);
|
|
|
|
|
} else {
|
|
|
|
|