From b52f7a711208de39575fff795c514e95dd47bec4 Mon Sep 17 00:00:00 2001 From: violateer <1828257089@qq.com> Date: Fri, 15 Aug 2025 20:41:59 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93=E8=A7=92=E8=89=B2=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8F=AF=E8=A7=81=E4=B8=AA=E4=BA=BA=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E5=8F=8A=E8=A7=92=E8=89=B2=E5=88=86=E9=85=8D=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/src/main/resources/application.yml | 2 +- .../org/ruoyi/service/IKnowledgeInfoService.java | 2 +- .../controller/knowledge/KnowledgeController.java | 14 +++----------- .../knowledge/KnowledgeInfoServiceImpl.java | 13 ++++++++++--- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 1992a5ab..f6abd846 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -162,7 +162,7 @@ tenant: - sys_user_role knowledge-role: - enable: false + enable: true # MyBatisPlus配置 # https://baomidou.com/config/ diff --git a/ruoyi-modules-api/ruoyi-knowledge-api/src/main/java/org/ruoyi/service/IKnowledgeInfoService.java b/ruoyi-modules-api/ruoyi-knowledge-api/src/main/java/org/ruoyi/service/IKnowledgeInfoService.java index 3972677d..754ba7c7 100644 --- a/ruoyi-modules-api/ruoyi-knowledge-api/src/main/java/org/ruoyi/service/IKnowledgeInfoService.java +++ b/ruoyi-modules-api/ruoyi-knowledge-api/src/main/java/org/ruoyi/service/IKnowledgeInfoService.java @@ -31,7 +31,7 @@ public interface IKnowledgeInfoService { /** * 查询知识库列表 */ - TableDataInfo queryPageListByRole(PageQuery pageQuery); + TableDataInfo queryPageListByRole(KnowledgeInfoBo bo, PageQuery pageQuery); /** * 查询知识库列表 diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/controller/knowledge/KnowledgeController.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/controller/knowledge/KnowledgeController.java index 76443156..a1a72e1a 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/controller/knowledge/KnowledgeController.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/controller/knowledge/KnowledgeController.java @@ -7,7 +7,6 @@ import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import org.ruoyi.chat.config.KnowledgeRoleConfig; import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.core.domain.model.LoginUser; import org.ruoyi.common.core.validate.AddGroup; import org.ruoyi.common.excel.utils.ExcelUtil; import org.ruoyi.common.log.annotation.Log; @@ -27,14 +26,7 @@ import org.ruoyi.service.IKnowledgeAttachService; import org.ruoyi.service.IKnowledgeFragmentService; import org.ruoyi.service.IKnowledgeInfoService; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.List; @@ -90,8 +82,8 @@ public class KnowledgeController extends BaseController { bo.setUid(LoginHelper.getUserId()); return knowledgeInfoService.queryPageList(bo, pageQuery); } else { - // TODO 自己创建的知识库+角色分配的知识库 - return knowledgeInfoService.queryPageListByRole(pageQuery); + bo.setUid(LoginHelper.getUserId()); + return knowledgeInfoService.queryPageListByRole(bo, pageQuery); } } diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/knowledge/KnowledgeInfoServiceImpl.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/knowledge/KnowledgeInfoServiceImpl.java index d2eb1276..12ccab1f 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/knowledge/KnowledgeInfoServiceImpl.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/knowledge/KnowledgeInfoServiceImpl.java @@ -89,7 +89,7 @@ public class KnowledgeInfoServiceImpl implements IKnowledgeInfoService { * 根据知识库角色查询知识库列表 */ @Override - public TableDataInfo queryPageListByRole(PageQuery pageQuery) { + public TableDataInfo queryPageListByRole(KnowledgeInfoBo bo, PageQuery pageQuery) { // 查询用户关联角色 LoginUser loginUser = LoginHelper.getLoginUser(); if (StringUtils.isEmpty(loginUser.getKroleGroupIds()) || StringUtils.isEmpty(loginUser.getKroleGroupType())) { @@ -122,8 +122,15 @@ public class KnowledgeInfoServiceImpl implements IKnowledgeInfoService { return new TableDataInfo<>(); } - LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); - lqw.in(KnowledgeInfo::getId, knowledgeRoleRelations.stream().map(KnowledgeRoleRelation::getKnowledgeId).filter(Objects::nonNull).collect(Collectors.toList())); + LambdaQueryWrapper lqw = buildQueryWrapper(bo); + // 在查询用户创建的知识库条件下,拼接角色分配知识库 + lqw.or(q -> q.in( + KnowledgeInfo::getId, + knowledgeRoleRelations.stream() + .map(KnowledgeRoleRelation::getKnowledgeId) + .filter(Objects::nonNull) + .collect(Collectors.toList()) + )); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); return TableDataInfo.build(result); }