Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ cd data-agent-frontend
pnpm install && pnpm dev
```

已有数据库升级到主键关联版本时,先备份数据库并在启动新版后端前执行:

```bash
mysql -u root -p data_agent < sql/migration_primary_key_relations.sql
```

浏览器打开 http://localhost:3000 ,使用 `admin` / `ADMIN_INIT_PASSWORD` 登录后,先在「数据源管理」接入业务库,在「语义管理」同步表结构并维护表/列/指标口径,再到聊天框用自然语言提问,例如:*"上个月各区域销售额是多少?"* 用户与角色入口在「系统管理」。

## 📚 文档
Expand Down Expand Up @@ -153,4 +159,4 @@ pnpm install && pnpm dev
<img src="https://contrib.rocks/image?repo=MaloneTalk/DataAgent" />
</a>

---
---
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

public final class SemanticConstants {

public static final String RELATION_KEY_SEPARATOR = "|";
public static final String RELATION_TABLE_COLUMN_SEPARATOR = ":";
public static final String RELATION_GROUP_SEPARATOR = "::";
public static final String DEFAULT_DOMAIN = "default";
public static final String RELATION_TYPE_FOREIGN_KEY =
LogicalTableRelationType.FOREIGN_KEY.getCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,8 @@ public LogicalTableRelationResponse toResponse(LogicalTableRelation relation) {
List<String> targetColumns =
logicalTableRelationHelper.fromJson(
relation.getTargetColumnNamesJson(), "targetColumnNames");
String relationKey =
logicalTableRelationHelper.buildRelationKey(
relation.getSourceTableName(),
sourceColumns,
relation.getTargetTableName(),
targetColumns);
return LogicalTableRelationResponse.builder()
.id(relation.getId())
.relationKey(relationKey)
.datasourceId(relation.getDatasourceId())
.source(SemanticConstants.RELATION_SOURCE_LOGICAL)
.sourceTableName(relation.getSourceTableName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@Builder
public record LogicalTableRelationResponse(
Integer id,
String relationKey,
Integer datasourceId,
String source,
String sourceTableName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class ColumnInfo {

private Integer id;
private Integer datasourceId;
private Integer tableId;
private String tableName;
private String columnName;
private String physicalColumnDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public class LogicalTableRelation {

private Integer id;
private Integer datasourceId;
private Integer sourceTableId;
private String sourceTableName;
private String sourceColumnNamesJson;
private String sourceColumnSignature;
private Integer targetTableId;
private String targetTableName;
private String targetColumnNamesJson;
private String targetColumnSignature;
private String relationType;
private String description;
private Boolean isEnabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.github.malonetalk.entity.ColumnInfo;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

Expand All @@ -36,6 +37,9 @@ List<ColumnInfo> selectByDatasourceIdAndTableNames(
@Param("datasourceId") Integer datasourceId,
@Param("tableNames") List<String> tableNames);

List<ColumnInfo> selectByDatasourceIdAndTableIds(
@Param("datasourceId") Integer datasourceId, @Param("tableIds") Set<Integer> tableIds);

List<ColumnInfo> selectPageByDatasourceIdAndTableName(
@Param("query") ColumnSemanticPageQuery query,
@Param("sortDescending") boolean sortDescending);
Expand All @@ -56,13 +60,11 @@ ColumnInfo selectByDatasourceIdAndTableNameAndColumnName(
int fillSemanticDescriptionIfBlank(
@Param("id") Integer id, @Param("description") String description);

int markPhysicalMissingByIds(
@Param("datasourceId") Integer datasourceId,
@Param("ids") List<Integer> ids,
@Param("now") LocalDateTime now);
int markPhysicalMissingByIds(@Param("ids") List<Integer> ids, @Param("now") LocalDateTime now);

int deleteByDatasourceId(@Param("datasourceId") Integer datasourceId);
int resetSemanticFieldsByIds(
@Param("datasourceId") Integer datasourceId, @Param("ids") List<Integer> ids);

int deleteByDatasourceIdAndIds(
int deletePhysicalMissingByIds(
@Param("datasourceId") Integer datasourceId, @Param("ids") List<Integer> ids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.github.malonetalk.entity.LogicalTableRelation;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

Expand All @@ -31,13 +32,9 @@ public interface LogicalTableRelationMapper {

List<LogicalTableRelation> selectByDatasourceId(@Param("datasourceId") Integer datasourceId);

List<LogicalTableRelation> selectByDatasourceIdAndSourceTable(
List<LogicalTableRelation> selectByDatasourceIdAndSourceTableIds(
@Param("datasourceId") Integer datasourceId,
@Param("sourceTableName") String sourceTableName);

List<LogicalTableRelation> selectByDatasourceIdAndSourceTables(
@Param("datasourceId") Integer datasourceId,
@Param("sourceTableNames") List<String> sourceTableNames);
@Param("sourceTableIds") Set<Integer> sourceTableIds);

List<LogicalTableRelation> selectPageByDatasourceIdAndSourceTable(
@Param("query") RelationSemanticPageQuery query,
Expand All @@ -50,21 +47,17 @@ List<LogicalTableRelation> selectPageByDatasourceIdAndSourceTable(
int updateEnabled(
@Param("id") Integer id,
@Param("datasourceId") Integer datasourceId,
@Param("sourceTableName") String sourceTableName,
@Param("sourceTableId") Integer sourceTableId,
@Param("isEnabled") Boolean isEnabled,
@Param("updateTime") LocalDateTime updateTime);

int deleteById(
@Param("id") Integer id,
@Param("datasourceId") Integer datasourceId,
@Param("sourceTableName") String sourceTableName);
@Param("sourceTableId") Integer sourceTableId);

int deleteByIdsAndSourceTable(
@Param("datasourceId") Integer datasourceId,
@Param("sourceTableName") String sourceTableName,
@Param("sourceTableId") Integer sourceTableId,
@Param("ids") List<Integer> ids);

int deleteByIds(@Param("datasourceId") Integer datasourceId, @Param("ids") List<Integer> ids);

int deleteByDatasourceId(@Param("datasourceId") Integer datasourceId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public interface TableInfoMapper {
int fillSemanticDescriptionIfBlank(
@Param("id") Integer id, @Param("description") String description);

int deleteByDatasourceIdAndIds(
int resetSemanticFieldsByIds(
@Param("datasourceId") Integer datasourceId, @Param("ids") List<Integer> ids);

int deletePhysicalMissingByIds(
@Param("datasourceId") Integer datasourceId, @Param("ids") List<Integer> ids);

List<TableInfo> selectByDatasourceId(@Param("datasourceId") Integer datasourceId);
Expand Down
Loading
Loading