-
Notifications
You must be signed in to change notification settings - Fork 1
feat(semantic): add domain crud #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2b98389
feat: add domain
mengnankkkk 881e69c
feat: add frontend
mengnankkkk 731c16a
fix: ci
mengnankkkk 5aa071f
fix: add check in domain
mengnankkkk 72fcba6
fix: add check in domain
mengnankkkk e08d4a0
fix: remove impl
mengnankkkk 138c38f
fix: frontend bug
mengnankkkk 053eca5
Update DomainController.java
mengnankkkk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
data-agent-backend/src/main/java/io/github/malonetalk/agent/tools/GetDomainsTool.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * 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.agent.tools; | ||
|
|
||
| import io.agentscope.core.tool.Tool; | ||
| import io.github.malonetalk.service.DomainService; | ||
| import java.util.List; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @AllArgsConstructor | ||
| public class GetDomainsTool implements MarkAgentTool { | ||
|
|
||
| private final DomainService domainService; | ||
|
|
||
| @Tool( | ||
| name = "get_domains", | ||
| description = | ||
| "Get available data domains in the datasource. Call this tool first to discover" | ||
| + " what domains are available before querying tables.") | ||
| public List<String> getDomains() { | ||
| return domainService.listDomainNames(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
data-agent-backend/src/main/java/io/github/malonetalk/controller/DomainController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| * 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.DomainCreateRequest; | ||
| import io.github.malonetalk.dto.DomainPageQuery; | ||
| import io.github.malonetalk.dto.DomainUpdateRequest; | ||
| import io.github.malonetalk.dto.pagination.PageResponse; | ||
| import io.github.malonetalk.entity.DomainInfo; | ||
| import io.github.malonetalk.service.DomainService; | ||
| import jakarta.validation.Valid; | ||
| 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.PostMapping; | ||
| 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.RestController; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/domains") | ||
| @RequiredArgsConstructor | ||
| public class DomainController { | ||
|
|
||
| private final DomainService domainService; | ||
|
|
||
| @GetMapping | ||
| public Result<PageResponse<DomainInfo>> findDomains(@Valid DomainPageQuery query) { | ||
| return Result.success(domainService.getDomainPage(query)); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| public Result<DomainInfo> findById(@PathVariable Integer id) { | ||
| if (id == null || id < 0) { | ||
| return Result.error(400, "ID必须为非负数"); | ||
| } | ||
| DomainInfo domain = domainService.findById(id); | ||
| if (domain == null) { | ||
| return Result.error(404, "领域不存在"); | ||
| } | ||
| return Result.success(domain); | ||
| } | ||
|
|
||
| @PostMapping | ||
| public Result<DomainInfo> create(@Valid @RequestBody DomainCreateRequest request) { | ||
| return Result.success(domainService.create(request)); | ||
| } | ||
|
|
||
| @PutMapping("/{id}") | ||
| public Result<DomainInfo> update( | ||
| @PathVariable Integer id, @Valid @RequestBody DomainUpdateRequest request) { | ||
| if (id == null || id < 0) { | ||
| return Result.error(400, "ID必须为非负数"); | ||
| } | ||
| return Result.success(domainService.update(id, request)); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| public Result<Boolean> delete(@PathVariable Integer id) { | ||
| if (id == null || id < 0) { | ||
| return Result.error(400, "ID必须为非负数"); | ||
| } | ||
| domainService.delete(id); | ||
| return Result.success(true); | ||
| } | ||
| } | ||
23 changes: 23 additions & 0 deletions
23
data-agent-backend/src/main/java/io/github/malonetalk/dto/DomainCreateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * 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.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record DomainCreateRequest( | ||
| @NotBlank(message = "领域名称不能为空") String name, String description) {} |
28 changes: 28 additions & 0 deletions
28
data-agent-backend/src/main/java/io/github/malonetalk/dto/DomainPageQuery.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * 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.dto; | ||
|
|
||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.Pattern; | ||
|
|
||
| public record DomainPageQuery( | ||
| @Min(1) Integer page, | ||
| @Min(1) Integer pageSize, | ||
| String keyword, | ||
| @Pattern(regexp = "^(?i)(asc|desc)$", message = "sortOrder must be asc or desc.") | ||
| String sortOrder) {} |
23 changes: 23 additions & 0 deletions
23
data-agent-backend/src/main/java/io/github/malonetalk/dto/DomainUpdateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * 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.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record DomainUpdateRequest( | ||
| @NotBlank(message = "领域名称不能为空") String name, String description) {} |
31 changes: 31 additions & 0 deletions
31
data-agent-backend/src/main/java/io/github/malonetalk/entity/DomainInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * 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.entity; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class DomainInfo { | ||
|
|
||
| private Integer id; | ||
| private String name; | ||
| private String description; | ||
| private LocalDateTime createTime; | ||
| private LocalDateTime updateTime; | ||
| } |
43 changes: 43 additions & 0 deletions
43
data-agent-backend/src/main/java/io/github/malonetalk/mapper/DomainInfoMapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * 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.mapper; | ||
|
|
||
| import io.github.malonetalk.dto.DomainPageQuery; | ||
| import io.github.malonetalk.entity.DomainInfo; | ||
| import java.util.List; | ||
| import org.apache.ibatis.annotations.Mapper; | ||
| import org.apache.ibatis.annotations.Param; | ||
|
|
||
| @Mapper | ||
| public interface DomainInfoMapper { | ||
|
|
||
| int insert(DomainInfo domainInfo); | ||
|
|
||
| int update(DomainInfo domainInfo); | ||
|
|
||
| int deleteByIds(@Param("ids") List<Integer> ids); | ||
|
|
||
| List<DomainInfo> selectAll(); | ||
|
|
||
| List<DomainInfo> selectPage( | ||
| @Param("query") DomainPageQuery query, @Param("sortDescending") boolean sortDescending); | ||
|
|
||
| DomainInfo selectById(@Param("id") Integer id); | ||
|
|
||
| DomainInfo selectByName(@Param("name") String name); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
data-agent-backend/src/main/java/io/github/malonetalk/service/DomainService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * 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.service; | ||
|
|
||
| import io.github.malonetalk.dto.DomainCreateRequest; | ||
| import io.github.malonetalk.dto.DomainPageQuery; | ||
| import io.github.malonetalk.dto.DomainUpdateRequest; | ||
| import io.github.malonetalk.dto.pagination.PageResponse; | ||
| import io.github.malonetalk.entity.DomainInfo; | ||
| import java.util.List; | ||
|
|
||
| public interface DomainService { | ||
|
|
||
| PageResponse<DomainInfo> getDomainPage(DomainPageQuery query); | ||
|
|
||
| DomainInfo findById(Integer id); | ||
|
|
||
| DomainInfo create(DomainCreateRequest request); | ||
|
|
||
| DomainInfo update(Integer id, DomainUpdateRequest request); | ||
|
|
||
| void delete(Integer id); | ||
|
|
||
| List<String> listDomainNames(); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.