update 优化 代码生成器

feature/model
疯狂的狮子Li 1 year ago
parent d5c33b5604
commit 512108cf5a

@ -178,11 +178,11 @@ public class GenTableServiceImpl implements IGenTableService {
@DSTransactional
@Override
public void importGenTable(List<GenTable> tableList, String dataName) {
String operName = LoginHelper.getUsername();
Long operId = LoginHelper.getUserId();
try {
for (GenTable table : tableList) {
String tableName = table.getTableName();
GenUtils.initTable(table, operName);
GenUtils.initTable(table, operId);
table.setDataName(dataName);
int row = baseMapper.insert(table);
if (row > 0) {

@ -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 {

Loading…
Cancel
Save