chore: initialize qiming workspace repository
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.xspaceagi</groupId>
|
||||
<artifactId>app-platform-compose</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<artifactId>app-platform-compose-sdk</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.xspaceagi.compose.sdk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xspaceagi.compose.sdk.vo.data.FrontColumnDefineVo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 前端list交互规范结构
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class DorisDataPage<T> extends Page<T> {
|
||||
|
||||
@Schema(description = "excel抬头字段定义")
|
||||
private List<FrontColumnDefineVo> columnDefines;
|
||||
|
||||
/**
|
||||
* @param current 当前页
|
||||
* @param size 每页显示条数
|
||||
*/
|
||||
public DorisDataPage(long current, long size) {
|
||||
super(current, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param current 当前页
|
||||
* @param size 每页显示条数
|
||||
* @param orders 排序字段
|
||||
*/
|
||||
public DorisDataPage(long current, long size, List<OrderItem> orders) {
|
||||
super(current, size);
|
||||
if (!CollectionUtils.isEmpty(orders)) {
|
||||
this.addOrder(orders);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 页大小
|
||||
* @param total 总条数
|
||||
*/
|
||||
public DorisDataPage(long pageNo, long pageSize, long total) {
|
||||
super(pageNo, pageSize, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 页大小
|
||||
* @param total 总条数
|
||||
* @param records 数据
|
||||
*/
|
||||
public DorisDataPage(long pageNo, long pageSize, long total, List<T> records) {
|
||||
super(pageNo, pageSize, total);
|
||||
this.setRecords(records);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换 IPage 的对象类型
|
||||
*/
|
||||
public static <O> DorisDataPage<O> build(DorisDataPage<?> in, List<O> records) {
|
||||
return new DorisDataPage<>(in.getCurrent(), in.getSize(), in.getTotal(), records);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.xspaceagi.compose.sdk.enums;
|
||||
|
||||
public class Arrays {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.xspaceagi.compose.sdk.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.xspaceagi.compose.sdk.vo.define.TableFieldDefineVo;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 系统默认的固定字段,所有的表定义必须包含这些字段
|
||||
*/
|
||||
@Getter
|
||||
public enum DefaultTableFieldEnum {
|
||||
|
||||
ID("id", "主键ID", TableFieldTypeEnum.PRIMARY_KEY, -1, null, -1, 1),
|
||||
UID("uid", "用户唯一标识", TableFieldTypeEnum.STRING, -1, null, -1, 1),
|
||||
USER_NAME("user_name", "用户名", TableFieldTypeEnum.STRING, 1, null, -1, 1),
|
||||
NICK_NAME("nick_name", "用户昵称", TableFieldTypeEnum.STRING, 1, null, -1, 1),
|
||||
AGENT_ID("agent_id", "智能体唯一标识", TableFieldTypeEnum.STRING, 1, null, -1, 1),
|
||||
AGENT_NAME("agent_name", "智能体名称", TableFieldTypeEnum.STRING, 1, null, -1, 1),
|
||||
CREATED("created", "数据创建时间", TableFieldTypeEnum.DATE, -1, "CURRENT_TIMESTAMP", -1, 1),
|
||||
MODIFIED("modified", "数据修改时间", TableFieldTypeEnum.DATE, -1, "CURRENT_TIMESTAMP", -1, 1);
|
||||
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private final String fieldName;
|
||||
|
||||
/**
|
||||
* 字段描述
|
||||
*/
|
||||
private final String fieldDescription;
|
||||
|
||||
/**
|
||||
* 字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date
|
||||
*/
|
||||
private final TableFieldTypeEnum fieldType;
|
||||
|
||||
/**
|
||||
* 是否可为空:1-可空 -1-非空
|
||||
*/
|
||||
private final Integer nullableFlag;
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
private final String defaultValue;
|
||||
|
||||
/**
|
||||
* 是否唯一:1-唯一 -1-非唯一
|
||||
*/
|
||||
private final Integer uniqueFlag;
|
||||
|
||||
/**
|
||||
* 是否启用:1-启用 -1-禁用
|
||||
*/
|
||||
private final Integer enabledFlag;
|
||||
|
||||
DefaultTableFieldEnum(String fieldName,
|
||||
String fieldDescription,
|
||||
TableFieldTypeEnum fieldType,
|
||||
Integer nullableFlag,
|
||||
String defaultValue,
|
||||
Integer uniqueFlag,
|
||||
Integer enabledFlag) {
|
||||
this.fieldName = fieldName;
|
||||
this.fieldDescription = fieldDescription;
|
||||
this.fieldType = fieldType;
|
||||
this.nullableFlag = nullableFlag;
|
||||
this.defaultValue = defaultValue;
|
||||
this.uniqueFlag = uniqueFlag;
|
||||
this.enabledFlag = enabledFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将枚举转换为字段定义VO
|
||||
*/
|
||||
public TableFieldDefineVo toFieldDefineVo() {
|
||||
return TableFieldDefineVo.builder()
|
||||
.id(null)
|
||||
.systemFieldFlag(1)
|
||||
.fieldName(this.fieldName)
|
||||
.fieldDescription(this.fieldDescription)
|
||||
.fieldType(this.fieldType.getCode())
|
||||
.nullableFlag(this.nullableFlag)
|
||||
.defaultValue(this.defaultValue)
|
||||
.uniqueFlag(this.uniqueFlag)
|
||||
.enabledFlag(this.enabledFlag)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有默认字段
|
||||
*
|
||||
* @return 默认字段列表
|
||||
*/
|
||||
public static List<TableFieldDefineVo> getAllDefaultFields() {
|
||||
return Arrays.stream(DefaultTableFieldEnum.values())
|
||||
.map(DefaultTableFieldEnum::toFieldDefineVo)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字段名获取对应的枚举值
|
||||
*
|
||||
* @param fieldName 字段名
|
||||
* @return 对应的枚举值,如果找不到则返回null
|
||||
*/
|
||||
public static DefaultTableFieldEnum getEnumByFieldName(String fieldName) {
|
||||
return Arrays.stream(DefaultTableFieldEnum.values())
|
||||
.filter(field -> field.getFieldName().equals(fieldName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.xspaceagi.compose.sdk.enums;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 字段类型枚举,包含原始类型、对应的 Apache Doris 数据类型映射以及默认的完整类型定义
|
||||
* String -> VARCHAR -> VARCHAR(255)
|
||||
* Integer -> INT -> INT
|
||||
* Number -> DOUBLE -> DECIMAL(20,6) // 注意:之前是 DOUBLE,现在改为 DECIMAL 以提供更精确的数值类型
|
||||
* Boolean -> BOOLEAN -> TINYINT(1)
|
||||
* Date -> DATETIME-> DATETIME
|
||||
* PrimaryKey -> BIGINT -> BIGINT AUTO_INCREMENT // 主键类型,用于自增主键
|
||||
* MEDIUMTEXT -> MEDIUMTEXT -> MEDIUMTEXT // 文本类型,用于存储较长的文本数据
|
||||
*/
|
||||
@Getter
|
||||
@Schema(description = "字段类型:1:String(VARCHAR(255));2:Integer(INT);3:Number(DECIMAL(20,6));4:Boolean(TINYINT(1));5:Date(DATETIME);6:PrimaryKey(BIGINT);7:MEDIUMTEXT(MEDIUMTEXT)")
|
||||
public enum TableFieldTypeEnum {
|
||||
|
||||
STRING(1, "String", "VARCHAR", "VARCHAR(255)", "VARCHAR", "VARCHAR(255)"),
|
||||
INTEGER(2, "Integer", "INT", "INT", "INT", "INT"),
|
||||
NUMBER(3, "Number", "DECIMAL", "DECIMAL(28,6)", "DECIMAL", "DECIMAL(28,6)"),
|
||||
BOOLEAN(4, "Boolean", "BOOLEAN", "TINYINT(1)", "TINYINT", "TINYINT(1)"),
|
||||
DATE(5, "Date", "DATETIME", "DATETIME", "DATETIME", "DATETIME"),
|
||||
PRIMARY_KEY(6, "PrimaryKey", "BIGINT", "BIGINT(20)", "BIGINT", "BIGINT(20)"),
|
||||
MEDIUMTEXT(7, "MediumText", "TEXT", "TEXT", "MEDIUMTEXT", "MEDIUMTEXT");
|
||||
|
||||
private final Integer code;
|
||||
private final String name;
|
||||
private final String dorisType; // 基础 Doris 类型 (例如 VARCHAR, INT)
|
||||
private final String dorisDefinition; // 完整的默认 Doris 类型定义 (例如 VARCHAR(255), DECIMAL(20,6))
|
||||
private final String mysqlType; // 基础 MySQL 类型 (例如 VARCHAR, INT)
|
||||
private final String mysqlDefinition; // 完整的默认 MySQL 类型定义 (例如 VARCHAR(255), DECIMAL(20,6))
|
||||
|
||||
TableFieldTypeEnum(Integer code, String name, String dorisType, String dorisDefinition, String mysqlType, String mysqlDefinition) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.dorisType = dorisType;
|
||||
this.dorisDefinition = dorisDefinition;
|
||||
this.mysqlType = mysqlType;
|
||||
this.mysqlDefinition = mysqlDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Doris/MySQL 类型获取枚举值
|
||||
*
|
||||
* @param dorisType Doris/MySQL类型
|
||||
* @return 枚举值
|
||||
*/
|
||||
public static TableFieldTypeEnum tryGetByDorisType(String dorisType) {
|
||||
return Arrays.stream(TableFieldTypeEnum.values())
|
||||
.filter(type -> type.getDorisType().equals(dorisType))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.xspaceagi.compose.sdk.request;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 查询doris表数据
|
||||
*/
|
||||
@Schema(description = "查询doris表数据")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class DorisTableDataRequest {
|
||||
|
||||
/**
|
||||
* 表ID
|
||||
*/
|
||||
@Schema(description = "表ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonPropertyDescription("表ID")
|
||||
private Long tableId;
|
||||
|
||||
/**
|
||||
* sql
|
||||
*/
|
||||
@Schema(description = "sql")
|
||||
@JsonPropertyDescription("sql")
|
||||
private String sql;
|
||||
|
||||
/**
|
||||
* 绑定sql的参数,比如: a = 1, b = 2,用于替换sql中的参数绑定
|
||||
*/
|
||||
@Schema(description = "绑定sql的参数")
|
||||
@JsonPropertyDescription("绑定sql的参数")
|
||||
private Map<String, Object> args;
|
||||
|
||||
/**
|
||||
* 扩展参数,比如:uid = 123, spaceId = 122,用于额外限制条件,加入到查询sql语句中
|
||||
*/
|
||||
@Schema(description = "扩展参数,比如:uid = 123, spaceId = 122,用于额外限制条件,加入到查询sql语句中")
|
||||
private Map<String, Object> extArgs;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xspaceagi.compose.sdk.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 查询doris表结构定义
|
||||
*/
|
||||
@Schema(description = "查询doris表结构定义")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class DorisTableDefineRequest {
|
||||
|
||||
/**
|
||||
* 表ID
|
||||
*/
|
||||
@Schema(description = "表ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonPropertyDescription("表ID")
|
||||
private Long tableId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xspaceagi.compose.sdk.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 查询用户可以使用的数据表组件的,对应的表结构定义信息
|
||||
*/
|
||||
@Schema(description = "查询用户可以使用的数据表组件的,对应的表结构定义信息")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class DorisToolTableDefineRequest {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Schema(description = "用户ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonPropertyDescription("用户ID")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 空间ID
|
||||
*/
|
||||
@Schema(description = "空间ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
|
||||
@JsonPropertyDescription("空间ID")
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonPropertyDescription("租户ID")
|
||||
private Long tenantId;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.xspaceagi.compose.sdk.request;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 分页查询doris表结构定义
|
||||
*/
|
||||
@Schema(description = "分页查询doris表结构定义")
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class QueryDorisTableDefinePageRequest {
|
||||
|
||||
/**
|
||||
* 空间ID
|
||||
*/
|
||||
@Schema(description = "空间ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonPropertyDescription("空间ID")
|
||||
private Long spaceId;
|
||||
|
||||
|
||||
/**
|
||||
* 关键字搜索
|
||||
*/
|
||||
@Schema(description = "关键字搜索")
|
||||
@JsonPropertyDescription("关键字搜索")
|
||||
private String kw;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
@Schema(description = "页码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonPropertyDescription("页码")
|
||||
private Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
@Schema(description = "每页条数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@JsonPropertyDescription("每页条数")
|
||||
private Integer pageSize;
|
||||
|
||||
@Schema(description = "空间ID列表,查询用户有权限的空间,限制访问空间,比如工作流查询全部知识库,要限制用户有权限的空间下的知识库")
|
||||
@JsonPropertyDescription("空间ID列表,查询用户有权限的空间,限制访问空间,比如工作流查询全部知识库,要限制用户有权限的空间下的知识库")
|
||||
private List<Long> authSpaceIds;
|
||||
|
||||
@Schema(description = "创建人ID列表")
|
||||
@JsonPropertyDescription("创建人ID列表")
|
||||
private List<Long> creatorIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.xspaceagi.compose.sdk.response;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
import com.xspaceagi.compose.sdk.vo.define.TableDefineVo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* doris 表数据查询响应
|
||||
*/
|
||||
@Schema(description = "doris 表数据查询响应")
|
||||
@Getter
|
||||
@Setter
|
||||
public class DorisTableDataResponse implements Serializable {
|
||||
/**
|
||||
* 表结构定义
|
||||
*/
|
||||
@Schema(description = "表结构定义")
|
||||
@JsonPropertyDescription("表结构定义")
|
||||
private TableDefineVo tableDefineVo;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
@Schema(description = "数据")
|
||||
@JsonPropertyDescription("数据")
|
||||
private List<Map<String, Object>> data;
|
||||
|
||||
/**
|
||||
* 影响的数据行数
|
||||
*/
|
||||
@Schema(description = "影响的数据行数")
|
||||
@JsonPropertyDescription("影响的数据行数")
|
||||
private Long rowNum;
|
||||
|
||||
/**
|
||||
* 数据主键id,新增sql会有对应的id
|
||||
* <p>
|
||||
* 注意: 新增sql会有对应的id,查询sql没有;且新增 insert语句必须是单条插入
|
||||
* </p>
|
||||
*/
|
||||
@Schema(description = "数据主键id,新增sql会有对应的id")
|
||||
@JsonPropertyDescription("数据主键id,新增sql会有对应的id")
|
||||
private Long rowId;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.xspaceagi.compose.sdk.response;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
import com.xspaceagi.compose.sdk.vo.define.TableDefineVo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* doris 用户可以使用的数据表组件的,对应的表结构定义信息查询响应
|
||||
*/
|
||||
@Schema(description = "doris 用户可以使用的数据表组件的,对应的表结构定义信息查询响应")
|
||||
@Getter
|
||||
@Setter
|
||||
public class DorisToolTableDefineResponse implements Serializable {
|
||||
|
||||
/**
|
||||
* 表结构定义
|
||||
*/
|
||||
@Schema(description = "表结构定义列表")
|
||||
@JsonPropertyDescription("表结构定义列表")
|
||||
private List<TableDefineVo> tableDefineList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.xspaceagi.compose.sdk.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.xspaceagi.compose.sdk.DorisDataPage;
|
||||
import com.xspaceagi.compose.sdk.request.DorisTableDataRequest;
|
||||
import com.xspaceagi.compose.sdk.request.DorisTableDefineRequest;
|
||||
import com.xspaceagi.compose.sdk.request.DorisToolTableDefineRequest;
|
||||
import com.xspaceagi.compose.sdk.request.QueryDorisTableDefinePageRequest;
|
||||
import com.xspaceagi.compose.sdk.response.DorisTableDataResponse;
|
||||
import com.xspaceagi.compose.sdk.response.DorisToolTableDefineResponse;
|
||||
import com.xspaceagi.compose.sdk.vo.define.CreateTableDefineVo;
|
||||
import com.xspaceagi.compose.sdk.vo.define.TableDefineVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 提供数据表功能的查询服务,包含表结构信息查询,表数据查询等;另外支持 直接写sql查询, 支持自定义sql查询;
|
||||
*/
|
||||
public interface IComposeDbTableRpcService {
|
||||
|
||||
/**
|
||||
* 查询表结构信息
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 表结构定义信息
|
||||
*/
|
||||
TableDefineVo queryTableDefinition(DorisTableDefineRequest request);
|
||||
|
||||
/**
|
||||
* 查询表数据
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 表数据
|
||||
*/
|
||||
DorisTableDataResponse queryTableData(DorisTableDataRequest request);
|
||||
|
||||
/**
|
||||
* 查询用户可以使用的数据表组件的,对应的表结构定义信息;不分页,查询全部
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 表结构定义信息列表
|
||||
*/
|
||||
DorisToolTableDefineResponse queryUserToolTableDefine(DorisToolTableDefineRequest request);
|
||||
|
||||
/**
|
||||
* 根据空间id,分页查询数据表定义信息
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 表定义信息列表
|
||||
*/
|
||||
DorisDataPage<TableDefineVo> queryTableDefineBySpaceId(QueryDorisTableDefinePageRequest request);
|
||||
|
||||
/**
|
||||
* 根据空间id,查询数据表定义信息
|
||||
*
|
||||
* @param spaceId 空间id
|
||||
* @return 表定义信息列表
|
||||
*/
|
||||
List<TableDefineVo> queryListBySpaceId(Long spaceId);
|
||||
|
||||
/**
|
||||
* 创建表
|
||||
*
|
||||
* @param tableDefineVo 表定义信息
|
||||
*/
|
||||
Long createTable(CreateTableDefineVo tableDefineVo);
|
||||
|
||||
/**
|
||||
* 查询创建表的表结构定义信息
|
||||
*
|
||||
* @param request 请求参数
|
||||
* @return 表结构定义信息
|
||||
*/
|
||||
CreateTableDefineVo queryCreateTableInfo(DorisTableDefineRequest request);
|
||||
|
||||
/**
|
||||
* 统计数据表总数
|
||||
*
|
||||
* @return 数据表总数
|
||||
*/
|
||||
Long countTotalTables();
|
||||
|
||||
/**
|
||||
* 管理端查询数据表列表
|
||||
*
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 每页大小
|
||||
* @param name 名称模糊搜索
|
||||
* @param creatorIds 创建人ID列表
|
||||
* @param spaceId 空间ID
|
||||
* @return 数据表分页数据
|
||||
*/
|
||||
IPage<TableDefineVo> queryListForManage(Integer pageNo, Integer pageSize, String name, java.util.List<Long> creatorIds, Long spaceId);
|
||||
|
||||
/**
|
||||
* 管理端删除数据表
|
||||
*
|
||||
* @param id 表ID
|
||||
*/
|
||||
void deleteForManage(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户数据表总数
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 数据表总数
|
||||
*/
|
||||
Long countUserTotalTable(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
package com.xspaceagi.compose.sdk.vo.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class ExecuteRawResultVo {
|
||||
/**
|
||||
* 执行sql返回的数据
|
||||
*/
|
||||
private List<Map<String, Object>> data;
|
||||
/**
|
||||
* 执行sql影响的行数
|
||||
*/
|
||||
private Long rowNum;
|
||||
/**
|
||||
* 数据主键id,新增sql会有对应的id
|
||||
*/
|
||||
private Long rowId;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.xspaceagi.compose.sdk.vo.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 给前端页面使用,和内部使用的字段模型区别,内部字段标识都是 :1和-1; 这里转换为了Boolean属性类型
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "数据表业务表结构的字段定义")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FrontColumnDefineVo implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 是否为系统字段
|
||||
*/
|
||||
@Schema(description = "是否为系统字段")
|
||||
private Boolean systemFieldFlag;
|
||||
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
@Schema(description = "字段名")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 字段描述
|
||||
*/
|
||||
@Schema(description = "字段描述")
|
||||
private String fieldDescription;
|
||||
|
||||
/**
|
||||
* 字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date;6:PrimaryKey;7:MEDIUMTEXT
|
||||
* @see com.xspaceagi.compose.sdk.enums.TableFieldTypeEnum
|
||||
*/
|
||||
@Schema(description = "字段类型:1:String(VARCHAR(255));2:Integer(INT);3:Number(DECIMAL(20,6));4:Boolean(TINYINT(1));5:Date(DATETIME);6:PrimaryKey(BIGINT);7:MEDIUMTEXT(MEDIUMTEXT)")
|
||||
private Integer fieldType;
|
||||
|
||||
/**
|
||||
* 是否可为空
|
||||
*/
|
||||
@Schema(description = "是否可为空,true:可空;false:非空")
|
||||
private Boolean nullableFlag;
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
@Schema(description = "默认值")
|
||||
private String defaultValue;
|
||||
|
||||
/**
|
||||
* 是否唯一
|
||||
*/
|
||||
@Schema(description = "是否唯一,true:唯一;false:非唯一")
|
||||
private Boolean uniqueFlag;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
@Schema(description = "是否启用:true:启用;false:禁用")
|
||||
private Boolean enabledFlag;
|
||||
|
||||
/**
|
||||
* 字段顺序
|
||||
*/
|
||||
@Schema(description = "字段顺序")
|
||||
private Integer sortIndex;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.xspaceagi.compose.sdk.vo.define;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Schema(description = "表结构定义,新增数据表")
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class CreateTableDefineVo {
|
||||
|
||||
// /**
|
||||
// * 租户ID
|
||||
// */
|
||||
// @Schema(description = "租户ID")
|
||||
// @JsonPropertyDescription("租户ID")
|
||||
// private Long tenantId;
|
||||
//
|
||||
/**
|
||||
* 所属空间ID
|
||||
*/
|
||||
@Schema(description = "所属空间ID")
|
||||
@JsonPropertyDescription("所属空间ID")
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 图标图片地址
|
||||
*/
|
||||
@Schema(description = "图标图片地址")
|
||||
@JsonPropertyDescription("图标图片地址")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@Schema(description = "表名")
|
||||
@JsonPropertyDescription("表名")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表描述
|
||||
*/
|
||||
@Schema(description = "表描述")
|
||||
@JsonPropertyDescription("表描述")
|
||||
private String tableDescription;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@Schema(description = "创建人id")
|
||||
@JsonPropertyDescription("创建人id")
|
||||
@NotNull(message = "Creator ID is required")
|
||||
private Long creatorId;
|
||||
|
||||
|
||||
/**
|
||||
* 表下面的字段定义列表
|
||||
*/
|
||||
@Schema(description = "表下面的字段定义列表")
|
||||
@JsonPropertyDescription("表下面的字段定义列表")
|
||||
private List<TableFieldDefineVo> fieldList;
|
||||
|
||||
public static CreateTableDefineVo convert(TableDefineVo tableDefineVo) {
|
||||
return CreateTableDefineVo.builder()
|
||||
.spaceId(tableDefineVo.getSpaceId())
|
||||
.icon(tableDefineVo.getIcon())
|
||||
.tableName(tableDefineVo.getTableName())
|
||||
.tableDescription(tableDefineVo.getTableDescription())
|
||||
.creatorId(tableDefineVo.getCreatorId())
|
||||
.fieldList(tableDefineVo.getFieldList())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.xspaceagi.compose.sdk.vo.define;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Schema(description = "表结构定义")
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class TableDefineVo {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Schema(description = "主键ID")
|
||||
@JsonPropertyDescription("主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
@JsonPropertyDescription("租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 所属空间ID
|
||||
*/
|
||||
@Schema(description = "所属空间ID")
|
||||
@JsonPropertyDescription("所属空间ID")
|
||||
private Long spaceId;
|
||||
|
||||
/**
|
||||
* 图标图片地址
|
||||
*/
|
||||
@Schema(description = "图标图片地址")
|
||||
@JsonPropertyDescription("图标图片地址")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
@Schema(description = "表名")
|
||||
@JsonPropertyDescription("表名")
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表描述
|
||||
*/
|
||||
@Schema(description = "表描述")
|
||||
@JsonPropertyDescription("表描述")
|
||||
private String tableDescription;
|
||||
|
||||
/**
|
||||
* Doris数据库名
|
||||
*/
|
||||
@Schema(description = "Doris数据库名")
|
||||
@JsonPropertyDescription("Doris数据库名")
|
||||
private String dorisDatabase;
|
||||
|
||||
/**
|
||||
* Doris表名
|
||||
*/
|
||||
@Schema(description = "Doris表名")
|
||||
@JsonPropertyDescription("Doris表名")
|
||||
private String dorisTable;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@JsonPropertyDescription("创建时间")
|
||||
private LocalDateTime created;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@Schema(description = "创建人id")
|
||||
@JsonPropertyDescription("创建人id")
|
||||
private Long creatorId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
@JsonPropertyDescription("创建人")
|
||||
private String creatorName;
|
||||
|
||||
/**
|
||||
* 创建人昵称
|
||||
*/
|
||||
@Schema(description = "创建人昵称")
|
||||
@JsonPropertyDescription("创建人昵称")
|
||||
private String creatorNickName;
|
||||
|
||||
/**
|
||||
* 创建人头像
|
||||
*/
|
||||
@Schema(description = "创建人头像")
|
||||
@JsonPropertyDescription("创建人头像")
|
||||
private String creatorAvatar;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
@JsonPropertyDescription("更新时间")
|
||||
private LocalDateTime modified;
|
||||
|
||||
/**
|
||||
* 最后修改人id
|
||||
*/
|
||||
@Schema(description = "最后修改人id")
|
||||
@JsonPropertyDescription("最后修改人id")
|
||||
private Long modifiedId;
|
||||
|
||||
/**
|
||||
* 最后修改人
|
||||
*/
|
||||
@Schema(description = "最后修改人")
|
||||
@JsonPropertyDescription("最后修改人")
|
||||
private String modifiedName;
|
||||
|
||||
/**
|
||||
* 表下面的字段定义列表
|
||||
*/
|
||||
@Schema(description = "表下面的字段定义列表")
|
||||
@JsonPropertyDescription("表下面的字段定义列表")
|
||||
private List<TableFieldDefineVo> fieldList;
|
||||
|
||||
|
||||
@Schema(description = "原始建表DDL")
|
||||
@JsonPropertyDescription("原始建表DDL")
|
||||
private String createTableDdl;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.xspaceagi.compose.sdk.vo.define;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Schema(description = "表字段定义")
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class TableFieldDefineVo {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Schema(description = "主键ID")
|
||||
@JsonPropertyDescription("主键ID")
|
||||
private Long id;
|
||||
/**
|
||||
* 是否为系统字段,1:系统字段;-1:非系统字段
|
||||
*/
|
||||
@Schema(description = "是否为系统字段,1:系统字段;-1:非系统字段")
|
||||
@JsonPropertyDescription("是否为系统字段,1:系统字段;-1:非系统字段")
|
||||
private Integer systemFieldFlag;
|
||||
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
@Schema(description = "字段名")
|
||||
@JsonPropertyDescription("字段名")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 字段描述
|
||||
*/
|
||||
@Schema(description = "字段描述")
|
||||
@JsonPropertyDescription("字段描述")
|
||||
private String fieldDescription;
|
||||
|
||||
/**
|
||||
* 字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date
|
||||
*/
|
||||
@Schema(description = "字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date")
|
||||
@JsonPropertyDescription("字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date")
|
||||
private Integer fieldType;
|
||||
|
||||
/**
|
||||
* 是否可为空:1-可空 -1-非空
|
||||
*/
|
||||
@Schema(description = "是否可为空:1-可空 -1-非空")
|
||||
@JsonPropertyDescription("是否可为空:1-可空 -1-非空")
|
||||
private Integer nullableFlag;
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
@Schema(description = "默认值")
|
||||
@JsonPropertyDescription("默认值")
|
||||
private String defaultValue;
|
||||
|
||||
/**
|
||||
* 是否唯一:1-唯一 -1-非唯一
|
||||
*/
|
||||
@Schema(description = "是否唯一:1-唯一 -1-非唯一")
|
||||
@JsonPropertyDescription("是否唯一:1-唯一 -1-非唯一")
|
||||
private Integer uniqueFlag;
|
||||
|
||||
@Schema(description = "是否启用:1-启用 -1-禁用")
|
||||
@JsonPropertyDescription("是否启用:1-启用 -1-禁用")
|
||||
private Integer enabledFlag;
|
||||
|
||||
/**
|
||||
* 字段顺序
|
||||
*/
|
||||
@Schema(description = "字段顺序")
|
||||
@JsonPropertyDescription("字段顺序")
|
||||
private Integer sortIndex;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.xspaceagi.compose.sdk.vo.doris;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
/**
|
||||
* Doris表定义
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "Doris表定义")
|
||||
public class DorisTableDefinitionVo {
|
||||
|
||||
@Schema(description = "数据库名")
|
||||
@JsonPropertyDescription("数据库名")
|
||||
private String database;
|
||||
|
||||
@Schema(description = "表名")
|
||||
@JsonPropertyDescription("表名")
|
||||
private String table;
|
||||
|
||||
@Schema(description = "图标图片地址")
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "表注释")
|
||||
@JsonPropertyDescription("表注释")
|
||||
private String comment;
|
||||
|
||||
@Schema(description = "表引擎")
|
||||
@JsonPropertyDescription("表引擎")
|
||||
private String engine;
|
||||
|
||||
@Schema(description = "分桶数")
|
||||
@JsonPropertyDescription("分桶数")
|
||||
private Integer buckets;
|
||||
|
||||
@Schema(description = "副本数")
|
||||
@JsonPropertyDescription("副本数")
|
||||
private Integer replicationNum;
|
||||
|
||||
@Schema(description = "分布键")
|
||||
@JsonPropertyDescription("分布键")
|
||||
private List<String> distributedKeys;
|
||||
|
||||
@Schema(description = "重复键")
|
||||
@JsonPropertyDescription("重复键")
|
||||
private List<String> duplicateKeys;
|
||||
|
||||
@Schema(description = "字段定义列表")
|
||||
@JsonPropertyDescription("字段定义列表")
|
||||
private List<DorisTableFieldVo> fields;
|
||||
|
||||
@Schema(description = "索引定义列表")
|
||||
@JsonPropertyDescription("索引定义列表")
|
||||
private List<DorisTableIndexVo> indexes;
|
||||
|
||||
@Schema(description = "表属性")
|
||||
@JsonPropertyDescription("表属性")
|
||||
private Map<String, String> properties;
|
||||
|
||||
@Schema(description = "原始建表DDL")
|
||||
@JsonPropertyDescription("原始建表DDL")
|
||||
private String createTableDdl;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.xspaceagi.compose.sdk.vo.doris;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
/**
|
||||
* Doris表字段定义
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "Doris表字段定义")
|
||||
@Builder
|
||||
public class DorisTableFieldVo {
|
||||
|
||||
@Schema(description = "字段名")
|
||||
@JsonPropertyDescription("字段名")
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date
|
||||
* @see com.xspaceagi.compose.sdk.enums.TableFieldTypeEnum
|
||||
*/
|
||||
@Schema(description = "字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date")
|
||||
@JsonPropertyDescription("字段类型:1:String;2:Integer;3:Number;4:Boolean;5:Date")
|
||||
private Integer fieldType;
|
||||
|
||||
@Schema(description = "字段类型描述")
|
||||
@JsonPropertyDescription("字段类型描述")
|
||||
private String fieldTypeDesc;
|
||||
|
||||
@Schema(description = "是否可为空")
|
||||
@JsonPropertyDescription("是否可为空")
|
||||
private Boolean nullable;
|
||||
|
||||
@Schema(description = "默认值")
|
||||
@JsonPropertyDescription("默认值")
|
||||
private String defaultValue;
|
||||
|
||||
@Schema(description = "字段注释")
|
||||
@JsonPropertyDescription("字段注释")
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 字段顺序
|
||||
*/
|
||||
@Schema(description = "字段顺序")
|
||||
@JsonPropertyDescription("字段顺序")
|
||||
private Integer sortIndex;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xspaceagi.compose.sdk.vo.doris;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
/**
|
||||
* Doris表索引定义
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "Doris表索引定义")
|
||||
public class DorisTableIndexVo {
|
||||
|
||||
@Schema(description = "索引名称")
|
||||
@JsonPropertyDescription("索引名称")
|
||||
private String indexName;
|
||||
|
||||
@Schema(description = "索引类型")
|
||||
@JsonPropertyDescription("索引类型")
|
||||
private String indexType;
|
||||
|
||||
@Schema(description = "索引列")
|
||||
@JsonPropertyDescription("索引列")
|
||||
private String indexColumns;
|
||||
|
||||
@Schema(description = "索引注释")
|
||||
@JsonPropertyDescription("索引注释")
|
||||
private String comment;
|
||||
|
||||
@Schema(description = "是否唯一索引")
|
||||
@JsonPropertyDescription("是否唯一索引")
|
||||
private Boolean isUnique;
|
||||
}
|
||||
Reference in New Issue
Block a user