mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-19 07:33:44 +08:00
添加知识库权限控制功能
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package org.ruoyi.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库角色对象 knowledge_role
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("knowledge_role")
|
||||
public class KnowledgeRole extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 知识库角色id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 知识库角色组id
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 知识库角色name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 知识库id列表
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<Long> knowledgeIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.ruoyi.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 知识库角色组对象 knowledge_role_group
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("knowledge_role_group")
|
||||
public class KnowledgeRoleGroup extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 知识库角色组id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 知识库角色组name
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.ruoyi.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 知识库角色与知识库关联对象 knowledge_role_relation
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("knowledge_role_relation")
|
||||
public class KnowledgeRoleRelation extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 知识库角色id
|
||||
*/
|
||||
private Long knowledgeRoleId;
|
||||
|
||||
/**
|
||||
* 知识库id
|
||||
*/
|
||||
private Long knowledgeId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.ruoyi.domain.bo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
import org.ruoyi.domain.KnowledgeRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库角色业务对象 knowledge_role
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = KnowledgeRole.class, reverseConvertGenerate = false)
|
||||
public class KnowledgeRoleBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 知识库角色id
|
||||
*/
|
||||
@NotNull(message = "知识库角色id不能为空", groups = {EditGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 知识库角色组id
|
||||
*/
|
||||
@NotNull(message = "知识库角色组id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 知识库角色name
|
||||
*/
|
||||
@NotBlank(message = "知识库角色name不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 知识库id列表
|
||||
*/
|
||||
private List<Long> knowledgeIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.ruoyi.domain.bo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
import org.ruoyi.domain.KnowledgeRoleGroup;
|
||||
|
||||
/**
|
||||
* 知识库角色组业务对象 knowledge_role_group
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = KnowledgeRoleGroup.class, reverseConvertGenerate = false)
|
||||
public class KnowledgeRoleGroupBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 知识库角色组id
|
||||
*/
|
||||
@NotNull(message = "知识库角色组id不能为空", groups = {EditGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 知识库角色组name
|
||||
*/
|
||||
@NotBlank(message = "知识库角色组name不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.ruoyi.domain.bo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.core.domain.BaseEntity;
|
||||
import org.ruoyi.domain.KnowledgeRoleRelation;
|
||||
|
||||
/**
|
||||
* 知识库角色与知识库关联业务对象 knowledge_role_relation
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = KnowledgeRoleRelation.class, reverseConvertGenerate = false)
|
||||
public class KnowledgeRoleRelationBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@NotNull(message = "id不能为空", groups = {EditGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@NotBlank(message = "备注不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 知识库角色id
|
||||
*/
|
||||
@NotNull(message = "知识库角色id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long knowledgeRoleId;
|
||||
|
||||
/**
|
||||
* 知识库id
|
||||
*/
|
||||
@NotNull(message = "知识库id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long knowledgeId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package org.ruoyi.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.ruoyi.domain.KnowledgeRoleGroup;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 知识库角色组视图对象 knowledge_role_group
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = KnowledgeRoleGroup.class)
|
||||
public class KnowledgeRoleGroupVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 知识库角色组id
|
||||
*/
|
||||
@ExcelProperty(value = "知识库角色组id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 知识库角色组name
|
||||
*/
|
||||
@ExcelProperty(value = "知识库角色组名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@ExcelProperty(value = "创建者")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@ExcelProperty(value = "更新时间")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ExcelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.ruoyi.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.ruoyi.domain.KnowledgeRoleRelation;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 知识库角色与知识库关联视图对象 knowledge_role_relation
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = KnowledgeRoleRelation.class)
|
||||
public class KnowledgeRoleRelationVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ExcelProperty(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 知识库角色id
|
||||
*/
|
||||
@ExcelProperty(value = "知识库角色id")
|
||||
private Long knowledgeRoleId;
|
||||
|
||||
/**
|
||||
* 知识库id
|
||||
*/
|
||||
@ExcelProperty(value = "知识库id")
|
||||
private Long knowledgeId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.ruoyi.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.ruoyi.domain.KnowledgeRole;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 知识库角色视图对象 knowledge_role
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = KnowledgeRole.class)
|
||||
public class KnowledgeRoleVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 知识库角色id
|
||||
*/
|
||||
@ExcelProperty(value = "知识库角色id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 知识库角色组id
|
||||
*/
|
||||
@ExcelProperty(value = "知识库角色组id")
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 知识库角色name
|
||||
*/
|
||||
@ExcelProperty(value = "知识库角色name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@ExcelProperty(value = "创建者")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@ExcelProperty(value = "更新时间")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ExcelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 知识库id列表
|
||||
*/
|
||||
private List<Long> knowledgeIds;
|
||||
|
||||
|
||||
/**
|
||||
* 角色组名称
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.ruoyi.mapper;
|
||||
|
||||
import org.ruoyi.core.mapper.BaseMapperPlus;
|
||||
import org.ruoyi.domain.KnowledgeRoleGroup;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleGroupVo;
|
||||
|
||||
/**
|
||||
* 知识库角色组Mapper接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface KnowledgeRoleGroupMapper extends BaseMapperPlus<KnowledgeRoleGroup, KnowledgeRoleGroupVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.ruoyi.mapper;
|
||||
|
||||
import org.ruoyi.core.mapper.BaseMapperPlus;
|
||||
import org.ruoyi.domain.KnowledgeRole;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleVo;
|
||||
|
||||
/**
|
||||
* 知识库角色Mapper接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface KnowledgeRoleMapper extends BaseMapperPlus<KnowledgeRole, KnowledgeRoleVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.ruoyi.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.ruoyi.core.mapper.BaseMapperPlus;
|
||||
import org.ruoyi.domain.KnowledgeRoleRelation;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleRelationVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库角色与知识库关联Mapper接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface KnowledgeRoleRelationMapper extends BaseMapperPlus<KnowledgeRoleRelation, KnowledgeRoleRelationVo> {
|
||||
@Select("SELECT knowledge_id FROM knowledge_role_relation WHERE knowledge_role_id = #{knowledgeRoleId}")
|
||||
List<Long> selectKnowledgeIdsByRoleId(@Param("knowledgeRoleId") Long knowledgeRoleId);
|
||||
|
||||
/**
|
||||
* 根据 roleId 删除所有关联
|
||||
*/
|
||||
@Delete("DELETE FROM knowledge_role_relation WHERE knowledge_role_id = #{knowledgeRoleId}")
|
||||
void deleteByRoleId(@Param("knowledgeRoleId") Long knowledgeRoleId);
|
||||
|
||||
@Delete({
|
||||
"<script>",
|
||||
"DELETE FROM knowledge_role_relation",
|
||||
"WHERE knowledge_role_id IN",
|
||||
"<foreach collection='knowledgeRoleIds' item='id' open='(' separator=',' close=')'>",
|
||||
"#{id}",
|
||||
"</foreach>",
|
||||
"</script>"
|
||||
})
|
||||
void deleteByRoleIds(@Param("knowledgeRoleIds") List<Long> knowledgeRoleIds);
|
||||
}
|
||||
@@ -28,6 +28,11 @@ public interface IKnowledgeInfoService {
|
||||
*/
|
||||
TableDataInfo<KnowledgeInfoVo> queryPageList(KnowledgeInfoBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询知识库列表
|
||||
*/
|
||||
TableDataInfo<KnowledgeInfoVo> queryPageListByRole(PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询知识库列表
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.ruoyi.service;
|
||||
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.bo.KnowledgeRoleGroupBo;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleGroupVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库角色组Service接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface IKnowledgeRoleGroupService {
|
||||
|
||||
/**
|
||||
* 查询知识库角色组
|
||||
*/
|
||||
KnowledgeRoleGroupVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询知识库角色组列表
|
||||
*/
|
||||
TableDataInfo<KnowledgeRoleGroupVo> queryPageList(KnowledgeRoleGroupBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询知识库角色组列表
|
||||
*/
|
||||
List<KnowledgeRoleGroupVo> queryList(KnowledgeRoleGroupBo bo);
|
||||
|
||||
/**
|
||||
* 新增知识库角色组
|
||||
*/
|
||||
Boolean insertByBo(KnowledgeRoleGroupBo bo);
|
||||
|
||||
/**
|
||||
* 修改知识库角色组
|
||||
*/
|
||||
Boolean updateByBo(KnowledgeRoleGroupBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除知识库角色组信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.ruoyi.service;
|
||||
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.bo.KnowledgeRoleRelationBo;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleRelationVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库角色与知识库关联Service接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface IKnowledgeRoleRelationService {
|
||||
|
||||
/**
|
||||
* 查询知识库角色与知识库关联
|
||||
*/
|
||||
KnowledgeRoleRelationVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询知识库角色与知识库关联列表
|
||||
*/
|
||||
TableDataInfo<KnowledgeRoleRelationVo> queryPageList(KnowledgeRoleRelationBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询知识库角色与知识库关联列表
|
||||
*/
|
||||
List<KnowledgeRoleRelationVo> queryList(KnowledgeRoleRelationBo bo);
|
||||
|
||||
/**
|
||||
* 新增知识库角色与知识库关联
|
||||
*/
|
||||
Boolean insertByBo(KnowledgeRoleRelationBo bo);
|
||||
|
||||
/**
|
||||
* 修改知识库角色与知识库关联
|
||||
*/
|
||||
Boolean updateByBo(KnowledgeRoleRelationBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除知识库角色与知识库关联信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.ruoyi.service;
|
||||
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.bo.KnowledgeRoleBo;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 知识库角色Service接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
public interface IKnowledgeRoleService {
|
||||
|
||||
/**
|
||||
* 查询知识库角色
|
||||
*/
|
||||
KnowledgeRoleVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询知识库角色列表
|
||||
*/
|
||||
TableDataInfo<KnowledgeRoleVo> queryPageList(KnowledgeRoleBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询知识库角色列表
|
||||
*/
|
||||
List<KnowledgeRoleVo> queryList(KnowledgeRoleBo bo);
|
||||
|
||||
/**
|
||||
* 新增知识库角色
|
||||
*/
|
||||
Boolean insertByBo(KnowledgeRoleBo bo);
|
||||
|
||||
/**
|
||||
* 修改知识库角色
|
||||
*/
|
||||
Boolean updateByBo(KnowledgeRoleBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除知识库角色信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package org.ruoyi.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.KnowledgeRoleGroup;
|
||||
import org.ruoyi.domain.bo.KnowledgeRoleGroupBo;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleGroupVo;
|
||||
import org.ruoyi.mapper.KnowledgeRoleGroupMapper;
|
||||
import org.ruoyi.service.IKnowledgeRoleGroupService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 知识库角色组Service业务层处理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class KnowledgeRoleGroupServiceImpl implements IKnowledgeRoleGroupService {
|
||||
|
||||
private final KnowledgeRoleGroupMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询知识库角色组
|
||||
*/
|
||||
@Override
|
||||
public KnowledgeRoleGroupVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询知识库角色组列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<KnowledgeRoleGroupVo> queryPageList(KnowledgeRoleGroupBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<KnowledgeRoleGroup> lqw = buildQueryWrapper(bo);
|
||||
Page<KnowledgeRoleGroupVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询知识库角色组列表
|
||||
*/
|
||||
@Override
|
||||
public List<KnowledgeRoleGroupVo> queryList(KnowledgeRoleGroupBo bo) {
|
||||
LambdaQueryWrapper<KnowledgeRoleGroup> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<KnowledgeRoleGroup> buildQueryWrapper(KnowledgeRoleGroupBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<KnowledgeRoleGroup> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getName()), KnowledgeRoleGroup::getName, bo.getName());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增知识库角色组
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(KnowledgeRoleGroupBo bo) {
|
||||
KnowledgeRoleGroup add = MapstructUtils.convert(bo, KnowledgeRoleGroup.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改知识库角色组
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(KnowledgeRoleGroupBo bo) {
|
||||
KnowledgeRoleGroup update = MapstructUtils.convert(bo, KnowledgeRoleGroup.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(KnowledgeRoleGroup entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除知识库角色组
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package org.ruoyi.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.KnowledgeRoleRelation;
|
||||
import org.ruoyi.domain.bo.KnowledgeRoleRelationBo;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleRelationVo;
|
||||
import org.ruoyi.mapper.KnowledgeRoleRelationMapper;
|
||||
import org.ruoyi.service.IKnowledgeRoleRelationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 知识库角色与知识库关联Service业务层处理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class KnowledgeRoleRelationServiceImpl implements IKnowledgeRoleRelationService {
|
||||
|
||||
private final KnowledgeRoleRelationMapper baseMapper;
|
||||
private final KnowledgeRoleRelationMapper knowledgeRoleRelationMapper;
|
||||
|
||||
/**
|
||||
* 查询知识库角色与知识库关联
|
||||
*/
|
||||
@Override
|
||||
public KnowledgeRoleRelationVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询知识库角色与知识库关联列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<KnowledgeRoleRelationVo> queryPageList(KnowledgeRoleRelationBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<KnowledgeRoleRelation> lqw = buildQueryWrapper(bo);
|
||||
Page<KnowledgeRoleRelationVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询知识库角色与知识库关联列表
|
||||
*/
|
||||
@Override
|
||||
public List<KnowledgeRoleRelationVo> queryList(KnowledgeRoleRelationBo bo) {
|
||||
LambdaQueryWrapper<KnowledgeRoleRelation> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<KnowledgeRoleRelation> buildQueryWrapper(KnowledgeRoleRelationBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<KnowledgeRoleRelation> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getKnowledgeRoleId() != null, KnowledgeRoleRelation::getKnowledgeRoleId, bo.getKnowledgeRoleId());
|
||||
lqw.eq(bo.getKnowledgeId() != null, KnowledgeRoleRelation::getKnowledgeId, bo.getKnowledgeId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增知识库角色与知识库关联
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(KnowledgeRoleRelationBo bo) {
|
||||
KnowledgeRoleRelation add = MapstructUtils.convert(bo, KnowledgeRoleRelation.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改知识库角色与知识库关联
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(KnowledgeRoleRelationBo bo) {
|
||||
KnowledgeRoleRelation update = MapstructUtils.convert(bo, KnowledgeRoleRelation.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(KnowledgeRoleRelation entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除知识库角色与知识库关联
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
public void saveRoleKnowledgeRelations(Long knowledgeRoleId, List<Long> knowledgeIds) {
|
||||
if (knowledgeRoleId == null) {
|
||||
throw new IllegalArgumentException("knowledgeRoleId不能为空");
|
||||
}
|
||||
|
||||
// 1. 删除旧的关联记录
|
||||
knowledgeRoleRelationMapper.deleteByRoleId(knowledgeRoleId);
|
||||
|
||||
// 2. 插入新的关联记录
|
||||
if (CollectionUtils.isNotEmpty(knowledgeIds)) {
|
||||
List<KnowledgeRoleRelation> insertList = new ArrayList<>();
|
||||
knowledgeIds.forEach(knowledgeId -> {
|
||||
KnowledgeRoleRelation knowledgeRoleRelation = new KnowledgeRoleRelation();
|
||||
knowledgeRoleRelation.setKnowledgeId(knowledgeId);
|
||||
knowledgeRoleRelation.setKnowledgeRoleId(knowledgeRoleId);
|
||||
insertList.add(knowledgeRoleRelation);
|
||||
});
|
||||
knowledgeRoleRelationMapper.insertBatch(insertList);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package org.ruoyi.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.core.page.PageQuery;
|
||||
import org.ruoyi.core.page.TableDataInfo;
|
||||
import org.ruoyi.domain.KnowledgeRole;
|
||||
import org.ruoyi.domain.KnowledgeRoleGroup;
|
||||
import org.ruoyi.domain.KnowledgeRoleRelation;
|
||||
import org.ruoyi.domain.bo.KnowledgeRoleBo;
|
||||
import org.ruoyi.domain.vo.KnowledgeRoleVo;
|
||||
import org.ruoyi.mapper.KnowledgeRoleGroupMapper;
|
||||
import org.ruoyi.mapper.KnowledgeRoleMapper;
|
||||
import org.ruoyi.mapper.KnowledgeRoleRelationMapper;
|
||||
import org.ruoyi.service.IKnowledgeRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 知识库角色Service业务层处理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-07-19
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class KnowledgeRoleServiceImpl implements IKnowledgeRoleService {
|
||||
|
||||
private final KnowledgeRoleMapper baseMapper;
|
||||
private final KnowledgeRoleGroupMapper knowledgeRoleGroupMapper;
|
||||
private final KnowledgeRoleRelationMapper knowledgeRoleRelationMapper;
|
||||
private final KnowledgeRoleRelationServiceImpl knowledgeRoleRelationServiceImpl;
|
||||
|
||||
/**
|
||||
* 查询知识库角色
|
||||
*/
|
||||
@Override
|
||||
public KnowledgeRoleVo queryById(Long id) {
|
||||
KnowledgeRoleVo vo = baseMapper.selectVoById(id);
|
||||
fillKnowledgeIds(vo);
|
||||
fillKnowledgeRoleGroupName(vo);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询知识库角色列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<KnowledgeRoleVo> queryPageList(KnowledgeRoleBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<KnowledgeRole> lqw = buildQueryWrapper(bo);
|
||||
Page<KnowledgeRoleVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
|
||||
fillKnowledgeIds(result.getRecords());
|
||||
fillKnowledgeRoleGroupName(result.getRecords());
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询知识库角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<KnowledgeRoleVo> queryList(KnowledgeRoleBo bo) {
|
||||
LambdaQueryWrapper<KnowledgeRole> lqw = buildQueryWrapper(bo);
|
||||
List<KnowledgeRoleVo> knowledgeRoleVos = baseMapper.selectVoList(lqw);
|
||||
fillKnowledgeIds(knowledgeRoleVos);
|
||||
fillKnowledgeRoleGroupName(knowledgeRoleVos);
|
||||
return knowledgeRoleVos;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<KnowledgeRole> buildQueryWrapper(KnowledgeRoleBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<KnowledgeRole> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getGroupId() != null, KnowledgeRole::getGroupId, bo.getGroupId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增知识库角色
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(KnowledgeRoleBo bo) {
|
||||
KnowledgeRole add = MapstructUtils.convert(bo, KnowledgeRole.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
|
||||
// 生成relation数据
|
||||
knowledgeRoleRelationServiceImpl.saveRoleKnowledgeRelations(bo.getId(), bo.getKnowledgeIds());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改知识库角色
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(KnowledgeRoleBo bo) {
|
||||
KnowledgeRole update = MapstructUtils.convert(bo, KnowledgeRole.class);
|
||||
validEntityBeforeSave(update);
|
||||
int count = baseMapper.updateById(update);
|
||||
if (count > 0) {
|
||||
// 生成relation数据
|
||||
knowledgeRoleRelationServiceImpl.saveRoleKnowledgeRelations(bo.getId(), bo.getKnowledgeIds());
|
||||
}
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(KnowledgeRole entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除知识库角色
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
int count = baseMapper.deleteBatchIds(ids);
|
||||
if (count > 0) {
|
||||
knowledgeRoleRelationMapper.deleteByRoleIds(ids.stream().toList());
|
||||
}
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充 VO 的 knowledgeIds 字段(从中间表查询)
|
||||
*/
|
||||
private void fillKnowledgeIds(KnowledgeRoleVo vo) {
|
||||
if (vo == null) return;
|
||||
List<Long> knowledgeIds = knowledgeRoleRelationMapper.selectKnowledgeIdsByRoleId(vo.getId());
|
||||
vo.setKnowledgeIds(knowledgeIds);
|
||||
}
|
||||
|
||||
private void fillKnowledgeIds(List<KnowledgeRoleVo> list) {
|
||||
if (CollectionUtils.isEmpty(list)) return;
|
||||
|
||||
// 1. 提取所有 roleId
|
||||
Set<Long> roleIds = list.stream()
|
||||
.map(KnowledgeRoleVo::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (roleIds.isEmpty()) return;
|
||||
|
||||
// 2. 一次性查询所有 roleId 对应的 knowledgeId 列表
|
||||
List<KnowledgeRoleRelation> relations = knowledgeRoleRelationMapper.selectList(
|
||||
new LambdaQueryWrapper<KnowledgeRoleRelation>()
|
||||
.in(KnowledgeRoleRelation::getKnowledgeRoleId, roleIds)
|
||||
);
|
||||
|
||||
// 3. 转为 Map<roleId, List<knowledgeId>>
|
||||
Map<Long, List<Long>> roleIdToKnowledgeIds = relations.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
KnowledgeRoleRelation::getKnowledgeRoleId,
|
||||
Collectors.mapping(KnowledgeRoleRelation::getKnowledgeId, Collectors.toList())
|
||||
));
|
||||
|
||||
// 4. 回填到 VO 中
|
||||
for (KnowledgeRoleVo vo : list) {
|
||||
vo.setKnowledgeIds(roleIdToKnowledgeIds.getOrDefault(vo.getId(), Collections.emptyList()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充 VO 的 knowledgeRoleGroupName 字段
|
||||
*/
|
||||
private void fillKnowledgeRoleGroupName(KnowledgeRoleVo vo) {
|
||||
if (vo == null || vo.getGroupId() == null) return;
|
||||
|
||||
KnowledgeRoleGroup group = knowledgeRoleGroupMapper.selectById(vo.getGroupId());
|
||||
if (group != null) {
|
||||
vo.setGroupName(group.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void fillKnowledgeRoleGroupName(List<KnowledgeRoleVo> list) {
|
||||
if (CollectionUtils.isEmpty(list)) return;
|
||||
|
||||
// 1. 提取所有 groupId(去重)
|
||||
Set<Long> groupIds = list.stream()
|
||||
.map(KnowledgeRoleVo::getGroupId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (groupIds.isEmpty()) return;
|
||||
|
||||
// 2. 一次性查出所有角色组信息
|
||||
List<KnowledgeRoleGroup> groupList = knowledgeRoleGroupMapper.selectBatchIds(groupIds);
|
||||
|
||||
// 3. 转为 Map<id, name>
|
||||
Map<Long, String> groupNameMap = groupList.stream()
|
||||
.collect(Collectors.toMap(KnowledgeRoleGroup::getId, KnowledgeRoleGroup::getName));
|
||||
|
||||
// 4. 回填到每个 VO
|
||||
for (KnowledgeRoleVo vo : list) {
|
||||
vo.setGroupName(groupNameMap.get(vo.getGroupId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user