提交 7185f815 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

fix: 仪表板分享过滤当前用户

上级 4108e689
......@@ -7,12 +7,13 @@ import io.dataease.dto.panel.PanelSharePo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface ExtPanelShareMapper {
int batchInsert(@Param("shares") List<PanelShare> shares);
List<PanelSharePo> query(GridExample example);
List<PanelSharePo> query(Map<String, Object> param);
List<PanelShare> queryWithResource(GridExample example);
}
......@@ -16,16 +16,17 @@
</foreach>
</insert>
<select id="query" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="treeNodeMap">
<select id="query" resultMap="treeNodeMap">
select distinct s.panel_group_id as id, g.create_by as creator, g.name
from panel_share s
left join panel_group g on g.id = s.panel_group_id
<if test="_parameter != null">
<include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
where
( s.target_id = #{userId} and s.type = 0 ) or
( s.target_id = #{deptId} and s.type = 1 ) or
s.target_id in
<foreach collection="roleIds" item="roleId" open='(' separator=',' close=')'>
#{roleId}
</foreach>
<if test="orderByClause == null">
order by s.create_time desc
</if>
......
......@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -92,7 +93,14 @@ public class ShareService {
Long deptId = user.getDeptId();
List<Long> roleIds = user.getRoles().stream().map(CurrentRoleDto::getId).collect(Collectors.toList());
List<Long> targetIds = new ArrayList<>();
Map<String, Object> param = new HashMap<>();
param.put("userId", userId);
param.put("deptId", deptId);
param.put("roleIds", roleIds);
List<PanelSharePo> datas = extPanelShareMapper.query(param);
/*List<Long> targetIds = new ArrayList<>();
targetIds.add(userId);
targetIds.add(deptId);
targetIds.addAll(roleIds);
......@@ -105,14 +113,15 @@ public class ShareService {
request.setConditions(new ArrayList<ConditionEntity>(){{add(condition);}});
GridExample example = request.convertExample();
List<PanelSharePo> datas = extPanelShareMapper.query(example);
List<PanelSharePo> datas = extPanelShareMapper.query(example);*/
List<PanelShareDto> dtoLists = datas.stream().map(po -> BeanUtils.copyBean(new PanelShareDto(), po)).collect(Collectors.toList());
return convertTree(dtoLists);
}
//List构建Tree
private List<PanelShareDto> convertTree(List<PanelShareDto> datas){
Map<String, List<PanelShareDto>> map = datas.stream().filter(panelShareDto -> StringUtils.isNotEmpty(panelShareDto.getCreator())).collect(Collectors.groupingBy(PanelShareDto::getCreator));
String username = AuthUtils.getUser().getUsername();
Map<String, List<PanelShareDto>> map = datas.stream().filter(panelShareDto -> StringUtils.isNotEmpty(panelShareDto.getCreator()) && !StringUtils.equals(username, panelShareDto.getCreator())).collect(Collectors.groupingBy(PanelShareDto::getCreator));
return map.entrySet().stream().map(entry -> {
PanelShareDto panelShareDto = new PanelShareDto();
panelShareDto.setName(entry.getKey());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论