Commit 45fa7609 authored by fangxinjiang's avatar fangxinjiang

代码生成器调整

parent 78427b22
...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.core.util; ...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.core.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -31,7 +32,25 @@ public class Common { ...@@ -31,7 +32,25 @@ public class Common {
public static boolean isEmpty(String str) { public static boolean isEmpty(String str) {
return null == str || "".equals(str.trim()) || "null".equals(str.trim()) || "undefinded".equals(str.trim()); return null == str || "".equals(str.trim()) || "null".equals(str.trim()) || "undefinded".equals(str.trim());
} }
/**
* 截取startStr和endStr中间的字符串(开区间)
*
* @param startStr 开始的标志
* @param endStr 结束标志
* @param src 源串
* @return 返回符合要求的字符串或者返回null
* @author: fxj
*/
public static String subByStr(String startStr, String endStr, String src) {
if (StringUtils.isNotBlank(src) && StringUtils.isNotBlank(startStr) && StringUtils.isNotBlank(endStr)) {
int start = src.indexOf(startStr);
int end = src.indexOf(endStr);
if (end > start && start > -1) {
return src.substring(start + 1, end);
}
}
return null;
}
/** /**
* 对象null * 对象null
* *
......
...@@ -75,4 +75,9 @@ public class ColumnEntity { ...@@ -75,4 +75,9 @@ public class ColumnEntity {
*/ */
private Boolean hidden; private Boolean hidden;
/**
* 是否隐藏
*/
private String maxLength;
} }
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.codegen.entity.GenFormConf; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.codegen.entity.GenFormConf;
import com.yifu.cloud.plus.v1.yifu.codegen.entity.TableEntity; import com.yifu.cloud.plus.v1.yifu.codegen.entity.TableEntity;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException; import com.yifu.cloud.plus.v1.yifu.common.core.exception.CheckedException;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -183,6 +184,9 @@ public class CodeGenKits { ...@@ -183,6 +184,9 @@ public class CodeGenKits {
String dataType = StrUtil.subBefore(columnEntity.getDataType(), "(", false); String dataType = StrUtil.subBefore(columnEntity.getDataType(), "(", false);
String attrType = config.getString(dataType, "unknowType"); String attrType = config.getString(dataType, "unknowType");
columnEntity.setAttrType(attrType); columnEntity.setAttrType(attrType);
if ("String".equals(attrType)) {
columnEntity.setMaxLength(Common.subByStr("(", ")", column.get("columnType")));
}
if (!hasBigDecimal && "BigDecimal".equals(attrType)) { if (!hasBigDecimal && "BigDecimal".equals(attrType)) {
hasBigDecimal = true; hasBigDecimal = true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment