Skip to content
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ yarn-error.log
yarn-debug.log
yarn-integrity
.yarn-integrity

.claude
.codegraph
.spec-workflow
7 changes: 7 additions & 0 deletions data-agent-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<spotless.version>3.4.0</spotless.version>
<google-java-format.version>1.28.0</google-java-format.version>
<mybatis-springboot-starter.version>4.0.0</mybatis-springboot-starter.version>
<pagehelper-spring-boot.version>2.1.1</pagehelper-spring-boot.version>
<lombok.version>1.18.42</lombok.version>
<mapstruct.version>1.6.3</mapstruct.version>
</properties>
Expand Down Expand Up @@ -83,6 +84,12 @@
<version>${mybatis-springboot-starter.version}</version>
</dependency>

<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper-spring-boot.version}</version>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.github.malonetalk.entity.TableInfo;
import io.github.malonetalk.enums.Status;
import io.github.malonetalk.service.DatasourceService;
import io.github.malonetalk.service.TableInfoService;
import io.github.malonetalk.service.semantic.table.TableSemanticService;
import java.util.Collections;
import java.util.List;
import lombok.AllArgsConstructor;
Expand All @@ -35,7 +35,7 @@
public class GetTablesTool implements MarkAgentTool {

private final DatasourceService dataSourceService;
private final TableInfoService tableInfoService;
private final TableSemanticService tableSemanticService;

@Tool(name = "get_tables", description = "获取数据库中的表信息,包括表名和表描述")
public List<TableInfo> getTables() {
Expand All @@ -54,6 +54,6 @@ public List<TableInfo> getTables() {
}

Datasource dataSource = activeDataSources.get(0);
return tableInfoService.findByDatasourceId(dataSource.getId());
return tableSemanticService.listTableInfosByDatasourceId(dataSource.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* limitations under the License.
*/
package io.github.malonetalk.convertor;
package io.github.malonetalk.common;

import io.github.malonetalk.dto.TableInfoRequest;
import io.github.malonetalk.dto.TableInfoResponse;
import io.github.malonetalk.entity.TableInfo;
import org.mapstruct.Mapper;
public final class SemanticConstants {

@Mapper(componentModel = "spring")
public interface TableInfoConverter {
public static final String RELATION_KEY_SEPARATOR = "|";
public static final String SORT_ORDER_ASC = "asc";
public static final String SORT_ORDER_DESC = "desc";

TableInfo toEntity(TableInfoRequest request);

TableInfoResponse toResponse(TableInfo tableInfo);
private SemanticConstants() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (C) 2026 github.com/MaloneTalk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* limitations under the License.
*/
package io.github.malonetalk.controller;

import io.github.malonetalk.common.Result;
import io.github.malonetalk.dto.pagination.PageRequest;
import io.github.malonetalk.dto.pagination.PageResponse;
import io.github.malonetalk.dto.semantic.BatchResetColumnSemanticRequest;
import io.github.malonetalk.dto.semantic.ColumnSemanticPageQuery;
import io.github.malonetalk.dto.semantic.ColumnSemanticResponse;
import io.github.malonetalk.dto.semantic.ColumnSemanticUpdateRequest;
import io.github.malonetalk.service.semantic.column.ColumnSemanticService;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/semantic/tables/columns/{tableName}")
@RequiredArgsConstructor
public class TableColumnSemanticController {

private final ColumnSemanticService columnSemanticService;

@GetMapping
public Result<PageResponse<ColumnSemanticResponse>> findAllColumns(
@PathVariable @NotBlank String tableName,
@RequestParam @NotNull @Min(1) Integer datasourceId,
@RequestParam(defaultValue = "1") @Min(1) Integer page,
@RequestParam(defaultValue = "20") @Min(1) Integer pageSize,
@RequestParam(name = "keyword", required = false) String keyword,
@RequestParam(defaultValue = "asc")
@Pattern(
regexp = "^(?i)(asc|desc)$",
message = "sortOrder must be asc or desc.")
String sortOrder) {
return Result.success(
Comment thread
mengnankkkk marked this conversation as resolved.
columnSemanticService.getColumnPage(
new ColumnSemanticPageQuery(
datasourceId,
tableName,
PageRequest.of(page, pageSize),
keyword,
sortOrder)));
}

@PutMapping
public Result<Boolean> updateColumnSemantic(
@PathVariable @NotBlank String tableName,
@RequestParam @NotNull @Min(1) Integer datasourceId,
@Valid @RequestBody ColumnSemanticUpdateRequest request) {
columnSemanticService.updateColumnSemantic(datasourceId, tableName, request);
return Result.success(true);
}

@DeleteMapping
public Result<Boolean> resetColumnSemantic(
@PathVariable @NotBlank String tableName,
@RequestParam @NotNull @Min(1) Integer datasourceId,
@RequestParam @NotBlank String columnName) {
columnSemanticService.resetColumnSemantic(datasourceId, tableName, columnName);
return Result.success(true);
}

@DeleteMapping("/batch")
public Result<Integer> resetColumnSemantics(
@PathVariable @NotBlank String tableName,
@Valid @RequestBody BatchResetColumnSemanticRequest request) {
return Result.success(
columnSemanticService.resetColumnSemantics(
request.datasourceId(), tableName, request.columnNames()));
}
}

This file was deleted.

Loading
Loading