提交 78813b6e 作者: yanxin

增加专题权限控制

上级 0ab2861d
package com.zzsn.event.mapper; package com.zzsn.event.mapper;
import com.zzsn.event.entity.ClbLabelItem;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -32,7 +31,7 @@ public interface CommonMapper { ...@@ -32,7 +31,7 @@ public interface CommonMapper {
* @author lkg * @author lkg
* @date 2024/9/13 * @date 2024/9/13
*/ */
List<Node> projectList(); List<Node> projectList(@Param("userId") String userId);
/** /**
* 企业标签下的企业信用代码集合 * 企业标签下的企业信用代码集合
......
...@@ -40,7 +40,7 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -40,7 +40,7 @@ public interface SubjectMapper extends BaseMapper<Subject> {
* @author lkg * @author lkg
* @date 2025/3/25 * @date 2025/3/25
*/ */
Page<SubjectPageVO> pageList_new(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPageVO> page); Page<SubjectPageVO> pageList_new(Page<SubjectPageVO> page,@Param("subjectCondition") SubjectCondition subjectCondition,@Param("userId") String userId);
/** /**
* 专题详情(包含专题分类、专题项目) * 专题详情(包含专题分类、专题项目)
......
...@@ -22,17 +22,19 @@ public interface SubjectTypeMapMapper extends BaseMapper<SubjectTypeMap> { ...@@ -22,17 +22,19 @@ public interface SubjectTypeMapMapper extends BaseMapper<SubjectTypeMap> {
* 分类下的专题id集合 * 分类下的专题id集合
* *
* @param typeIds 分类id集合 * @param typeIds 分类id集合
* @param userId
* @author lkg * @author lkg
* @date 2024/5/6 * @date 2024/5/6
*/ */
List<String> selectSubjectByTypeIds(@Param("typeIds") List<String> typeIds); List<String> selectSubjectByTypeIds(@Param("typeIds") List<String> typeIds, @Param("userId")String userId);
/** /**
* 分类下的事件id集合 * 分类下的事件id集合
* *
* @param typeIds 分类id集合 * @param typeIds 分类id集合
* @param userId
* @author lkg * @author lkg
* @date 2024/5/6 * @date 2024/5/6
*/ */
List<String> selectEventByTypeIds(@Param("typeIds") List<String> typeIds); List<String> selectEventByTypeIds(@Param("typeIds") List<String> typeIds, @Param("userId")String userId);
} }
...@@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description: 专题类别 * @Description: 专题类别
...@@ -29,7 +28,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> { ...@@ -29,7 +28,7 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @author lkg * @author lkg
* @date 2024/4/29 * @date 2024/4/29
*/ */
List<Node> enableList(@Param("category") Integer category,@Param("username") String createBy); List<Node> enableList(@Param("category") Integer category,@Param("username") String createBy,@Param("userId") String userId);
/** /**
* 可用的专题和客户列表 * 可用的专题和客户列表
...@@ -64,12 +63,13 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> { ...@@ -64,12 +63,13 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* 按分类分组,获取绑定专题/事件数量 * 按分类分组,获取绑定专题/事件数量
* *
* @param category 类别(1-专题;2-事件) * @param category 类别(1-专题;2-事件)
* @param userId
* @author lkg * @author lkg
* @date 2025/1/8 * @date 2025/1/8
*/ */
List<SubjectTypeTreeVO> typeBindCountTreeList(@Param("category") Integer category); List<SubjectTypeTreeVO> typeBindCountTreeList(@Param("category") Integer category, @Param("userId") String userId);
List<SubjectTypeTreeVO> typeBindSubjectList(); List<SubjectTypeTreeVO> typeBindSubjectList(@Param("userId")String userId);
List<SubjectTypeTreeVO> typeBindEventList(); List<SubjectTypeTreeVO> typeBindEventList(@Param("userId")String userId);
/** /**
* 根据是否公开获取专题列表 * 根据是否公开获取专题列表
...@@ -134,4 +134,12 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> { ...@@ -134,4 +134,12 @@ public interface SubjectTypeMapper extends BaseMapper<SubjectType> {
* @date 2024/4/29 * @date 2024/4/29
*/ */
List<SubjectTreeVO> eventAndTypeTree(@Param("userId") String userId, @Param("customerId") String customerId); List<SubjectTreeVO> eventAndTypeTree(@Param("userId") String userId, @Param("customerId") String customerId);
/**
* 获取全部有权访问的分类列表
* @param category
* @param userId
* @return
*/
List<SubjectType> allList(@Param("category") Integer category, @Param("userId") String userId);
} }
...@@ -148,6 +148,9 @@ ...@@ -148,6 +148,9 @@
<select id="projectList" resultType="com.zzsn.event.util.tree.Node"> <select id="projectList" resultType="com.zzsn.event.util.tree.Node">
select s.id, s.project_name as name select s.id, s.project_name as name
from project s from project s
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on s.id=dp.permission_id and dp.user_id = #{userId}
</if>
where s.is_delete = 0 where s.is_delete = 0
and s.status = 1 and s.status = 1
</select> </select>
......
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
s.total_num,s.un_check_num,s.bind_source_num,s.bind_keyword_num,s.latest_data_date, s.total_num,s.un_check_num,s.bind_source_num,s.bind_keyword_num,s.latest_data_date,
c.type_name as subjectTypeName, g.project_name as projectName c.type_name as subjectTypeName, g.project_name as projectName
from subject d from subject d
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on d.id=dp.permission_id and dp.user_id = #{userId}
</if>
INNER JOIN subject_type_map b ON b.subject_id = d.id INNER JOIN subject_type_map b ON b.subject_id = d.id
INNER JOIN subject_type c ON b.type_id = c.id INNER JOIN subject_type c ON b.type_id = c.id
LEFT JOIN project_subject_map f ON f.subject_id = d.id LEFT JOIN project_subject_map f ON f.subject_id = d.id
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
</delete> </delete>
<select id="selectSubjectByTypeIds" resultType="String"> <select id="selectSubjectByTypeIds" resultType="String">
select distinct a.id from subject a select distinct a.id from subject a
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on a.id=dp.permission_id and dp.user_id = #{userId}
</if>
inner join subject_type_map c on c.subject_id = a.id inner join subject_type_map c on c.subject_id = a.id
where 1=1 where 1=1
<if test="typeIds!=null and typeIds.size()>0"> <if test="typeIds!=null and typeIds.size()>0">
...@@ -18,6 +21,9 @@ ...@@ -18,6 +21,9 @@
</select> </select>
<select id="selectEventByTypeIds" resultType="String"> <select id="selectEventByTypeIds" resultType="String">
select distinct a.id from event a select distinct a.id from event a
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on a.id=dp.permission_id and dp.user_id = #{userId}
</if>
inner join subject_type_map c on c.subject_id = a.id inner join subject_type_map c on c.subject_id = a.id
where 1=1 where 1=1
<if test="typeIds!=null and typeIds.size()>0"> <if test="typeIds!=null and typeIds.size()>0">
......
...@@ -5,11 +5,15 @@ ...@@ -5,11 +5,15 @@
<select id="enableList" resultType="com.zzsn.event.util.tree.Node"> <select id="enableList" resultType="com.zzsn.event.util.tree.Node">
select s.id, s.type_name as name, s.pid select s.id, s.type_name as name, s.pid
from subject_type s from subject_type s
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on s.id=dp.permission_id and dp.user_id = #{userId}
</if>
where s.category = #{category} where s.category = #{category}
and s.status = 1 and s.status = 1
<if test="username!=null and username != ''"> <if test="username!=null and username != ''">
and s.create_by = #{username} and s.create_by = #{username}
</if> </if>
</select> </select>
<update id="updateTreeNodeStatus" parameterType="java.lang.String"> <update id="updateTreeNodeStatus" parameterType="java.lang.String">
...@@ -21,6 +25,9 @@ ...@@ -21,6 +25,9 @@
<select id="typeBindCountTreeList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO"> <select id="typeBindCountTreeList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO">
SELECT t.id,t.type_name as name,t.pid,count(m.type_id) as subjectCount,t.create_time,'false' as ynSubject SELECT t.id,t.type_name as name,t.pid,count(m.type_id) as subjectCount,t.create_time,'false' as ynSubject
FROM subject_type t FROM subject_type t
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on t.id=dp.permission_id and dp.user_id = #{userId}
</if>
inner join `subject_type_map` m on t.id = m.type_id inner join `subject_type_map` m on t.id = m.type_id
<if test="category != null and category == 1"> <if test="category != null and category == 1">
left join subject s on m.subject_id = s.id left join subject s on m.subject_id = s.id
...@@ -35,12 +42,18 @@ ...@@ -35,12 +42,18 @@
<select id="typeBindSubjectList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO"> <select id="typeBindSubjectList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO">
SELECT s.id,s.subject_name as name,m.type_id as pid,'0' as subjectCount,s.create_time,'true' as ynSubject SELECT s.id,s.subject_name as name,m.type_id as pid,'0' as subjectCount,s.create_time,'true' as ynSubject
FROM subject s FROM subject s
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on s.id=dp.permission_id and dp.user_id = #{userId}
</if>
inner join `subject_type_map` m on s.id = m.subject_id inner join `subject_type_map` m on s.id = m.subject_id
order by s.sort_order,s.create_time desc order by s.sort_order,s.create_time desc
</select> </select>
<select id="typeBindEventList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO"> <select id="typeBindEventList" resultType="com.zzsn.event.vo.SubjectTypeTreeVO">
SELECT s.id,s.event_name as name,m.type_id as pid,'0' as subjectCount,s.create_time,'true' as ynSubject SELECT s.id,s.event_name as name,m.type_id as pid,'0' as subjectCount,s.create_time,'true' as ynSubject
FROM event s FROM event s
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on s.id=dp.permission_id and dp.user_id = #{userId}
</if>
inner join `subject_type_map` m on s.id = m.subject_id inner join `subject_type_map` m on s.id = m.subject_id
order by s.sort_order,s.create_time desc order by s.sort_order,s.create_time desc
</select> </select>
...@@ -217,4 +230,11 @@ ...@@ -217,4 +230,11 @@
) x ) x
order by x.create_time desc order by x.create_time desc
</select> </select>
<select id="allList" resultType="com.zzsn.event.entity.SubjectType">
select t.* from subject_type t
<if test="userId !=null and userId != ''">
inner join sys_user_data_permission dp on t.id=dp.permission_id and dp.user_id = #{userId}
</if>
</select>
</mapper> </mapper>
...@@ -13,6 +13,7 @@ import com.zzsn.event.service.*; ...@@ -13,6 +13,7 @@ import com.zzsn.event.service.*;
import com.zzsn.event.util.DateUtil; import com.zzsn.event.util.DateUtil;
import com.zzsn.event.util.ObsUtil; import com.zzsn.event.util.ObsUtil;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -55,7 +56,7 @@ public class CommonServiceImpl implements CommonService { ...@@ -55,7 +56,7 @@ public class CommonServiceImpl implements CommonService {
@Override @Override
public List<Node> projectList() { public List<Node> projectList() {
return commonMapper.projectList(); return commonMapper.projectList(AuthUtil.getAuthUserId());
} }
@Override @Override
......
...@@ -27,6 +27,7 @@ import com.zzsn.event.permit.UQueryEntity; ...@@ -27,6 +27,7 @@ import com.zzsn.event.permit.UQueryEntity;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.*; import com.zzsn.event.util.*;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.util.user.UserVo; import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.*; import com.zzsn.event.vo.*;
...@@ -172,7 +173,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -172,7 +173,7 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
subjectCondition.setTypeIds(typeIds); subjectCondition.setTypeIds(typeIds);
Page<SubjectPageVO> page = new Page<>(pageNo, pageSize); Page<SubjectPageVO> page = new Page<>(pageNo, pageSize);
Page<SubjectPageVO> pageList = baseMapper.pageList_new(subjectCondition, page); Page<SubjectPageVO> pageList = baseMapper.pageList_new(page,subjectCondition, AuthUtil.getAuthUserId());
List<SubjectPageVO> records = pageList.getRecords(); List<SubjectPageVO> records = pageList.getRecords();
if (CollUtil.isNotEmpty(records)) { if (CollUtil.isNotEmpty(records)) {
List<String> idList = records.stream().map(SubjectPageVO::getId).collect(Collectors.toList()); List<String> idList = records.stream().map(SubjectPageVO::getId).collect(Collectors.toList());
......
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SubjectTypeMap; import com.zzsn.event.entity.SubjectTypeMap;
import com.zzsn.event.mapper.SubjectTypeMapMapper; import com.zzsn.event.mapper.SubjectTypeMapMapper;
import com.zzsn.event.service.ISubjectTypeMapService; import com.zzsn.event.service.ISubjectTypeMapService;
import com.zzsn.event.util.user.AuthUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -24,11 +25,11 @@ public class SubjectTypeMapServiceImpl extends ServiceImpl<SubjectTypeMapMapper, ...@@ -24,11 +25,11 @@ public class SubjectTypeMapServiceImpl extends ServiceImpl<SubjectTypeMapMapper,
@Override @Override
public List<String> selectSubjectByTypeIds(List<String> typeIds) { public List<String> selectSubjectByTypeIds(List<String> typeIds) {
return baseMapper.selectSubjectByTypeIds(typeIds); return baseMapper.selectSubjectByTypeIds(typeIds, AuthUtil.getAuthUserId());
} }
@Override @Override
public List<String> selectEventByTypeIds(List<String> typeIds) { public List<String> selectEventByTypeIds(List<String> typeIds) {
return baseMapper.selectEventByTypeIds(typeIds); return baseMapper.selectEventByTypeIds(typeIds, AuthUtil.getAuthUserId());
} }
} }
...@@ -12,6 +12,7 @@ import com.zzsn.event.service.ISubjectTypeService; ...@@ -12,6 +12,7 @@ import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.util.TokenUtil; import com.zzsn.event.util.TokenUtil;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.tree.TreeUtil; import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
import com.zzsn.event.vo.SubjectPage; import com.zzsn.event.vo.SubjectPage;
import com.zzsn.event.vo.SubjectTreeVO; import com.zzsn.event.vo.SubjectTreeVO;
...@@ -41,12 +42,12 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -41,12 +42,12 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
@Override @Override
public List<Node> enableList(Integer category) { public List<Node> enableList(Integer category) {
return baseMapper.enableList(category,null); return baseMapper.enableList(category,null,AuthUtil.getAuthUserId());
} }
@Override @Override
public List<Node> researchCenterEnableList(String username) { public List<Node> researchCenterEnableList(String username) {
return baseMapper.enableList(1, username); return baseMapper.enableList(1, username,AuthUtil.getAuthUserId());
} }
@Autowired @Autowired
private ParamAop paramAop; private ParamAop paramAop;
...@@ -161,19 +162,18 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -161,19 +162,18 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
@Override @Override
public List<String> researchCenterBelowIdList(String typeId, Integer category) { public List<String> researchCenterBelowIdList(String typeId, Integer category) {
String username = UserUtil.getLoginUser().getUsername(); String username = UserUtil.getLoginUser().getUsername();
List<Node> nodes = baseMapper.enableList(category,username); List<Node> nodes = baseMapper.enableList(category,username,AuthUtil.getAuthUserId());
return TreeUtil.belowList(nodes, typeId, true); return TreeUtil.belowList(nodes, typeId, true);
} }
@Override @Override
public List<SubjectTypeTreeVO> typeAndBindCountTreeList(Integer category) { public List<SubjectTypeTreeVO> typeAndBindCountTreeList(Integer category) {
String userId = AuthUtil.getAuthUserId();
List<SubjectTypeTreeVO> resultList = new ArrayList<>(); List<SubjectTypeTreeVO> resultList = new ArrayList<>();
LambdaQueryWrapper<SubjectType> queryWrapper = Wrappers.lambdaQuery(); List<SubjectType> allList = baseMapper.allList(category,userId);
queryWrapper.eq(SubjectType::getCategory, category).orderByAsc(SubjectType::getCreateTime);
List<SubjectType> allList = list(queryWrapper);
if (CollectionUtils.isNotEmpty(allList)) { if (CollectionUtils.isNotEmpty(allList)) {
//绑定有专题/事件的分类 //绑定有专题/事件的分类
List<SubjectTypeTreeVO> subjectTypeTreeVOS = baseMapper.typeBindCountTreeList(category); List<SubjectTypeTreeVO> subjectTypeTreeVOS = baseMapper.typeBindCountTreeList(category,userId);
if (CollectionUtils.isNotEmpty(subjectTypeTreeVOS)) { if (CollectionUtils.isNotEmpty(subjectTypeTreeVOS)) {
List<String> collect = subjectTypeTreeVOS.stream().map(SubjectTypeTreeVO::getId).collect(Collectors.toList()); List<String> collect = subjectTypeTreeVOS.stream().map(SubjectTypeTreeVO::getId).collect(Collectors.toList());
//补充未绑定专题的分类 //补充未绑定专题的分类
...@@ -191,9 +191,9 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -191,9 +191,9 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
//获取专题数据 //获取专题数据
List<SubjectTypeTreeVO> dataList = new ArrayList<>(); List<SubjectTypeTreeVO> dataList = new ArrayList<>();
if (category == 1) { if (category == 1) {
dataList = baseMapper.typeBindSubjectList(); dataList = baseMapper.typeBindSubjectList(userId);
} else if (category == 2) { } else if (category == 2) {
dataList = baseMapper.typeBindEventList(); dataList = baseMapper.typeBindEventList(userId);
} }
subjectTypeTreeVOS.addAll(dataList); subjectTypeTreeVOS.addAll(dataList);
//构造树型结构 //构造树型结构
......
...@@ -45,4 +45,16 @@ public class AuthUtil { ...@@ -45,4 +45,16 @@ public class AuthUtil {
} }
/**
* 获取需要鉴权的用户id,超级管理员不做权限控制,返回null
* @return
*/
public static String getAuthUserId() {
UserVo loginUser = getLoginUser();
if(loginUser.getCategory()!=null && loginUser.getCategory()!=1){
//非超级管理员,需要根据用户确定权限
return loginUser.getUserId();
}
return null;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论