Commit 96fb953730433d999486bac28594c0b0300b4418
1 parent
4208339d
【新增】AI 知识库: 增加部分管理类接口
Showing
24 changed files
with
479 additions
and
20 deletions
yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ErrorCodeConstants.java
| @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; | ||
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | * AI 错误码枚举类 | 6 | * AI 错误码枚举类 |
| 7 | - * | 7 | + * <p> |
| 8 | * ai 系统,使用 1-040-000-000 段 | 8 | * ai 系统,使用 1-040-000-000 段 |
| 9 | */ | 9 | */ |
| 10 | public interface ErrorCodeConstants { | 10 | public interface ErrorCodeConstants { |
| @@ -55,5 +55,7 @@ public interface ErrorCodeConstants { | @@ -55,5 +55,7 @@ public interface ErrorCodeConstants { | ||
| 55 | 55 | ||
| 56 | // ========== API 知识库 1-022-008-000 ========== | 56 | // ========== API 知识库 1-022-008-000 ========== |
| 57 | ErrorCode KNOWLEDGE_NOT_EXISTS = new ErrorCode(1_022_008_000, "知识库不存在!"); | 57 | ErrorCode KNOWLEDGE_NOT_EXISTS = new ErrorCode(1_022_008_000, "知识库不存在!"); |
| 58 | + ErrorCode KNOWLEDGE_DOCUMENT_NOT_EXISTS = new ErrorCode(1_022_008_001, "文档不存在!"); | ||
| 59 | + ErrorCode KNOWLEDGE_SEGMENT_NOT_EXISTS = new ErrorCode(1_022_008_002, "段落不存在!"); | ||
| 58 | 60 | ||
| 59 | } | 61 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeController.java
| 1 | package cn.iocoder.yudao.module.ai.controller.admin.knowledge; | 1 | package cn.iocoder.yudao.module.ai.controller.admin.knowledge; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeCreateMyReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeUpdateMyReqVO; | 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 7 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeCreateMyReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeRespVO; | ||
| 9 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeUpdateMyReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; | ||
| 6 | import cn.iocoder.yudao.module.ai.service.knowledge.AiKnowledgeService; | 11 | import cn.iocoder.yudao.module.ai.service.knowledge.AiKnowledgeService; |
| 7 | import io.swagger.v3.oas.annotations.Operation; | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 8 | import io.swagger.v3.oas.annotations.tags.Tag; | 13 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 9 | import jakarta.annotation.Resource; | 14 | import jakarta.annotation.Resource; |
| 10 | import jakarta.validation.Valid; | 15 | import jakarta.validation.Valid; |
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 11 | import org.springframework.web.bind.annotation.*; | 17 | import org.springframework.web.bind.annotation.*; |
| 12 | 18 | ||
| 13 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 19 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| @@ -19,19 +25,27 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti | @@ -19,19 +25,27 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti | ||
| 19 | public class AiKnowledgeController { | 25 | public class AiKnowledgeController { |
| 20 | 26 | ||
| 21 | @Resource | 27 | @Resource |
| 22 | - private AiKnowledgeService knowledgeBaseService; | 28 | + private AiKnowledgeService knowledgeService; |
| 29 | + | ||
| 30 | + @GetMapping("/my-page") | ||
| 31 | + @Operation(summary = "获取【我的】知识库分页") | ||
| 32 | + public CommonResult<PageResult<AiKnowledgeRespVO>> getKnowledgePageMy(@Validated PageParam pageReqVO) { | ||
| 33 | + PageResult<AiKnowledgeDO> pageResult = knowledgeService.getKnowledgePageMy(getLoginUserId(), pageReqVO); | ||
| 34 | + return success(BeanUtils.toBean(pageResult, AiKnowledgeRespVO.class)); | ||
| 35 | + } | ||
| 36 | + | ||
| 23 | 37 | ||
| 24 | @PostMapping("/create-my") | 38 | @PostMapping("/create-my") |
| 25 | @Operation(summary = "创建【我的】知识库") | 39 | @Operation(summary = "创建【我的】知识库") |
| 26 | public CommonResult<Long> createKnowledgeMy(@RequestBody @Valid AiKnowledgeCreateMyReqVO createReqVO) { | 40 | public CommonResult<Long> createKnowledgeMy(@RequestBody @Valid AiKnowledgeCreateMyReqVO createReqVO) { |
| 27 | - return success(knowledgeBaseService.createKnowledgeMy(createReqVO, getLoginUserId())); | 41 | + return success(knowledgeService.createKnowledgeMy(createReqVO, getLoginUserId())); |
| 28 | } | 42 | } |
| 29 | 43 | ||
| 30 | 44 | ||
| 31 | @PutMapping("/update-my") | 45 | @PutMapping("/update-my") |
| 32 | @Operation(summary = "更新【我的】知识库") | 46 | @Operation(summary = "更新【我的】知识库") |
| 33 | public CommonResult<Boolean> updateKnowledgeMy(@RequestBody @Valid AiKnowledgeUpdateMyReqVO updateReqVO) { | 47 | public CommonResult<Boolean> updateKnowledgeMy(@RequestBody @Valid AiKnowledgeUpdateMyReqVO updateReqVO) { |
| 34 | - knowledgeBaseService.updateKnowledgeMy(updateReqVO, getLoginUserId()); | 48 | + knowledgeService.updateKnowledgeMy(updateReqVO, getLoginUserId()); |
| 35 | return success(true); | 49 | return success(true); |
| 36 | } | 50 | } |
| 37 | 51 |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeDocumentController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO; | ||
| 11 | +import cn.iocoder.yudao.module.ai.service.knowledge.AiKnowledgeDocumentService; | ||
| 12 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | +import jakarta.annotation.Resource; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | +import org.springframework.web.bind.annotation.*; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +@Tag(name = "管理后台 - AI 知识库-文档") | ||
| 22 | +@RestController | ||
| 23 | +@RequestMapping("/ai/knowledge/document") | ||
| 24 | +public class AiKnowledgeDocumentController { | ||
| 25 | + | ||
| 26 | + @Resource | ||
| 27 | + private AiKnowledgeDocumentService documentService; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + @PostMapping("/create") | ||
| 31 | + @Operation(summary = "新建文档") | ||
| 32 | + public CommonResult<Long> createKnowledgeDocument(@Validated AiKnowledgeDocumentCreateReqVO reqVO) { | ||
| 33 | + Long knowledgeDocumentId = documentService.createKnowledgeDocument(reqVO); | ||
| 34 | + return success(knowledgeDocumentId); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + @GetMapping("/page") | ||
| 39 | + @Operation(summary = "获取文档分页") | ||
| 40 | + public CommonResult<PageResult<AiKnowledgeDocumentRespVO>> getKnowledgeDocumentPageMy(@Validated AiKnowledgeDocumentPageReqVO pageReqVO) { | ||
| 41 | + PageResult<AiKnowledgeDocumentDO> pageResult = documentService.getKnowledgeDocumentPage(pageReqVO); | ||
| 42 | + return success(BeanUtils.toBean(pageResult, AiKnowledgeDocumentRespVO.class)); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + @PutMapping("/update") | ||
| 47 | + @Operation(summary = "更新文档") | ||
| 48 | + public CommonResult<Boolean> updateKnowledgeDocument(@Validated @RequestBody AiKnowledgeDocumentUpdateReqVO reqVO) { | ||
| 49 | + documentService.updateKnowledgeDocument(reqVO); | ||
| 50 | + return success(true); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + | ||
| 54 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeSegmentController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateStatusReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; | ||
| 11 | +import cn.iocoder.yudao.module.ai.service.knowledge.AiKnowledgeSegmentService; | ||
| 12 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | +import jakarta.annotation.Resource; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | +import org.springframework.web.bind.annotation.*; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +@Tag(name = "管理后台 - AI 知识库-段落") | ||
| 22 | +@RestController | ||
| 23 | +@RequestMapping("/ai/knowledge/segment") | ||
| 24 | +public class AiKnowledgeSegmentController { | ||
| 25 | + | ||
| 26 | + @Resource | ||
| 27 | + private AiKnowledgeSegmentService segmentService; | ||
| 28 | + | ||
| 29 | + @GetMapping("/page") | ||
| 30 | + @Operation(summary = "获取段落分页") | ||
| 31 | + public CommonResult<PageResult<AiKnowledgeSegmentRespVO>> getKnowledgeSegmentPageMy(@Validated AiKnowledgeSegmentPageReqVO pageReqVO) { | ||
| 32 | + PageResult<AiKnowledgeSegmentDO> pageResult = segmentService.getKnowledgeSegmentPage(pageReqVO); | ||
| 33 | + return success(BeanUtils.toBean(pageResult, AiKnowledgeSegmentRespVO.class)); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + @PutMapping("/update") | ||
| 38 | + @Operation(summary = "更新段落内容") | ||
| 39 | + public CommonResult<Boolean> updateKnowledgeSegment(@Validated @RequestBody AiKnowledgeSegmentUpdateReqVO reqVO) { | ||
| 40 | + segmentService.updateKnowledgeSegment(reqVO); | ||
| 41 | + return success(true); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @PutMapping("/update-status") | ||
| 45 | + @Operation(summary = "启禁用段落内容") | ||
| 46 | + public CommonResult<Boolean> updateKnowledgeSegmentStatus(@Validated @RequestBody AiKnowledgeSegmentUpdateStatusReqVO reqVO) { | ||
| 47 | + segmentService.updateKnowledgeSegmentStatus(reqVO); | ||
| 48 | + return success(true); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - AI 知识库-文档 分页 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class AiKnowledgeDocumentPageReqVO extends PageParam { | ||
| 10 | + | ||
| 11 | + @Schema(description = "文档名称", example = "Java 开发手册") | ||
| 12 | + private String name; | ||
| 13 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - AI 知识库-文档 Response VO") | ||
| 8 | +@Data | ||
| 9 | +public class AiKnowledgeDocumentRespVO extends PageParam { | ||
| 10 | + | ||
| 11 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "知识库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 15 | + private Long knowledgeId; | ||
| 16 | + | ||
| 17 | + @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "Java 开发手册") | ||
| 18 | + private String name; | ||
| 19 | + | ||
| 20 | + @Schema(description = "内容", example = "Java 是一门面向对象的语言.....") | ||
| 21 | + private String content; | ||
| 22 | + | ||
| 23 | + @Schema(description = "文档 url", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://doc.iocoder.cn") | ||
| 24 | + private String url; | ||
| 25 | + | ||
| 26 | + @Schema(description = "token 数量", example = "1024") | ||
| 27 | + private Integer tokens; | ||
| 28 | + | ||
| 29 | + @Schema(description = "字符数", example = "1008") | ||
| 30 | + private Integer wordCount; | ||
| 31 | + | ||
| 32 | + @Schema(description = "切片状态", example = "1") | ||
| 33 | + private Integer sliceStatus; | ||
| 34 | + | ||
| 35 | + @Schema(description = "文档状态", example = "1") | ||
| 36 | + private Integer status; | ||
| 37 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotNull; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - AI 更新 知识库-文档 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class AiKnowledgeDocumentUpdateReqVO { | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15583") | ||
| 14 | + @NotNull(message = "编号不能为空") | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | + @Schema(description = "是否启用", example = "1") | ||
| 18 | + private Integer status; | ||
| 19 | + | ||
| 20 | + @Schema(description = "名称", example = "Java 开发手册") | ||
| 21 | + private String name; | ||
| 22 | + | ||
| 23 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/AiKnowledgeCreateMyReqVO.java renamed to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/knowledge/AiKnowledgeCreateMyReqVO.java
| 1 | -package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo; | 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import jakarta.validation.constraints.NotBlank; | 4 | import jakarta.validation.constraints.NotBlank; |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/AiKnowledgeDocumentCreateReqVO.java renamed to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/knowledge/AiKnowledgeDocumentCreateReqVO.java
| 1 | -package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo; | 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import jakarta.validation.constraints.NotBlank; | 4 | import jakarta.validation.constraints.NotBlank; |
| @@ -6,10 +6,8 @@ import jakarta.validation.constraints.NotNull; | @@ -6,10 +6,8 @@ import jakarta.validation.constraints.NotNull; | ||
| 6 | import lombok.Data; | 6 | import lombok.Data; |
| 7 | import org.hibernate.validator.constraints.URL; | 7 | import org.hibernate.validator.constraints.URL; |
| 8 | 8 | ||
| 9 | -/** | ||
| 10 | - * @author xiaoxin | ||
| 11 | - */ | ||
| 12 | -@Schema(description = "管理后台 - AI 知识库【创建文档】 Request VO") | 9 | + |
| 10 | +@Schema(description = "管理后台 - AI 知识库创建【文档】 Request VO") | ||
| 13 | @Data | 11 | @Data |
| 14 | public class AiKnowledgeDocumentCreateReqVO { | 12 | public class AiKnowledgeDocumentCreateReqVO { |
| 15 | 13 |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/knowledge/AiKnowledgeRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - AI 知识库 Response VO") | ||
| 8 | +@Data | ||
| 9 | +public class AiKnowledgeRespVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "知识库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "ruoyi-vue-pro 用户指南") | ||
| 15 | + private String name; | ||
| 16 | + | ||
| 17 | + @Schema(description = "知识库描述", example = "ruoyi-vue-pro 用户指南") | ||
| 18 | + private String description; | ||
| 19 | + | ||
| 20 | + @Schema(description = "模型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "14") | ||
| 21 | + private Long modelId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "模型标识", example = "qwen-72b-chat") | ||
| 24 | + private String model; | ||
| 25 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/AiKnowledgeUpdateMyReqVO.java renamed to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/knowledge/AiKnowledgeUpdateMyReqVO.java
| 1 | -package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo; | 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import jakarta.validation.constraints.NotBlank; | 4 | import jakarta.validation.constraints.NotBlank; |
| @@ -7,7 +7,7 @@ import lombok.Data; | @@ -7,7 +7,7 @@ import lombok.Data; | ||
| 7 | 7 | ||
| 8 | import java.util.List; | 8 | import java.util.List; |
| 9 | 9 | ||
| 10 | -@Schema(description = "管理后台 - AI 知识库创建【我的】 Request VO") | 10 | +@Schema(description = "管理后台 - AI 知识库更新【我的】 Request VO") |
| 11 | @Data | 11 | @Data |
| 12 | public class AiKnowledgeUpdateMyReqVO { | 12 | public class AiKnowledgeUpdateMyReqVO { |
| 13 | 13 |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/segment/AiKnowledgeSegmentPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - AI 知识库分页 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class AiKnowledgeSegmentPageReqVO extends PageParam { | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + @Schema(description = "分段状态", example = "1") | ||
| 13 | + private Integer status; | ||
| 14 | + | ||
| 15 | + @Schema(description = "文档编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 16 | + private Integer documentId; | ||
| 17 | + | ||
| 18 | + @Schema(description = "分段内容关键字", example = "Java 开发") | ||
| 19 | + private String keyword; | ||
| 20 | + | ||
| 21 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/segment/AiKnowledgeSegmentRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Schema(description = "管理后台 - AI 知识库-文档 Response VO") | ||
| 7 | +@Data | ||
| 8 | +public class AiKnowledgeSegmentRespVO { | ||
| 9 | + | ||
| 10 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 11 | + private Long id; | ||
| 12 | + | ||
| 13 | + @Schema(description = "文档编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 14 | + private Long documentId; | ||
| 15 | + | ||
| 16 | + @Schema(description = "知识库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 17 | + private Long knowledgeId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "向量库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1858496a-1dde-4edf-a43e-0aed08f37f8c") | ||
| 20 | + private String vectorId; | ||
| 21 | + | ||
| 22 | + @Schema(description = "切片内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "Java 开发手册") | ||
| 23 | + private String content; | ||
| 24 | + | ||
| 25 | + @Schema(description = "token 数量", example = "1024") | ||
| 26 | + private Integer tokens; | ||
| 27 | + | ||
| 28 | + @Schema(description = "字符数", example = "1008") | ||
| 29 | + private Integer wordCount; | ||
| 30 | + | ||
| 31 | + @Schema(description = "文档状态", example = "1") | ||
| 32 | + private Integer status; | ||
| 33 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/segment/AiKnowledgeSegmentUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - AI 更新 知识库-段落 request VO") | ||
| 8 | +@Data | ||
| 9 | +public class AiKnowledgeSegmentUpdateReqVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "切片内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "Java 开发手册") | ||
| 15 | + private String content; | ||
| 16 | + | ||
| 17 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/segment/AiKnowledgeSegmentUpdateStatusReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - AI 更新 知识库-段落 request VO") | ||
| 8 | +@Data | ||
| 9 | +public class AiKnowledgeSegmentUpdateStatusReqVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 15 | + private Integer status; | ||
| 16 | + | ||
| 17 | +} |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/knowledge/AiKnowledgeDocumentMapper.java
| 1 | package cn.iocoder.yudao.module.ai.dal.mysql.knowledge; | 1 | package cn.iocoder.yudao.module.ai.dal.mysql.knowledge; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO; | ||
| 4 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO; | 7 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO; |
| 5 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 9 | ||
| @@ -11,4 +14,11 @@ import org.apache.ibatis.annotations.Mapper; | @@ -11,4 +14,11 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 11 | */ | 14 | */ |
| 12 | @Mapper | 15 | @Mapper |
| 13 | public interface AiKnowledgeDocumentMapper extends BaseMapperX<AiKnowledgeDocumentDO> { | 16 | public interface AiKnowledgeDocumentMapper extends BaseMapperX<AiKnowledgeDocumentDO> { |
| 17 | + | ||
| 18 | + default PageResult<AiKnowledgeDocumentDO> selectPage(AiKnowledgeDocumentPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<AiKnowledgeDocumentDO>() | ||
| 20 | + .likeIfPresent(AiKnowledgeDocumentDO::getName, reqVO.getName()) | ||
| 21 | + .orderByDesc(AiKnowledgeDocumentDO::getId)); | ||
| 22 | + } | ||
| 23 | + | ||
| 14 | } | 24 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/knowledge/AiKnowledgeMapper.java
| 1 | package cn.iocoder.yudao.module.ai.dal.mysql.knowledge; | 1 | package cn.iocoder.yudao.module.ai.dal.mysql.knowledge; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 4 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; | 8 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; |
| 5 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 10 | ||
| @@ -11,4 +15,11 @@ import org.apache.ibatis.annotations.Mapper; | @@ -11,4 +15,11 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 11 | */ | 15 | */ |
| 12 | @Mapper | 16 | @Mapper |
| 13 | public interface AiKnowledgeMapper extends BaseMapperX<AiKnowledgeDO> { | 17 | public interface AiKnowledgeMapper extends BaseMapperX<AiKnowledgeDO> { |
| 18 | + | ||
| 19 | + default PageResult<AiKnowledgeDO> selectPageByMy(Long userId, PageParam pageReqVO) { | ||
| 20 | + return selectPage(pageReqVO, new LambdaQueryWrapperX<AiKnowledgeDO>() | ||
| 21 | + .eq(AiKnowledgeDO::getUserId, userId) | ||
| 22 | + .eq(AiKnowledgeDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) | ||
| 23 | + .orderByDesc(AiKnowledgeDO::getId)); | ||
| 24 | + } | ||
| 14 | } | 25 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/mysql/knowledge/AiKnowledgeSegmentMapper.java
| 1 | package cn.iocoder.yudao.module.ai.dal.mysql.knowledge; | 1 | package cn.iocoder.yudao.module.ai.dal.mysql.knowledge; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentPageReqVO; | ||
| 4 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; | 7 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; |
| 5 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 9 | ||
| @@ -11,4 +14,12 @@ import org.apache.ibatis.annotations.Mapper; | @@ -11,4 +14,12 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 11 | */ | 14 | */ |
| 12 | @Mapper | 15 | @Mapper |
| 13 | public interface AiKnowledgeSegmentMapper extends BaseMapperX<AiKnowledgeSegmentDO> { | 16 | public interface AiKnowledgeSegmentMapper extends BaseMapperX<AiKnowledgeSegmentDO> { |
| 17 | + | ||
| 18 | + default PageResult<AiKnowledgeSegmentDO> selectPage(AiKnowledgeSegmentPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<AiKnowledgeSegmentDO>() | ||
| 20 | + .eq(AiKnowledgeSegmentDO::getDocumentId, reqVO.getDocumentId()) | ||
| 21 | + .eqIfPresent(AiKnowledgeSegmentDO::getStatus, reqVO.getStatus()) | ||
| 22 | + .likeIfPresent(AiKnowledgeSegmentDO::getContent, reqVO.getKeyword()) | ||
| 23 | + .orderByDesc(AiKnowledgeSegmentDO::getId)); | ||
| 24 | + } | ||
| 14 | } | 25 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentService.java
| 1 | package cn.iocoder.yudao.module.ai.service.knowledge; | 1 | package cn.iocoder.yudao.module.ai.service.knowledge; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeDocumentCreateReqVO; | 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO; | ||
| 4 | 8 | ||
| 5 | /** | 9 | /** |
| 6 | * AI 知识库-文档 Service 接口 | 10 | * AI 知识库-文档 Service 接口 |
| @@ -17,4 +21,19 @@ public interface AiKnowledgeDocumentService { | @@ -17,4 +21,19 @@ public interface AiKnowledgeDocumentService { | ||
| 17 | */ | 21 | */ |
| 18 | Long createKnowledgeDocument(AiKnowledgeDocumentCreateReqVO createReqVO); | 22 | Long createKnowledgeDocument(AiKnowledgeDocumentCreateReqVO createReqVO); |
| 19 | 23 | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 获取文档分页 | ||
| 27 | + * | ||
| 28 | + * @param pageReqVO 分页参数 | ||
| 29 | + * @return 文档分页 | ||
| 30 | + */ | ||
| 31 | + PageResult<AiKnowledgeDocumentDO> getKnowledgeDocumentPage(AiKnowledgeDocumentPageReqVO pageReqVO); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 更新文档 | ||
| 35 | + * | ||
| 36 | + * @param reqVO 更新信息 | ||
| 37 | + */ | ||
| 38 | + void updateKnowledgeDocument(AiKnowledgeDocumentUpdateReqVO reqVO); | ||
| 20 | } | 39 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentServiceImpl.java
| @@ -3,9 +3,12 @@ package cn.iocoder.yudao.module.ai.service.knowledge; | @@ -3,9 +3,12 @@ package cn.iocoder.yudao.module.ai.service.knowledge; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.http.HttpUtil; | 4 | import cn.hutool.http.HttpUtil; |
| 5 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 5 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeDocumentCreateReqVO; | 9 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO; |
| 10 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateReqVO; | ||
| 11 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO; | ||
| 9 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; | 12 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; |
| 10 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO; | 13 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO; |
| 11 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; | 14 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; |
| @@ -29,6 +32,9 @@ import org.springframework.transaction.annotation.Transactional; | @@ -29,6 +32,9 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 29 | import java.util.List; | 32 | import java.util.List; |
| 30 | import java.util.Map; | 33 | import java.util.Map; |
| 31 | 34 | ||
| 35 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 36 | +import static cn.iocoder.yudao.module.ai.enums.ErrorCodeConstants.KNOWLEDGE_DOCUMENT_NOT_EXISTS; | ||
| 37 | + | ||
| 32 | /** | 38 | /** |
| 33 | * AI 知识库-文档 Service 实现类 | 39 | * AI 知识库-文档 Service 实现类 |
| 34 | * | 40 | * |
| @@ -104,6 +110,32 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic | @@ -104,6 +110,32 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic | ||
| 104 | return documentId; | 110 | return documentId; |
| 105 | } | 111 | } |
| 106 | 112 | ||
| 113 | + @Override | ||
| 114 | + public PageResult<AiKnowledgeDocumentDO> getKnowledgeDocumentPage(AiKnowledgeDocumentPageReqVO pageReqVO) { | ||
| 115 | + return documentMapper.selectPage(pageReqVO); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + @Override | ||
| 119 | + public void updateKnowledgeDocument(AiKnowledgeDocumentUpdateReqVO reqVO) { | ||
| 120 | + validateKnowledgeDocumentExists(reqVO.getId()); | ||
| 121 | + AiKnowledgeDocumentDO document = BeanUtils.toBean(reqVO, AiKnowledgeDocumentDO.class); | ||
| 122 | + documentMapper.updateById(document); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * 校验文档是否存在 | ||
| 127 | + * | ||
| 128 | + * @param id 文档编号 | ||
| 129 | + * @return 文档信息 | ||
| 130 | + */ | ||
| 131 | + private AiKnowledgeDocumentDO validateKnowledgeDocumentExists(Long id) { | ||
| 132 | + AiKnowledgeDocumentDO knowledgeDocument = documentMapper.selectById(id); | ||
| 133 | + if (knowledgeDocument == null) { | ||
| 134 | + throw exception(KNOWLEDGE_DOCUMENT_NOT_EXISTS); | ||
| 135 | + } | ||
| 136 | + return knowledgeDocument; | ||
| 137 | + } | ||
| 138 | + | ||
| 107 | private org.springframework.core.io.Resource downloadFile(String url) { | 139 | private org.springframework.core.io.Resource downloadFile(String url) { |
| 108 | try { | 140 | try { |
| 109 | byte[] bytes = HttpUtil.downloadBytes(url); | 141 | byte[] bytes = HttpUtil.downloadBytes(url); |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeSegmentService.java
| 1 | package cn.iocoder.yudao.module.ai.service.knowledge; | 1 | package cn.iocoder.yudao.module.ai.service.knowledge; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateStatusReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; | ||
| 8 | + | ||
| 3 | /** | 9 | /** |
| 4 | * AI 知识库分片 Service 接口 | 10 | * AI 知识库分片 Service 接口 |
| 5 | * | 11 | * |
| @@ -7,4 +13,25 @@ package cn.iocoder.yudao.module.ai.service.knowledge; | @@ -7,4 +13,25 @@ package cn.iocoder.yudao.module.ai.service.knowledge; | ||
| 7 | */ | 13 | */ |
| 8 | public interface AiKnowledgeSegmentService { | 14 | public interface AiKnowledgeSegmentService { |
| 9 | 15 | ||
| 16 | + /** | ||
| 17 | + * 获取段落分页 | ||
| 18 | + * | ||
| 19 | + * @param pageReqVO 分页查询 | ||
| 20 | + * @return 文档分页 | ||
| 21 | + */ | ||
| 22 | + PageResult<AiKnowledgeSegmentDO> getKnowledgeSegmentPage(AiKnowledgeSegmentPageReqVO pageReqVO); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 更新段落内容 | ||
| 26 | + * | ||
| 27 | + * @param reqVO 更新内容 | ||
| 28 | + */ | ||
| 29 | + void updateKnowledgeSegment(AiKnowledgeSegmentUpdateReqVO reqVO); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 更新状态 | ||
| 33 | + * | ||
| 34 | + * @param reqVO 更新内容 | ||
| 35 | + */ | ||
| 36 | + void updateKnowledgeSegmentStatus(AiKnowledgeSegmentUpdateStatusReqVO reqVO); | ||
| 10 | } | 37 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeSegmentServiceImpl.java
| 1 | package cn.iocoder.yudao.module.ai.service.knowledge; | 1 | package cn.iocoder.yudao.module.ai.service.knowledge; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateStatusReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; | ||
| 9 | +import cn.iocoder.yudao.module.ai.dal.mysql.knowledge.AiKnowledgeSegmentMapper; | ||
| 10 | +import jakarta.annotation.Resource; | ||
| 3 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 4 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 5 | 13 | ||
| @@ -12,4 +20,23 @@ import org.springframework.stereotype.Service; | @@ -12,4 +20,23 @@ import org.springframework.stereotype.Service; | ||
| 12 | @Slf4j | 20 | @Slf4j |
| 13 | public class AiKnowledgeSegmentServiceImpl implements AiKnowledgeSegmentService { | 21 | public class AiKnowledgeSegmentServiceImpl implements AiKnowledgeSegmentService { |
| 14 | 22 | ||
| 23 | + @Resource | ||
| 24 | + private AiKnowledgeSegmentMapper segmentMapper; | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public PageResult<AiKnowledgeSegmentDO> getKnowledgeSegmentPage(AiKnowledgeSegmentPageReqVO pageReqVO) { | ||
| 28 | + return segmentMapper.selectPage(pageReqVO); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public void updateKnowledgeSegment(AiKnowledgeSegmentUpdateReqVO reqVO) { | ||
| 33 | + segmentMapper.updateById(BeanUtils.toBean(reqVO, AiKnowledgeSegmentDO.class)); | ||
| 34 | + // TODO @xin 重新向量化 | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void updateKnowledgeSegmentStatus(AiKnowledgeSegmentUpdateStatusReqVO reqVO) { | ||
| 39 | + segmentMapper.updateById(BeanUtils.toBean(reqVO, AiKnowledgeSegmentDO.class)); | ||
| 40 | + // TODO @xin 1.禁用删除向量 2.启用重新向量化 | ||
| 41 | + } | ||
| 15 | } | 42 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeService.java
| 1 | package cn.iocoder.yudao.module.ai.service.knowledge; | 1 | package cn.iocoder.yudao.module.ai.service.knowledge; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeCreateMyReqVO; | ||
| 4 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeUpdateMyReqVO; | 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeCreateMyReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeUpdateMyReqVO; | ||
| 5 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; | 7 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; |
| 6 | 8 | ||
| 7 | /** | 9 | /** |
| @@ -37,4 +39,12 @@ public interface AiKnowledgeService { | @@ -37,4 +39,12 @@ public interface AiKnowledgeService { | ||
| 37 | */ | 39 | */ |
| 38 | AiKnowledgeDO validateKnowledgeExists(Long id); | 40 | AiKnowledgeDO validateKnowledgeExists(Long id); |
| 39 | 41 | ||
| 42 | + /** | ||
| 43 | + * 获得【我的】知识库分页 | ||
| 44 | + * | ||
| 45 | + * @param userId 用户编号 | ||
| 46 | + * @param pageReqVO 分页查询 | ||
| 47 | + * @return 知识库分页 | ||
| 48 | + */ | ||
| 49 | + PageResult<AiKnowledgeDO> getKnowledgePageMy(Long userId, PageParam pageReqVO); | ||
| 40 | } | 50 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeServiceImpl.java
| @@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.ai.service.knowledge; | @@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.ai.service.knowledge; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.ObjUtil; | 3 | import cn.hutool.core.util.ObjUtil; |
| 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeCreateMyReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.AiKnowledgeUpdateMyReqVO; | 8 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeCreateMyReqVO; |
| 9 | +import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeUpdateMyReqVO; | ||
| 8 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; | 10 | import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; |
| 9 | import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO; | 11 | import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiChatModelDO; |
| 10 | import cn.iocoder.yudao.module.ai.dal.mysql.knowledge.AiKnowledgeMapper; | 12 | import cn.iocoder.yudao.module.ai.dal.mysql.knowledge.AiKnowledgeMapper; |
| @@ -68,4 +70,9 @@ public class AiKnowledgeServiceImpl implements AiKnowledgeService { | @@ -68,4 +70,9 @@ public class AiKnowledgeServiceImpl implements AiKnowledgeService { | ||
| 68 | return knowledgeBase; | 70 | return knowledgeBase; |
| 69 | } | 71 | } |
| 70 | 72 | ||
| 73 | + @Override | ||
| 74 | + public PageResult<AiKnowledgeDO> getKnowledgePageMy(Long userId, PageParam pageReqVO) { | ||
| 75 | + return knowledgeMapper.selectPageByMy(userId, pageReqVO); | ||
| 76 | + } | ||
| 77 | + | ||
| 71 | } | 78 | } |