mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-13 20:53:42 +08:00
Merge pull request #198 from wenxwang/fix/admin-knowledge-remove-error
fix(Knowledge): 知识库删除失败
This commit is contained in:
@@ -2,6 +2,7 @@ package org.ruoyi.mapper;
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.ruoyi.core.mapper.BaseMapperPlus;
|
||||
import org.ruoyi.domain.KnowledgeInfo;
|
||||
import org.ruoyi.domain.vo.KnowledgeInfoVo;
|
||||
@@ -15,4 +16,10 @@ import org.ruoyi.domain.vo.KnowledgeInfoVo;
|
||||
@Mapper
|
||||
public interface KnowledgeInfoMapper extends BaseMapperPlus<KnowledgeInfo, KnowledgeInfoVo> {
|
||||
|
||||
/**
|
||||
* 根据kid查询知识库
|
||||
* @param kid 知识库id
|
||||
* @return KnowledgeInfo
|
||||
*/
|
||||
KnowledgeInfo selectByKid(@Param("kid") String kid);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public interface IKnowledgeInfoService {
|
||||
/**
|
||||
* 删除知识库
|
||||
*/
|
||||
void removeKnowledge(String id);
|
||||
void removeKnowledge(String kid);
|
||||
|
||||
/**
|
||||
* 上传附件
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.ruoyi.mapper.KnowledgeInfoMapper">
|
||||
<select id="selectByKid" resultType="org.ruoyi.domain.KnowledgeInfo">
|
||||
SELECT * FROM knowledge_info WHERE kid = #{kid}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -102,9 +102,9 @@ public class KnowledgeController extends BaseController {
|
||||
/**
|
||||
* 删除知识库
|
||||
*/
|
||||
@PostMapping("/remove/{id}")
|
||||
public R<String> remove(@PathVariable String id) {
|
||||
knowledgeInfoService.removeKnowledge(id);
|
||||
@PostMapping("/remove/{kid}")
|
||||
public R<String> remove(@PathVariable String kid) {
|
||||
knowledgeInfoService.removeKnowledge(kid);
|
||||
return R.ok("删除知识库成功!");
|
||||
}
|
||||
|
||||
|
||||
@@ -226,11 +226,12 @@ public class KnowledgeInfoServiceImpl implements IKnowledgeInfoService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeKnowledge(String id) {
|
||||
public void removeKnowledge(String kid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
KnowledgeInfo knowledgeInfo = baseMapper.selectById(id);
|
||||
KnowledgeInfo knowledgeInfo = baseMapper.selectByKid(kid);
|
||||
|
||||
check(knowledgeInfo);
|
||||
map.put("kid", knowledgeInfo.getId());
|
||||
map.put("kid", knowledgeInfo.getKid());
|
||||
// 删除向量数据
|
||||
vectorStoreService.removeById(String.valueOf(knowledgeInfo.getId()), knowledgeInfo.getVectorModelName());
|
||||
// 删除附件和知识片段
|
||||
|
||||
Reference in New Issue
Block a user