update 优化 代码生成器
This commit is contained in:
parent
d5c33b5604
commit
512108cf5a
@ -178,11 +178,11 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
@DSTransactional
|
@DSTransactional
|
||||||
@Override
|
@Override
|
||||||
public void importGenTable(List<GenTable> tableList, String dataName) {
|
public void importGenTable(List<GenTable> tableList, String dataName) {
|
||||||
String operName = LoginHelper.getUsername();
|
Long operId = LoginHelper.getUserId();
|
||||||
try {
|
try {
|
||||||
for (GenTable table : tableList) {
|
for (GenTable table : tableList) {
|
||||||
String tableName = table.getTableName();
|
String tableName = table.getTableName();
|
||||||
GenUtils.initTable(table, operName);
|
GenUtils.initTable(table, operId);
|
||||||
table.setDataName(dataName);
|
table.setDataName(dataName);
|
||||||
int row = baseMapper.insert(table);
|
int row = baseMapper.insert(table);
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package org.dromara.generator.util;
|
package org.dromara.generator.util;
|
||||||
|
|
||||||
import org.dromara.generator.constant.GenConstants;
|
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
|
||||||
import org.dromara.generator.config.GenConfig;
|
|
||||||
import org.dromara.generator.domain.GenTable;
|
|
||||||
import org.dromara.generator.domain.GenTableColumn;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.apache.commons.lang3.RegExUtils;
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
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 java.util.Arrays;
|
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.setClassName(convertClassName(genTable.getTableName()));
|
||||||
genTable.setPackageName(GenConfig.getPackageName());
|
genTable.setPackageName(GenConfig.getPackageName());
|
||||||
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
||||||
genTable.setBusinessName(getBusinessName(genTable.getTableName()));
|
genTable.setBusinessName(getBusinessName(genTable.getTableName()));
|
||||||
genTable.setFunctionName(replaceText(genTable.getTableComment()));
|
genTable.setFunctionName(replaceText(genTable.getTableComment()));
|
||||||
genTable.setFunctionAuthor(GenConfig.getAuthor());
|
genTable.setFunctionAuthor(GenConfig.getAuthor());
|
||||||
genTable.setCreateBy(LoginHelper.getUserId());
|
genTable.setCreateBy(operId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,7 +184,7 @@ public class GenUtils {
|
|||||||
String text = replacementm;
|
String text = replacementm;
|
||||||
for (String searchString : searchList) {
|
for (String searchString : searchList) {
|
||||||
if (replacementm.startsWith(searchString)) {
|
if (replacementm.startsWith(searchString)) {
|
||||||
text = replacementm.replaceFirst(searchString, "");
|
text = replacementm.replaceFirst(searchString, StringUtils.EMPTY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +208,7 @@ public class GenUtils {
|
|||||||
* @return 截取后的列类型
|
* @return 截取后的列类型
|
||||||
*/
|
*/
|
||||||
public static String getDbType(String columnType) {
|
public static String getDbType(String columnType) {
|
||||||
if (StringUtils.indexOf(columnType, '(') > 0) {
|
if (StringUtils.indexOf(columnType, "(") > 0) {
|
||||||
return StringUtils.substringBefore(columnType, "(");
|
return StringUtils.substringBefore(columnType, "(");
|
||||||
} else {
|
} else {
|
||||||
return columnType;
|
return columnType;
|
||||||
@ -223,7 +222,7 @@ public class GenUtils {
|
|||||||
* @return 截取后的列类型
|
* @return 截取后的列类型
|
||||||
*/
|
*/
|
||||||
public static Integer getColumnLength(String columnType) {
|
public static Integer getColumnLength(String columnType) {
|
||||||
if (StringUtils.indexOf(columnType, '(') > 0) {
|
if (StringUtils.indexOf(columnType, "(") > 0) {
|
||||||
String length = StringUtils.substringBetween(columnType, "(", ")");
|
String length = StringUtils.substringBetween(columnType, "(", ")");
|
||||||
return Integer.valueOf(length);
|
return Integer.valueOf(length);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user