Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Shucai Chen
/
lufa-ai
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
227214db
authored
Mar 24, 2026
by
pengshun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加知识库可删除的限制
parent
b48e8f92
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
101 additions
and
10 deletions
+101
-10
.DS_Store
+0
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ErrorCodeConstants.java
+2
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeDocumentController.java
+9
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentRespVO.java
+3
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateDeletableReqVO.java
+22
-0
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/knowledge/AiKnowledgeDocumentDO.java
+2
-1
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentService.java
+3
-4
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentServiceImpl.java
+21
-4
yudao-ui-admin-vue3/.DS_Store
+0
-0
yudao-ui-admin-vue3/src/api/ai/knowledge/document/index.ts
+10
-1
yudao-ui-admin-vue3/src/views/ai/knowledge/document/index.vue
+29
-0
No files found.
.DS_Store
View file @
227214db
No preview for this file type
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ErrorCodeConstants.java
View file @
227214db
...
@@ -68,6 +68,8 @@ public interface ErrorCodeConstants {
...
@@ -68,6 +68,8 @@ public interface ErrorCodeConstants {
ErrorCode
KNOWLEDGE_DOCUMENT_FROM_ZIP
=
new
ErrorCode
(
1_040_009_106
,
"禁止更新通过压缩包创建的文件夹及其内容!"
);
ErrorCode
KNOWLEDGE_DOCUMENT_FROM_ZIP
=
new
ErrorCode
(
1_040_009_106
,
"禁止更新通过压缩包创建的文件夹及其内容!"
);
ErrorCode
KNOWLEDGE_DOCUMENT_CANNOT_DELETE
=
new
ErrorCode
(
1_040_009_107
,
"不允许删除该内容!"
);
ErrorCode
KNOWLEDGE_SEGMENT_NOT_EXISTS
=
new
ErrorCode
(
1_040_009_202
,
"段落不存在!"
);
ErrorCode
KNOWLEDGE_SEGMENT_NOT_EXISTS
=
new
ErrorCode
(
1_040_009_202
,
"段落不存在!"
);
ErrorCode
KNOWLEDGE_SEGMENT_CONTENT_TOO_LONG
=
new
ErrorCode
(
1_040_009_203
,
"内容 Token 数为 {},超过最大限制 {}"
);
ErrorCode
KNOWLEDGE_SEGMENT_CONTENT_TOO_LONG
=
new
ErrorCode
(
1_040_009_203
,
"内容 Token 数为 {},超过最大限制 {}"
);
...
...
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeDocumentController.java
View file @
227214db
...
@@ -223,4 +223,13 @@ public class AiKnowledgeDocumentController {
...
@@ -223,4 +223,13 @@ public class AiKnowledgeDocumentController {
return
success
(
true
);
return
success
(
true
);
}
}
@PutMapping
(
"/update-deletable"
)
@Operation
(
summary
=
"更新文档是否可删除"
)
@PreAuthorize
(
"@ss.hasPermission('ai:knowledge:update')"
)
public
CommonResult
<
Boolean
>
updateKnowledgeDocumentDeletable
(
@Valid
@RequestBody
AiKnowledgeDocumentUpdateDeletableReqVO
reqVO
)
{
documentService
.
updateKnowledgeDocumentDeletable
(
reqVO
);
return
success
(
true
);
}
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentRespVO.java
View file @
227214db
...
@@ -50,4 +50,7 @@ public class AiKnowledgeDocumentRespVO {
...
@@ -50,4 +50,7 @@ public class AiKnowledgeDocumentRespVO {
@Schema
(
description
=
"是否有权限"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
@Schema
(
description
=
"是否有权限"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
Boolean
hasPermi
;
private
Boolean
hasPermi
;
@Schema
(
description
=
"是否可删除"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
)
private
Boolean
deletable
;
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateDeletableReqVO.java
0 → 100644
View file @
227214db
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
controller
.
admin
.
knowledge
.
vo
.
document
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.validation.InEnum
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
jakarta.validation.constraints.NotNull
;
import
lombok.Data
;
@Schema
(
description
=
"管理后台 - AI 知识库文档更新状态 Request VO"
)
@Data
public
class
AiKnowledgeDocumentUpdateDeletableReqVO
{
@Schema
(
description
=
"编号"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"15583"
)
@NotNull
(
message
=
"编号不能为空"
)
private
Long
id
;
@Schema
(
description
=
"可删除"
,
requiredMode
=
Schema
.
RequiredMode
.
REQUIRED
,
example
=
"false"
)
@NotNull
(
message
=
"可删除字段不能为空"
)
private
Boolean
deletable
;
}
\ No newline at end of file
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/dal/dataobject/knowledge/AiKnowledgeDocumentDO.java
View file @
227214db
...
@@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
...
@@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import
com.baomidou.mybatisplus.annotation.KeySequence
;
import
com.baomidou.mybatisplus.annotation.KeySequence
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -75,4 +74,6 @@ public class AiKnowledgeDocumentDO extends BaseDO {
...
@@ -75,4 +74,6 @@ public class AiKnowledgeDocumentDO extends BaseDO {
private
Boolean
fromZip
;
private
Boolean
fromZip
;
private
Boolean
deletable
;
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentService.java
View file @
227214db
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
service
.
knowledge
;
package
cn
.
iocoder
.
yudao
.
module
.
ai
.
service
.
knowledge
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentCreateListReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.*
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateStatusReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO
;
...
@@ -132,4 +129,6 @@ public interface AiKnowledgeDocumentService {
...
@@ -132,4 +129,6 @@ public interface AiKnowledgeDocumentService {
List
<
AiKnowledgeDocumentDO
>
getKnowledgeDir
(
Long
id
);
List
<
AiKnowledgeDocumentDO
>
getKnowledgeDir
(
Long
id
);
Long
getKnowledgeSize
(
Long
userId
);
Long
getKnowledgeSize
(
Long
userId
);
void
updateKnowledgeDocumentDeletable
(
AiKnowledgeDocumentUpdateDeletableReqVO
reqVO
);
}
}
ruoyi-vue-pro-master-jdk17/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/AiKnowledgeDocumentServiceImpl.java
View file @
227214db
...
@@ -6,10 +6,7 @@ import cn.hutool.http.HttpUtil;
...
@@ -6,10 +6,7 @@ import cn.hutool.http.HttpUtil;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.enums.CommonStatusEnum
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.util.object.BeanUtils
;
import
cn.iocoder.yudao.framework.common.util.object.BeanUtils
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentCreateListReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.*
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateStatusReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO
;
import
cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO
;
import
cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO
;
...
@@ -313,6 +310,9 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
...
@@ -313,6 +310,9 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
if
(
document
==
null
)
{
if
(
document
==
null
)
{
throw
exception
(
KNOWLEDGE_DOCUMENT_NOT_EXISTS
);
throw
exception
(
KNOWLEDGE_DOCUMENT_NOT_EXISTS
);
}
}
if
(!
document
.
getDeletable
()){
throw
exception
(
KNOWLEDGE_DOCUMENT_CANNOT_DELETE
);
}
// 权限获取
// 权限获取
Long
userId
=
getLoginUserId
();
Long
userId
=
getLoginUserId
();
...
@@ -497,6 +497,23 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
...
@@ -497,6 +497,23 @@ public class AiKnowledgeDocumentServiceImpl implements AiKnowledgeDocumentServic
}
}
@Override
@Override
public
void
updateKnowledgeDocumentDeletable
(
AiKnowledgeDocumentUpdateDeletableReqVO
reqVO
)
{
// 1. 校验存在
AiKnowledgeDocumentDO
document
=
validateKnowledgeDocumentExists
(
reqVO
.
getId
());
// 2. 更新状态
knowledgeDocumentMapper
.
updateById
(
new
AiKnowledgeDocumentDO
()
.
setId
(
reqVO
.
getId
()).
setDeletable
(
reqVO
.
getDeletable
()));
// 3. 处理子目录下的文档
// List<AiKnowledgeDocumentDO> documents = knowledgeDocumentMapper.selectListByParentId(reqVO.getId());
// for (AiKnowledgeDocumentDO aiKnowledgeDocumentDO : documents) {
// aiKnowledgeDocumentDO.setDeletable(reqVO.getDeletable());
// }
// knowledgeDocumentMapper.updateBatch(documents);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
deleteKnowledgeDocumentByKnowledgeId
(
Long
knowledgeId
)
{
public
void
deleteKnowledgeDocumentByKnowledgeId
(
Long
knowledgeId
)
{
// // 1. 获取该知识库下的所有文档
// // 1. 获取该知识库下的所有文档
...
...
yudao-ui-admin-vue3/.DS_Store
View file @
227214db
No preview for this file type
yudao-ui-admin-vue3/src/api/ai/knowledge/document/index.ts
View file @
227214db
...
@@ -11,6 +11,7 @@ export interface KnowledgeDocumentVO {
...
@@ -11,6 +11,7 @@ export interface KnowledgeDocumentVO {
retrievalCount
:
number
// 召回次数
retrievalCount
:
number
// 召回次数
status
:
number
// 是否启用
status
:
number
// 是否启用
parentId
:
number
// 上级目录
parentId
:
number
// 上级目录
deletable
:
boolean
}
}
// AI 知识库文档 API
// AI 知识库文档 API
...
@@ -65,5 +66,13 @@ export const KnowledgeDocumentApi = {
...
@@ -65,5 +66,13 @@ export const KnowledgeDocumentApi = {
// 删除知识库文档
// 删除知识库文档
deleteKnowledgeDocument
:
async
(
id
:
number
)
=>
{
deleteKnowledgeDocument
:
async
(
id
:
number
)
=>
{
return
await
request
.
delete
({
url
:
`/ai/knowledge/document/delete?id=`
+
id
})
return
await
request
.
delete
({
url
:
`/ai/knowledge/document/delete?id=`
+
id
})
}
},
// 修改知识库文档状态
updateKnowledgeDocumentDeletable
:
async
(
data
:
any
)
=>
{
return
await
request
.
put
({
url
:
`/ai/knowledge/document/update-deletable`
,
data
})
},
}
}
yudao-ui-admin-vue3/src/views/ai/knowledge/document/index.vue
View file @
227214db
...
@@ -70,6 +70,17 @@
...
@@ -70,6 +70,17 @@
/>
/>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
<el-table-column
label=
"不可删除"
align=
"center"
prop=
"deletable"
>
<
template
#
default=
"scope"
>
<el-switch
v-model=
"scope.row.deletable"
:active-value=
"false"
:inactive-value=
"true"
@
change=
"handleDeletableChange(scope.row)"
:disabled=
"!checkPermi(['ai:knowledge:update'])"
/>
</
template
>
</el-table-column>
<el-table-column
<el-table-column
label=
"上传时间"
label=
"上传时间"
align=
"center"
align=
"center"
...
@@ -226,6 +237,24 @@ const handleStatusChange = async (row: KnowledgeDocumentVO) => {
...
@@ -226,6 +237,24 @@ const handleStatusChange = async (row: KnowledgeDocumentVO) => {
}
}
}
}
/** 修改可删除操作 */
const
handleDeletableChange
=
async
(
row
:
KnowledgeDocumentVO
)
=>
{
try
{
// 修改状态的二次确认
// const text = row.status === CommonStatusEnum.ENABLE ? '启用' : '禁用'
// await message.confirm('确认要"' + text + '""' + row.name + '"文档吗?')
// 发起修改状态
await
KnowledgeDocumentApi
.
updateKnowledgeDocumentDeletable
({
id
:
row
.
id
,
deletable
:
row
.
deletable
})
message
.
success
(
t
(
'common.updateSuccess'
))
// 刷新列表
await
getList
()
}
catch
{
// 取消后,进行恢复按钮
row
.
deletable
=
row
.
deletable
===
CommonStatusEnum
.
ENABLE
?
CommonStatusEnum
.
DISABLE
:
CommonStatusEnum
.
ENABLE
}
}
/** 跳转到知识库分段页面 */
/** 跳转到知识库分段页面 */
const
handleSegment
=
(
id
:
number
)
=>
{
const
handleSegment
=
(
id
:
number
)
=>
{
router
.
push
({
router
.
push
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment