Add query column data type

This commit is contained in:
SwallowGG
2023-09-13 00:36:13 +08:00
parent 663083d563
commit 4f47d3095f
4 changed files with 198 additions and 21 deletions

View File

@ -166,7 +166,7 @@ public class TableController {
* @param request
* @return
*/
@GetMapping("/modify/sql")
@PostMapping("/modify/sql")
public ListResult<SqlVO> modifySql(@Valid TableModifySqlRequest request) {
return tableService.buildSql(
rdbWebConverter.tableRequest2param(request.getOldTable()),

View File

@ -2,6 +2,7 @@ package ai.chat2db.server.web.api.controller.rdb.vo;
import ai.chat2db.spi.enums.ColumnTypeEnum;
import com.fasterxml.jackson.annotation.JsonAlias;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -18,27 +19,52 @@ import lombok.experimental.SuperBuilder;
@AllArgsConstructor
public class ColumnVO {
/**
* 名称
* 旧的列名,在修改列的时候需要这个参数
* 在返回的时候oldName=name
*/
private String oldName;
/**
* 列名
*/
private String name;
/**
* 列的类型
*
* @see ColumnTypeEnum
* 表名
*/
private String dataType;
private String tableName;
/**
* 列的类型
* 比如 varchar(100) ,double(10,6)
*/
private String columnType;
/**
* 是否为空
* 列的数据类型
* 比如 varchar ,double
*/
private Integer nullable;
private Integer dataType;
/**
* 默认值
*/
private String defaultValue;
/**
* 是否自增
* 为空 代表没有值 数据库的实际语义是 false
*/
private Boolean autoIncrement;
/**
* 注释
*/
private String comment;
/**
* 是否主键
@ -46,33 +72,85 @@ public class ColumnVO {
private Boolean primaryKey;
/**
* 默认值
* 空间名
*/
private String defaultValue;
private String schemaName;
/**
* 是否自增
* 数据库名
*/
private Boolean autoIncrement;
private String databaseName;
/**
* 数字精度
* Data source dependent type name, for a UDT the type name is fully qualified
*/
private Integer numericPrecision;
private String typeName;
/**
* 数字比例
* column size.
*/
private Integer numericScale;
private Integer columnSize;
/**
* 字符串最大长度
* is not used.
*/
private Integer characterMaximumLength;
private Integer bufferLength;
/**
* 注释
* the number of fractional digits. Null is returned for data types where DECIMAL_DIGITS is not applicable.
*/
private String comment;
private Integer decimalDigits;
/**
* Radix (typically either 10 or 2)
*/
private Integer numPrecRadix;
/**
* is NULL allowed.
* columnNoNulls - might not allow NULL values
* columnNullable - definitely allows NULL values
* columnNullableUnknown - nullability unknown
*/
private Integer nullableInt;
/**
* unused
*/
private Integer sqlDataType;
/**
* unused
*/
private Integer sqlDatetimeSub;
/**
* for char types the maximum number of bytes in the column
*/
private Integer charOctetLength;
/**
* index of column in table (starting at 1)
*/
private Integer ordinalPosition;
/**
* ISO rules are used to determine the nullability for a column.
*/
private Integer nullable;
/**
* String => Indicates whether this is a generated column
* * YES --- if this a generated column
* * NO --- if this not a generated column
*/
private Boolean generatedColumn;
}

View File

@ -0,0 +1,99 @@
package ai.chat2db.server.web.api.controller.rdb.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* 列信息
*
* @author Jiaju Zhuang
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class IndexColumnVO {
/**
* 索引名称
*/
private String indexName;
/**
* 表名
*/
private String tableName;
/**
* 索引类型
*
* @see
*/
private String type;
/**
* 注释
*/
private String comment;
/**
* 列名
*/
private String columnName;
/**
* 顺序
*/
private Short ordinalPosition;
/**
* 排序
*
*/
private String collation;
/**
* 索引所属schema
*/
private String schemaName;
/**
* 数据库名
*/
private String databaseName;
/**
* 是否唯一
*/
private Boolean nonUnique;
/**
* index catalog (may be null); null when TYPE is tableIndexStatistic
*/
private String indexQualifier;
/**
* ASC_OR_DESC String => column sort sequence, "A" => ascending, "D" => descending, may be null if sort sequence is not supported; null when TYPE is tableIndexStatistic
*/
private String ascOrDesc;
/**
* CARDINALITY long => When TYPE is tableIndexStatistic, then this is the number of rows in the table; otherwise, it is the number of unique values in the index.
*/
private Long cardinality;
/**
* When TYPE is tableIndexStatistic then this is the number of pages used for the table, otherwise it is the number of pages used for the current index.
*/
private Long pages;
/**
* Filter condition, if any. (may be null)
*/
private String filterCondition;
}

View File

@ -39,5 +39,5 @@ public class IndexVO {
/**
* 索引包含的列
*/
private List<ColumnVO> columnList;
private List<IndexColumnVO> columnList;
}