feat: 增加RAG知识库与文档基础骨架

This commit is contained in:
2026-05-18 22:32:53 +08:00
parent 18386fde63
commit 4a20a25282
15 changed files with 360 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
package com.bruce.rag.constant;
public final class RagSystemConstants {
public static final String RAG_STORE = "RAG_STORE";
public static final String RAG_DOCUMENT = "RAG_DOCUMENT";
private RagSystemConstants() {
}
}

View File

@@ -0,0 +1,29 @@
package com.bruce.rag.controller;
import com.bruce.rag.entity.RagDocument;
import com.bruce.rag.service.IRagDocumentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Tag(name = "RAG知识库文档管理")
@RestController
@RequestMapping("/api/rag/documents")
public class RagDocumentController {
private final IRagDocumentService ragDocumentService;
public RagDocumentController(IRagDocumentService ragDocumentService) {
this.ragDocumentService = ragDocumentService;
}
@Operation(summary = "查询全部知识库文档")
@GetMapping
public List<RagDocument> list() {
return ragDocumentService.list();
}
}

View File

@@ -0,0 +1,29 @@
package com.bruce.rag.controller;
import com.bruce.rag.entity.RagStore;
import com.bruce.rag.service.IRagStoreService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Tag(name = "RAG知识库管理")
@RestController
@RequestMapping("/api/rag/stores")
public class RagStoreController {
private final IRagStoreService ragStoreService;
public RagStoreController(IRagStoreService ragStoreService) {
this.ragStoreService = ragStoreService;
}
@Operation(summary = "查询全部知识库")
@GetMapping
public List<RagStore> list() {
return ragStoreService.list();
}
}

View File

@@ -0,0 +1,51 @@
package com.bruce.rag.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bruce.common.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("rag_document")
@Schema(description = "RAG知识库文档")
public class RagDocument extends BaseEntity {
@Schema(description = "知识库ID")
@TableField("store_id")
private Long storeId;
@Schema(description = "附件ID")
@TableField("attachment_id")
private Long attachmentId;
@Schema(description = "文档标题")
@TableField("document_title")
private String documentTitle;
@Schema(description = "文档摘要")
@TableField("document_summary")
private String documentSummary;
@Schema(description = "解析状态")
@TableField("parse_status")
private String parseStatus;
@Schema(description = "索引状态")
@TableField("index_status")
private String indexStatus;
@Schema(description = "是否启用")
private Boolean enabled;
@Schema(description = "失败原因")
@TableField("error_message")
private String errorMessage;
@Schema(description = "备注")
private String remark;
}

View File

@@ -0,0 +1,31 @@
package com.bruce.rag.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bruce.common.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("rag_store")
@Schema(description = "RAG知识库")
public class RagStore extends BaseEntity {
@Schema(description = "知识库编码")
private String storeCode;
@Schema(description = "知识库名称")
private String storeName;
@Schema(description = "知识库描述")
private String description;
@Schema(description = "状态")
private String status;
@Schema(description = "备注")
private String remark;
}

View File

@@ -0,0 +1,9 @@
package com.bruce.rag.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bruce.rag.entity.RagDocument;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RagDocumentMapper extends BaseMapper<RagDocument> {
}

View File

@@ -0,0 +1,9 @@
package com.bruce.rag.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bruce.rag.entity.RagStore;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RagStoreMapper extends BaseMapper<RagStore> {
}

View File

@@ -0,0 +1,7 @@
package com.bruce.rag.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bruce.rag.entity.RagDocument;
public interface IRagDocumentService extends IService<RagDocument> {
}

View File

@@ -0,0 +1,7 @@
package com.bruce.rag.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bruce.rag.entity.RagStore;
public interface IRagStoreService extends IService<RagStore> {
}

View File

@@ -0,0 +1,11 @@
package com.bruce.rag.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bruce.rag.entity.RagDocument;
import com.bruce.rag.mapper.RagDocumentMapper;
import com.bruce.rag.service.IRagDocumentService;
import org.springframework.stereotype.Service;
@Service
public class RagDocumentServiceImpl extends ServiceImpl<RagDocumentMapper, RagDocument> implements IRagDocumentService {
}

View File

@@ -0,0 +1,11 @@
package com.bruce.rag.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bruce.rag.entity.RagStore;
import com.bruce.rag.mapper.RagStoreMapper;
import com.bruce.rag.service.IRagStoreService;
import org.springframework.stereotype.Service;
@Service
public class RagStoreServiceImpl extends ServiceImpl<RagStoreMapper, RagStore> implements IRagStoreService {
}