|
@@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.validation.Valid;
|
|
import jakarta.validation.Valid;
|
|
import org.hibernate.validator.constraints.URL;
|
|
import org.hibernate.validator.constraints.URL;
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -29,7 +30,6 @@ import java.util.Map;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
|
-// TODO @芋艿:增加权限标识
|
|
|
|
@Tag(name = "管理后台 - AI 知识库段落")
|
|
@Tag(name = "管理后台 - AI 知识库段落")
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/ai/knowledge/segment")
|
|
@RequestMapping("/ai/knowledge/segment")
|
|
@@ -38,27 +38,45 @@ public class AiKnowledgeSegmentController {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private AiKnowledgeSegmentService segmentService;
|
|
private AiKnowledgeSegmentService segmentService;
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private AiKnowledgeDocumentService documentService;
|
|
private AiKnowledgeDocumentService documentService;
|
|
|
|
|
|
|
|
+ @GetMapping("/get")
|
|
|
|
+ @Operation(summary = "获取段落详情")
|
|
|
|
+ @Parameter(name = "id", description = "段落编号", required = true, example = "1024")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:query')")
|
|
|
|
+ public CommonResult<AiKnowledgeSegmentRespVO> getKnowledgeSegment(@RequestParam("id") Long id) {
|
|
|
|
+ AiKnowledgeSegmentDO segment = segmentService.getKnowledgeSegment(id);
|
|
|
|
+ return success(BeanUtils.toBean(segment, AiKnowledgeSegmentRespVO.class));
|
|
|
|
+ }
|
|
|
|
+
|
|
@GetMapping("/page")
|
|
@GetMapping("/page")
|
|
@Operation(summary = "获取段落分页")
|
|
@Operation(summary = "获取段落分页")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:query')")
|
|
public CommonResult<PageResult<AiKnowledgeSegmentRespVO>> getKnowledgeSegmentPage(
|
|
public CommonResult<PageResult<AiKnowledgeSegmentRespVO>> getKnowledgeSegmentPage(
|
|
@Valid AiKnowledgeSegmentPageReqVO pageReqVO) {
|
|
@Valid AiKnowledgeSegmentPageReqVO pageReqVO) {
|
|
PageResult<AiKnowledgeSegmentDO> pageResult = segmentService.getKnowledgeSegmentPage(pageReqVO);
|
|
PageResult<AiKnowledgeSegmentDO> pageResult = segmentService.getKnowledgeSegmentPage(pageReqVO);
|
|
return success(BeanUtils.toBean(pageResult, AiKnowledgeSegmentRespVO.class));
|
|
return success(BeanUtils.toBean(pageResult, AiKnowledgeSegmentRespVO.class));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @PostMapping("/create")
|
|
|
|
+ @Operation(summary = "创建段落")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:create')")
|
|
|
|
+ public CommonResult<Long> createKnowledgeSegment(@Valid @RequestBody AiKnowledgeSegmentSaveReqVO createReqVO) {
|
|
|
|
+ return success(segmentService.createKnowledgeSegment(createReqVO));
|
|
|
|
+ }
|
|
|
|
+
|
|
@PutMapping("/update")
|
|
@PutMapping("/update")
|
|
@Operation(summary = "更新段落内容")
|
|
@Operation(summary = "更新段落内容")
|
|
- public CommonResult<Boolean> updateKnowledgeSegment(@Valid @RequestBody AiKnowledgeSegmentUpdateReqVO reqVO) {
|
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:update')")
|
|
|
|
+ public CommonResult<Boolean> updateKnowledgeSegment(@Valid @RequestBody AiKnowledgeSegmentSaveReqVO reqVO) {
|
|
segmentService.updateKnowledgeSegment(reqVO);
|
|
segmentService.updateKnowledgeSegment(reqVO);
|
|
return success(true);
|
|
return success(true);
|
|
}
|
|
}
|
|
|
|
|
|
@PutMapping("/update-status")
|
|
@PutMapping("/update-status")
|
|
@Operation(summary = "启禁用段落内容")
|
|
@Operation(summary = "启禁用段落内容")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:update')")
|
|
public CommonResult<Boolean> updateKnowledgeSegmentStatus(
|
|
public CommonResult<Boolean> updateKnowledgeSegmentStatus(
|
|
@Valid @RequestBody AiKnowledgeSegmentUpdateStatusReqVO reqVO) {
|
|
@Valid @RequestBody AiKnowledgeSegmentUpdateStatusReqVO reqVO) {
|
|
segmentService.updateKnowledgeSegmentStatus(reqVO);
|
|
segmentService.updateKnowledgeSegmentStatus(reqVO);
|
|
@@ -71,6 +89,7 @@ public class AiKnowledgeSegmentController {
|
|
@Parameter(name = "url", description = "文档 URL", required = true),
|
|
@Parameter(name = "url", description = "文档 URL", required = true),
|
|
@Parameter(name = "segmentMaxTokens", description = "分段的最大 Token 数", required = true)
|
|
@Parameter(name = "segmentMaxTokens", description = "分段的最大 Token 数", required = true)
|
|
})
|
|
})
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:query')")
|
|
public CommonResult<List<AiKnowledgeSegmentRespVO>> splitContent(
|
|
public CommonResult<List<AiKnowledgeSegmentRespVO>> splitContent(
|
|
@RequestParam("url") @URL String url,
|
|
@RequestParam("url") @URL String url,
|
|
@RequestParam(value = "segmentMaxTokens") Integer segmentMaxTokens) {
|
|
@RequestParam(value = "segmentMaxTokens") Integer segmentMaxTokens) {
|
|
@@ -81,6 +100,7 @@ public class AiKnowledgeSegmentController {
|
|
@GetMapping("/get-process-list")
|
|
@GetMapping("/get-process-list")
|
|
@Operation(summary = "获取文档处理列表")
|
|
@Operation(summary = "获取文档处理列表")
|
|
@Parameter(name = "documentIds", description = "文档编号列表", required = true, example = "1,2,3")
|
|
@Parameter(name = "documentIds", description = "文档编号列表", required = true, example = "1,2,3")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:query')")
|
|
public CommonResult<List<AiKnowledgeSegmentProcessRespVO>> getKnowledgeSegmentProcessList(
|
|
public CommonResult<List<AiKnowledgeSegmentProcessRespVO>> getKnowledgeSegmentProcessList(
|
|
@RequestParam("documentIds") List<Long> documentIds) {
|
|
@RequestParam("documentIds") List<Long> documentIds) {
|
|
List<AiKnowledgeSegmentProcessRespVO> list = segmentService.getKnowledgeSegmentProcessList(documentIds);
|
|
List<AiKnowledgeSegmentProcessRespVO> list = segmentService.getKnowledgeSegmentProcessList(documentIds);
|
|
@@ -89,6 +109,7 @@ public class AiKnowledgeSegmentController {
|
|
|
|
|
|
@GetMapping("/search")
|
|
@GetMapping("/search")
|
|
@Operation(summary = "搜索段落内容")
|
|
@Operation(summary = "搜索段落内容")
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('ai:knowledge:query')")
|
|
public CommonResult<List<AiKnowledgeSegmentSearchRespVO>> searchKnowledgeSegment(
|
|
public CommonResult<List<AiKnowledgeSegmentSearchRespVO>> searchKnowledgeSegment(
|
|
@Valid AiKnowledgeSegmentSearchReqVO reqVO) {
|
|
@Valid AiKnowledgeSegmentSearchReqVO reqVO) {
|
|
// 1. 搜索段落
|
|
// 1. 搜索段落
|