forked from lxm_tools/screw
⚡ 优化代码
This commit is contained in:
@@ -29,79 +29,78 @@ public class DefaultConstants implements Serializable {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
public static final String NAME = "screw";
|
||||
public static final String NAME = "screw";
|
||||
/**
|
||||
* 百分号
|
||||
*/
|
||||
public static final String PERCENT_SIGN = "%";
|
||||
public static final String PERCENT_SIGN = "%";
|
||||
/**
|
||||
* 暂未支持
|
||||
*/
|
||||
public static final String NOT_SUPPORTED = "Not supported yet!";
|
||||
public static final String NOT_SUPPORTED = "Not supported yet!";
|
||||
|
||||
/**
|
||||
* 默认字符集
|
||||
*/
|
||||
public static final String DEFAULT_ENCODING = "UTF-8";
|
||||
public static final String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
/**
|
||||
* 默认国际化
|
||||
*/
|
||||
public static final String DEFAULT_LOCALE = "zh_CN";
|
||||
public static final String DEFAULT_LOCALE = "zh_CN";
|
||||
/**
|
||||
* Mac
|
||||
*/
|
||||
public static final String MAC = "Mac";
|
||||
public static final String MAC = "Mac";
|
||||
/**
|
||||
* Windows
|
||||
*/
|
||||
public static final String WINDOWS = "Windows";
|
||||
public static final String WINDOWS = "Windows";
|
||||
/**
|
||||
* 小数点0
|
||||
*/
|
||||
public static final String ZERO_DECIMAL_DIGITS = "0";
|
||||
public static final String ZERO_DECIMAL_DIGITS = "0";
|
||||
/**
|
||||
* 默认描述
|
||||
*/
|
||||
public static final String DESCRIPTION = "数据库设计文档";
|
||||
public static final String DESCRIPTION = "数据库设计文档";
|
||||
/**
|
||||
* mysql useInformationSchema
|
||||
*/
|
||||
public static final String USE_INFORMATION_SCHEMA = "useInformationSchema";
|
||||
public static final String USE_INFORMATION_SCHEMA = "useInformationSchema";
|
||||
/**
|
||||
* oracle 连接参数备注
|
||||
*/
|
||||
public static final String ORACLE_REMARKS = "remarks";
|
||||
public static final String ORACLE_REMARKS = "remarks";
|
||||
/**
|
||||
* 日志开始
|
||||
*/
|
||||
public static final String LOGGER_BEGINS = "Database design document generation begins 🚀";
|
||||
public static final String LOGGER_BEGINS = "Database design document generation begins 🚀";
|
||||
/**
|
||||
* 日志结束
|
||||
*/
|
||||
public static final String LOGGER_COMPLETE = "Database design document generation is complete , time cost:%s second 🎇";
|
||||
public static final String LOGGER_COMPLETE = "Database design document generation is complete , time cost:%s second 🎇";
|
||||
/**
|
||||
* 零
|
||||
*/
|
||||
public static final String ZERO = "0";
|
||||
public static final String ZERO = "0";
|
||||
/**
|
||||
* N
|
||||
*/
|
||||
public static final String N = "N";
|
||||
public static final String N = "N";
|
||||
/**
|
||||
* Y
|
||||
*/
|
||||
public static final String Y = "Y";
|
||||
public static final String Y = "Y";
|
||||
|
||||
/**
|
||||
* phoenix 命名空间
|
||||
*/
|
||||
public static final String PHOENIX_NAMESPACE_MAPPING = "phoenix.schema.isNamespaceMappingEnabled";
|
||||
public static final String PHOENIX_NAMESPACE_MAPPING = "phoenix.schema.isNamespaceMappingEnabled";
|
||||
|
||||
/**
|
||||
* phoenix 系统命名空间
|
||||
*/
|
||||
public static final String PHOENIX_SYS_NAMESPACE_MAPPING = "phoenix.schema.mapSystemTablesToNamespace";
|
||||
|
||||
public static final String PHOENIX_SYS_NAMESPACE_MAPPING = "phoenix.schema.mapSystemTablesToNamespace";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* screw-core - 简洁好用的数据库表结构文档生成工具
|
||||
* Copyright © 2020 SanLi (qinggang.zuo@gmail.com)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cn.smallbun.screw.core.query.phoenix;
|
||||
|
||||
import cn.smallbun.screw.core.exception.QueryException;
|
||||
@@ -22,9 +39,7 @@ import static cn.smallbun.screw.core.constant.DefaultConstants.PERCENT_SIGN;
|
||||
|
||||
/**
|
||||
* @author xielongwang
|
||||
* @create 2020/8/19 4:53 下午
|
||||
* @email siaron.wang@gmail.com
|
||||
* @description
|
||||
* Created by siaron.wang@gmail.com 2020/8/19 4:53 下午
|
||||
*/
|
||||
public class PhoenixDataBaseQuery extends AbstractDatabaseQuery {
|
||||
|
||||
@@ -45,7 +60,7 @@ public class PhoenixDataBaseQuery extends AbstractDatabaseQuery {
|
||||
try {
|
||||
//查询
|
||||
resultSet = getMetaData().getTables("", getSchema(), PERCENT_SIGN,
|
||||
new String[]{"TABLE"});
|
||||
new String[] { "TABLE" });
|
||||
//映射
|
||||
return Mapping.convertList(resultSet, PhoenixlTableModel.class);
|
||||
} catch (SQLException e) {
|
||||
@@ -63,7 +78,8 @@ public class PhoenixDataBaseQuery extends AbstractDatabaseQuery {
|
||||
//查询
|
||||
resultSet = getMetaData().getColumns("", getSchema(), table, PERCENT_SIGN);
|
||||
//映射
|
||||
List<PhoenixColumnModel> list = Mapping.convertList(resultSet, PhoenixColumnModel.class);
|
||||
List<PhoenixColumnModel> list = Mapping.convertList(resultSet,
|
||||
PhoenixColumnModel.class);
|
||||
|
||||
//处理columnName
|
||||
list.forEach(model -> model.setColumnType(model.getTypeName()));
|
||||
@@ -95,7 +111,6 @@ public class PhoenixDataBaseQuery extends AbstractDatabaseQuery {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<? extends PrimaryKey> getPrimaryKeys() throws QueryException {
|
||||
ResultSet resultSet = null;
|
||||
|
||||
@@ -34,117 +34,117 @@ public class PhoenixColumnModel implements Column {
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "SCOPE_TABLE")
|
||||
private Object scopeTable;
|
||||
private Object scopeTable;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "TABLE_CAT")
|
||||
private String tableCat;
|
||||
private String tableCat;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "BUFFER_LENGTH")
|
||||
private String bufferLength;
|
||||
private String bufferLength;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "IS_NULLABLE")
|
||||
private String isNullable;
|
||||
private String isNullable;
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@MappingField(value = "TABLE_NAME")
|
||||
private String tableName;
|
||||
private String tableName;
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
@MappingField(value = "COLUMN_DEF")
|
||||
private String columnDef;
|
||||
private String columnDef;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "SCOPE_CATALOG")
|
||||
private Object scopeCatalog;
|
||||
private Object scopeCatalog;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "TABLE_SCHEM")
|
||||
private Object tableSchem;
|
||||
private Object tableSchem;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "COLUMN_NAME")
|
||||
private String columnName;
|
||||
private String columnName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "NULLABLE")
|
||||
private String nullable;
|
||||
private String nullable;
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@MappingField(value = "REMARKS")
|
||||
private String remarks;
|
||||
private String remarks;
|
||||
/**
|
||||
* 小数位
|
||||
*/
|
||||
@MappingField(value = "DECIMAL_DIGITS")
|
||||
private String decimalDigits;
|
||||
private String decimalDigits;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "NUM_PREC_RADIX")
|
||||
private String numPrecRadix;
|
||||
private String numPrecRadix;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "SQL_DATETIME_SUB")
|
||||
private String sqlDatetimeSub;
|
||||
private String sqlDatetimeSub;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "IS_GENERATEDCOLUMN")
|
||||
private String isGeneratedColumn;
|
||||
private String isGeneratedColumn;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "IS_AUTOINCREMENT")
|
||||
private String isAutoIncrement;
|
||||
private String isAutoIncrement;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "SQL_DATA_TYPE")
|
||||
private String sqlDataType;
|
||||
private String sqlDataType;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "CHAR_OCTET_LENGTH")
|
||||
private String charOctetLength;
|
||||
private String charOctetLength;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "ORDINAL_POSITION")
|
||||
private String ordinalPosition;
|
||||
private String ordinalPosition;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "SCOPE_SCHEMA")
|
||||
private Object scopeSchema;
|
||||
private Object scopeSchema;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "SOURCE_DATA_TYPE")
|
||||
private Object sourceDataType;
|
||||
private Object sourceDataType;
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
@MappingField(value = "DATA_TYPE")
|
||||
private String dataType;
|
||||
private String dataType;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "TYPE_NAME")
|
||||
private String typeName;
|
||||
private String typeName;
|
||||
/**
|
||||
* 列表示给定列的指定列大小。
|
||||
* 对于数值数据,这是最大精度。
|
||||
@@ -154,22 +154,22 @@ public class PhoenixColumnModel implements Column {
|
||||
* 对于 ROWID 数据类型,这是字节长度。对于列大小不适用的数据类型,则返回 Null。
|
||||
*/
|
||||
@MappingField(value = "COLUMN_SIZE")
|
||||
private String columnSize;
|
||||
private String columnSize;
|
||||
|
||||
/**
|
||||
* 是否主键
|
||||
*/
|
||||
private String primaryKey;
|
||||
private String primaryKey;
|
||||
|
||||
/**
|
||||
* 列类型(带长度)
|
||||
*/
|
||||
@MappingField(value = "COLUMN_TYPE")
|
||||
private String columnType;
|
||||
private String columnType;
|
||||
|
||||
/**
|
||||
* 列长度
|
||||
*/
|
||||
@MappingField(value = "COLUMN_LENGTH")
|
||||
private String columnLength;
|
||||
private String columnLength;
|
||||
}
|
||||
|
||||
@@ -34,30 +34,30 @@ public class PhoenixPrimaryKeyModel implements PrimaryKey {
|
||||
* 主键名称
|
||||
*/
|
||||
@MappingField(value = "PK_NAME")
|
||||
private String pkName;
|
||||
private String pkName;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "TABLE_SCHEM")
|
||||
private String tableSchem;
|
||||
private String tableSchem;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@MappingField(value = "KEY_SEQ")
|
||||
private String keySeq;
|
||||
private String keySeq;
|
||||
/**
|
||||
* tableCat
|
||||
*/
|
||||
@MappingField(value = "TABLE_CAT")
|
||||
private String tableCat;
|
||||
private String tableCat;
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
@MappingField(value = "COLUMN_NAME")
|
||||
private String columnName;
|
||||
private String columnName;
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@MappingField(value = "TABLE_NAME")
|
||||
private String tableName;
|
||||
private String tableName;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* screw-core - 简洁好用的数据库表结构文档生成工具
|
||||
* Copyright © 2020 SanLi (qinggang.zuo@gmail.com)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cn.smallbun.screw.core.query.phoenix.model;
|
||||
|
||||
import cn.smallbun.screw.core.metadata.Database;
|
||||
@@ -5,9 +22,7 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author xielongwang
|
||||
* @create 2020/8/19 4:55 下午
|
||||
* @email siaron.wang@gmail.com
|
||||
* @description
|
||||
* Created by siaron.wang@gmail.com 2020/8/19 4:55 下午
|
||||
*/
|
||||
@Data
|
||||
public class PhoenixSqlDatabaseModel implements Database {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# screw-core - \u7B80\u6D01\u597D\u7528\u7684\u6570\u636E\u5E93\u8868\u7ED3\u6784\u6587\u6863\u751F\u6210\u5DE5\u5177
|
||||
# Copyright \u00A9 2020 SanLi (qinggang.zuo@gmail.com)
|
||||
# screw-core - 简洁好用的数据库表结构文档生成工具
|
||||
# Copyright © 2020 SanLi (qinggang.zuo@gmail.com)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
#
|
||||
# screw-core - 简洁好用的数据库表结构文档生成工具
|
||||
# Copyright © 2020 SanLi (qinggang.zuo@gmail.com)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
driver=org.apache.phoenix.jdbc.PhoenixDriver
|
||||
url=jdbc:phoenix:xxxx:2181
|
||||
username=username
|
||||
|
||||
@@ -59,22 +59,22 @@ public class PhoenixDocumentationBuilderTest extends AbstractDocumentationExecut
|
||||
DataSource dataSource = new HikariDataSource(hikariConfig);
|
||||
//生成配置
|
||||
EngineConfig engineConfig = EngineConfig.builder()
|
||||
//生成文件路径
|
||||
.fileOutputDir(fileOutputDir)
|
||||
//文件类型
|
||||
.fileType(EngineFileType.HTML)
|
||||
//生成模板实现
|
||||
.produceType(EngineTemplateType.freemarker).build();
|
||||
//生成文件路径
|
||||
.fileOutputDir(fileOutputDir)
|
||||
//文件类型
|
||||
.fileType(EngineFileType.HTML)
|
||||
//生成模板实现
|
||||
.produceType(EngineTemplateType.freemarker).build();
|
||||
//配置
|
||||
Configuration config = Configuration.builder()
|
||||
//版本
|
||||
.version("1.0.0")
|
||||
//描述
|
||||
.description("数据库设计文档生成")
|
||||
//数据源
|
||||
.dataSource(dataSource)
|
||||
//生成配置
|
||||
.engineConfig(engineConfig).build();
|
||||
//版本
|
||||
.version("1.0.0")
|
||||
//描述
|
||||
.description("数据库设计文档生成")
|
||||
//数据源
|
||||
.dataSource(dataSource)
|
||||
//生成配置
|
||||
.engineConfig(engineConfig).build();
|
||||
|
||||
execute(config);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user