mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-30 03:03:13 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@ -503,18 +503,7 @@ const ColumnList = forwardRef((props: IProps, ref: ForwardedRef<IColumnListRef>)
|
||||
)}
|
||||
{editingConfig?.supportDefaultValue && (
|
||||
<Form.Item labelCol={labelCol} label={i18n('editTable.label.defaultValue')} name="defaultValue">
|
||||
<CustomSelect
|
||||
options={[
|
||||
{
|
||||
label: 'EMPTY_STRING',
|
||||
value: 'EMPTY_STRING',
|
||||
},
|
||||
{
|
||||
label: 'NULL',
|
||||
value: 'NULL',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<CustomSelect options={databaseSupportField.defaultValues} />
|
||||
</Form.Item>
|
||||
)}
|
||||
{editingConfig?.supportCharset && (
|
||||
|
@ -54,6 +54,7 @@ export interface IDatabaseSupportField {
|
||||
charsets: IOption[];
|
||||
collations: IOption[];
|
||||
indexTypes: IOption[];
|
||||
defaultValues: IOption[];
|
||||
}
|
||||
|
||||
export default memo((props: IProps) => {
|
||||
@ -93,6 +94,7 @@ export default memo((props: IProps) => {
|
||||
charsets: [],
|
||||
collations: [],
|
||||
indexTypes: [],
|
||||
defaultValues: [],
|
||||
});
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
|
||||
@ -148,11 +150,20 @@ export default memo((props: IProps) => {
|
||||
};
|
||||
}) || [];
|
||||
|
||||
const defaultValues =
|
||||
res?.defaultValues?.map((i) => {
|
||||
return {
|
||||
value: i.defaultValue,
|
||||
label: i.defaultValue,
|
||||
};
|
||||
}) || [];
|
||||
|
||||
setDatabaseSupportField({
|
||||
columnTypes,
|
||||
charsets,
|
||||
collations,
|
||||
indexTypes,
|
||||
defaultValues,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ export interface IDatabaseSupportField {
|
||||
charsets: ICharset[];
|
||||
collations: ICollation[];
|
||||
indexTypes: IIndexTypes[];
|
||||
defaultValues: IDefaultValue[];
|
||||
}
|
||||
|
||||
/** 字段所对应的 字符集*/
|
||||
@ -84,3 +85,8 @@ export interface IColumnTypes {
|
||||
supportValue: boolean; // 是否支持值
|
||||
supportUnit: boolean; // 是否支持单位
|
||||
}
|
||||
|
||||
/** 不同数据库支持不同的默认值 */
|
||||
export interface IDefaultValue {
|
||||
defaultValue: string; // 默认值
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import ai.chat2db.plugin.db2.builder.DB2SqlBuilder;
|
||||
import ai.chat2db.plugin.db2.type.DB2ColumnTypeEnum;
|
||||
import ai.chat2db.plugin.db2.type.DB2DefaultValueEnum;
|
||||
import ai.chat2db.plugin.db2.type.DB2IndexTypeEnum;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
@ -152,6 +153,7 @@ public class DB2MetaData extends DefaultMetaService implements MetaData {
|
||||
.charsets(Lists.newArrayList())
|
||||
.collations(Lists.newArrayList())
|
||||
.indexTypes(DB2IndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(DB2DefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package ai.chat2db.plugin.db2.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum DB2DefaultValueEnum {
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
DB2DefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(DB2DefaultValueEnum.values()).map(DB2DefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import ai.chat2db.plugin.dm.builder.DMSqlBuilder;
|
||||
import ai.chat2db.plugin.dm.type.DMColumnTypeEnum;
|
||||
import ai.chat2db.plugin.dm.type.DMDefaultValueEnum;
|
||||
import ai.chat2db.plugin.dm.type.DMIndexTypeEnum;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
@ -218,6 +219,7 @@ public class DMMetaData extends DefaultMetaService implements MetaData {
|
||||
.charsets(Lists.newArrayList())
|
||||
.collations(Lists.newArrayList())
|
||||
.indexTypes(DMIndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(DMDefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package ai.chat2db.plugin.dm.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum DMDefaultValueEnum {
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
DMDefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(DMDefaultValueEnum.values()).map(DMDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package ai.chat2db.plugin.kingbase;
|
||||
|
||||
import ai.chat2db.plugin.kingbase.builder.KingBaseSqlBuilder;
|
||||
import ai.chat2db.plugin.kingbase.type.KingBaseColumnTypeEnum;
|
||||
import ai.chat2db.plugin.kingbase.type.KingBaseDefaultValueEnum;
|
||||
import ai.chat2db.plugin.kingbase.type.KingBaseIndexTypeEnum;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
@ -196,6 +197,7 @@ public class KingBaseMetaData extends DefaultMetaService implements MetaData {
|
||||
//.charsets(PostgreSQLCharsetEnum.getCharsets())
|
||||
//.collations(PostgreSQLCollationEnum.getCollations())
|
||||
.indexTypes(KingBaseIndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(KingBaseDefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
@Override
|
||||
|
@ -0,0 +1,27 @@
|
||||
package ai.chat2db.plugin.kingbase.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum KingBaseDefaultValueEnum {
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
KingBaseDefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(KingBaseDefaultValueEnum.values()).map(KingBaseDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -8,10 +8,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import ai.chat2db.plugin.mysql.builder.MysqlSqlBuilder;
|
||||
import ai.chat2db.plugin.mysql.type.MysqlCharsetEnum;
|
||||
import ai.chat2db.plugin.mysql.type.MysqlCollationEnum;
|
||||
import ai.chat2db.plugin.mysql.type.MysqlColumnTypeEnum;
|
||||
import ai.chat2db.plugin.mysql.type.MysqlIndexTypeEnum;
|
||||
import ai.chat2db.plugin.mysql.type.*;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
import ai.chat2db.spi.ValueHandler;
|
||||
@ -287,6 +284,7 @@ public class MysqlMetaData extends DefaultMetaService implements MetaData {
|
||||
.charsets(MysqlCharsetEnum.getCharsets())
|
||||
.collations(MysqlCollationEnum.getCollations())
|
||||
.indexTypes(MysqlIndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(MysqlDefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package ai.chat2db.plugin.mysql.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum MysqlDefaultValueEnum {
|
||||
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
CURRENT_TIMESTAMP("CURRENT_TIMESTAMP"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
MysqlDefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(MysqlDefaultValueEnum.values()).map(MysqlDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import ai.chat2db.plugin.oracle.builder.OracleSqlBuilder;
|
||||
import ai.chat2db.plugin.oracle.type.OracleColumnTypeEnum;
|
||||
import ai.chat2db.plugin.oracle.type.OracleDefaultValueEnum;
|
||||
import ai.chat2db.plugin.oracle.type.OracleIndexTypeEnum;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
@ -295,6 +296,7 @@ public class OracleMetaData extends DefaultMetaService implements MetaData {
|
||||
.charsets(Lists.newArrayList())
|
||||
.collations(Lists.newArrayList())
|
||||
.indexTypes(OracleIndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(OracleDefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package ai.chat2db.plugin.oracle.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum OracleDefaultValueEnum {
|
||||
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
OracleDefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(OracleDefaultValueEnum.values()).map(OracleDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -7,10 +7,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import ai.chat2db.plugin.postgresql.builder.PostgreSQLSqlBuilder;
|
||||
import ai.chat2db.plugin.postgresql.type.PostgreSQLCharsetEnum;
|
||||
import ai.chat2db.plugin.postgresql.type.PostgreSQLCollationEnum;
|
||||
import ai.chat2db.plugin.postgresql.type.PostgreSQLColumnTypeEnum;
|
||||
import ai.chat2db.plugin.postgresql.type.PostgreSQLIndexTypeEnum;
|
||||
import ai.chat2db.plugin.postgresql.type.*;
|
||||
import ai.chat2db.server.tools.common.util.EasyCollectionUtils;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
@ -301,6 +298,7 @@ public class PostgreSQLMetaData extends DefaultMetaService implements MetaData {
|
||||
.charsets(PostgreSQLCharsetEnum.getCharsets())
|
||||
.collations(PostgreSQLCollationEnum.getCollations())
|
||||
.indexTypes(PostgreSQLIndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(PostgreSQLDefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package ai.chat2db.plugin.postgresql.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum PostgreSQLDefaultValueEnum {
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
PostgreSQLDefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(PostgreSQLDefaultValueEnum.values()).map(PostgreSQLDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -9,6 +9,7 @@ import java.util.stream.Collectors;
|
||||
import ai.chat2db.plugin.sqlite.builder.SqliteBuilder;
|
||||
import ai.chat2db.plugin.sqlite.type.SqliteCollationEnum;
|
||||
import ai.chat2db.plugin.sqlite.type.SqliteColumnTypeEnum;
|
||||
import ai.chat2db.plugin.sqlite.type.SqliteDefaultValueEnum;
|
||||
import ai.chat2db.plugin.sqlite.type.SqliteIndexTypeEnum;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
@ -56,6 +57,7 @@ public class SqliteMetaData extends DefaultMetaService implements MetaData {
|
||||
.charsets(null)
|
||||
.collations(SqliteCollationEnum.getCollations())
|
||||
.indexTypes(SqliteIndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(SqliteDefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package ai.chat2db.plugin.sqlite.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum SqliteDefaultValueEnum {
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
SqliteDefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(SqliteDefaultValueEnum.values()).map(SqliteDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import ai.chat2db.plugin.sqlserver.builder.SqlServerSqlBuilder;
|
||||
import ai.chat2db.plugin.sqlserver.type.SqlServerColumnTypeEnum;
|
||||
import ai.chat2db.plugin.sqlserver.type.SqlServerDefaultValueEnum;
|
||||
import ai.chat2db.plugin.sqlserver.type.SqlServerIndexTypeEnum;
|
||||
import ai.chat2db.spi.MetaData;
|
||||
import ai.chat2db.spi.SqlBuilder;
|
||||
@ -382,6 +383,7 @@ public class SqlServerMetaData extends DefaultMetaService implements MetaData {
|
||||
.charsets(null)
|
||||
.collations(null)
|
||||
.indexTypes(SqlServerIndexTypeEnum.getIndexTypes())
|
||||
.defaultValues(SqlServerDefaultValueEnum.getDefaultValues())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package ai.chat2db.plugin.sqlserver.type;
|
||||
|
||||
import ai.chat2db.spi.model.DefaultValue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum SqlServerDefaultValueEnum {
|
||||
EMPTY_STRING("EMPTY_STRING"),
|
||||
NULL("NULL"),
|
||||
;
|
||||
private DefaultValue defaultValue;
|
||||
|
||||
SqlServerDefaultValueEnum(String defaultValue) {
|
||||
this.defaultValue = new DefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
public DefaultValue getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static List<DefaultValue> getDefaultValues() {
|
||||
return Arrays.stream(SqlServerDefaultValueEnum.values()).map(SqlServerDefaultValueEnum::getDefaultValue).collect(java.util.stream.Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
@ -74,7 +74,10 @@ public class Chat2dbAIClient {
|
||||
apikey = ApplicationContextUtil.getProperty(CHAT2DB_OPENAI_KEY);
|
||||
}
|
||||
Config modelConfig = configService.find(CHAT2DB_OPENAI_MODEL).getData();
|
||||
String model = modelConfig.getContent();
|
||||
String model = "";
|
||||
if (modelConfig != null) {
|
||||
model = modelConfig.getContent();
|
||||
}
|
||||
log.info("refresh chat2db apikey:{}", maskApiKey(apikey));
|
||||
CHAT2DB_AI_STREAM_CLIENT = Chat2DBAIStreamClient.builder().apiHost(apiHost)
|
||||
.apiKey(apikey).model(model).build();
|
||||
|
@ -0,0 +1,12 @@
|
||||
package ai.chat2db.spi.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DefaultValue {
|
||||
|
||||
private String defaultValue;
|
||||
|
||||
}
|
@ -19,4 +19,6 @@ public class TableMeta {
|
||||
|
||||
|
||||
private List<IndexType> indexTypes;
|
||||
|
||||
private List<DefaultValue> defaultValues;
|
||||
}
|
||||
|
Reference in New Issue
Block a user