✨ Introducing new features. 代码生成细节完善,注释换行符号去除, 字段类型去除括号后匹配等
This commit is contained in:
1 parent
fc6fefd224
commit
1e09236868
5 files changed
+16
-6
No files matched your search
+1
-1
@@ -60,7 +60,7 @@ public class JdbcDynamicDataSourceProvider extends AbstractJdbcDataSourceProvide
|
||||
|
||||
Map<String, DataSourceProperty> map = new HashMap<>(8);
|
||||
while (rs.next()) {
|
||||
String name = rs.getString(DataSourceConstants.DS_NAME);
|
||||
String name = rs.getString(DataSourceConstants.NAME);
|
||||
String username = rs.getString(DataSourceConstants.DS_USER_NAME);
|
||||
String password = rs.getString(DataSourceConstants.DS_USER_PWD);
|
||||
Integer confType = rs.getInt(DataSourceConstants.DS_CONFIG_TYPE);
|
||||
|
||||
+6
-1
@@ -11,7 +11,7 @@ public interface DataSourceConstants {
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
String DS_NAME = "name";
|
||||
String NAME = "name";
|
||||
|
||||
/**
|
||||
* 默认数据源(master)
|
||||
@@ -43,6 +43,11 @@ public interface DataSourceConstants {
|
||||
*/
|
||||
String DS_TYPE = "ds_type";
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
String DS_NAME = "ds_name";
|
||||
|
||||
/**
|
||||
* 主机类型
|
||||
*/
|
||||
|
||||
+4
-1
@@ -1,5 +1,6 @@
|
||||
package com.pig4cloud.pigx.codegen.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.codegen.entity.ColumnEntity;
|
||||
@@ -31,7 +32,9 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
|
||||
// 处理 数据库类型和 Java 类型关系
|
||||
Configuration config = GenUtils.getConfig();
|
||||
columnPage.getRecords().forEach(column -> {
|
||||
String attrType = config.getString(column.getDataType(), "unknowType");
|
||||
// 只保留 ()之前部分,例如 timestamp(6) -> timestamp
|
||||
String dataType = StrUtil.subBefore(column.getDataType(), "(", false);
|
||||
String attrType = config.getString(dataType, "unknowType");
|
||||
column.setLowerAttrName(StringUtils.uncapitalize(GenUtils.columnToJava(column.getColumnName())));
|
||||
column.setJavaType(attrType);
|
||||
});
|
||||
|
||||
+4
-2
@@ -175,14 +175,16 @@ public class GenUtils {
|
||||
|
||||
// 判断注释是否为空
|
||||
if (StrUtil.isNotBlank(column.get("comments"))) {
|
||||
columnEntity.setComments(column.get("comments"));
|
||||
// 注意去除换行符号
|
||||
columnEntity.setComments(StrUtil.removeAllLineBreaks(column.get("comments")));
|
||||
}
|
||||
else {
|
||||
columnEntity.setComments(columnEntity.getLowerAttrName());
|
||||
}
|
||||
|
||||
// 列的数据类型,转换成Java类型
|
||||
String attrType = config.getString(columnEntity.getDataType(), "unknowType");
|
||||
String dataType = StrUtil.subBefore(columnEntity.getDataType(), "(", false);
|
||||
String attrType = config.getString(dataType, "unknowType");
|
||||
columnEntity.setAttrType(attrType);
|
||||
if (!hasBigDecimal && "BigDecimal".equals(attrType)) {
|
||||
hasBigDecimal = true;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
TEMP.COLUMN_NAME AS "columnName",
|
||||
TEMP.data_type AS "columnType",
|
||||
TEMP.data_type AS "dataType",
|
||||
TEMP.comments AS comments,
|
||||
TEMP.comments AS "comments",
|
||||
CASE
|
||||
TEMP.constraint_type
|
||||
WHEN 'P' THEN
|
||||
|
||||
Reference in new issue
Block a user