feat: 仪表盘分享页面完善

This commit is contained in:
fit2cloud-chenyw
2021-03-18 16:55:31 +08:00
parent 3f5d2bee53
commit 9e9fb73892
14 changed files with 354 additions and 97 deletions

View File

@@ -9,7 +9,7 @@ public class PanelShare implements Serializable {
private String panelGroupId;
private Long userId;
private Long targetId;
private Long createTime;

View File

@@ -234,63 +234,63 @@ public class PanelShareExample {
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
public Criteria andTargetIdIsNull() {
addCriterion("target_id is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
public Criteria andTargetIdIsNotNull() {
addCriterion("target_id is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(Long value) {
addCriterion("user_id =", value, "userId");
public Criteria andTargetIdEqualTo(Long value) {
addCriterion("target_id =", value, "targetId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(Long value) {
addCriterion("user_id <>", value, "userId");
public Criteria andTargetIdNotEqualTo(Long value) {
addCriterion("target_id <>", value, "targetId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(Long value) {
addCriterion("user_id >", value, "userId");
public Criteria andTargetIdGreaterThan(Long value) {
addCriterion("target_id >", value, "targetId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("user_id >=", value, "userId");
public Criteria andTargetIdGreaterThanOrEqualTo(Long value) {
addCriterion("target_id >=", value, "targetId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(Long value) {
addCriterion("user_id <", value, "userId");
public Criteria andTargetIdLessThan(Long value) {
addCriterion("target_id <", value, "targetId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(Long value) {
addCriterion("user_id <=", value, "userId");
public Criteria andTargetIdLessThanOrEqualTo(Long value) {
addCriterion("target_id <=", value, "targetId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<Long> values) {
addCriterion("user_id in", values, "userId");
public Criteria andTargetIdIn(List<Long> values) {
addCriterion("target_id in", values, "targetId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<Long> values) {
addCriterion("user_id not in", values, "userId");
public Criteria andTargetIdNotIn(List<Long> values) {
addCriterion("target_id not in", values, "targetId");
return (Criteria) this;
}
public Criteria andUserIdBetween(Long value1, Long value2) {
addCriterion("user_id between", value1, value2, "userId");
public Criteria andTargetIdBetween(Long value1, Long value2) {
addCriterion("target_id between", value1, value2, "targetId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(Long value1, Long value2) {
addCriterion("user_id not between", value1, value2, "userId");
public Criteria andTargetIdNotBetween(Long value1, Long value2) {
addCriterion("target_id not between", value1, value2, "targetId");
return (Criteria) this;
}

View File

@@ -4,7 +4,7 @@
<resultMap id="BaseResultMap" type="io.dataease.base.domain.PanelShare">
<id column="share_id" jdbcType="BIGINT" property="shareId" />
<result column="panel_group_id" jdbcType="VARCHAR" property="panelGroupId" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="target_id" jdbcType="BIGINT" property="targetId" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="type" jdbcType="INTEGER" property="type" />
</resultMap>
@@ -67,7 +67,7 @@
</where>
</sql>
<sql id="Base_Column_List">
share_id, panel_group_id, user_id, create_time, `type`
share_id, panel_group_id, target_id, create_time, `type`
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.PanelShareExample" resultMap="BaseResultMap">
select
@@ -100,9 +100,9 @@
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.PanelShare">
insert into panel_share (share_id, panel_group_id, user_id,
insert into panel_share (share_id, panel_group_id, target_id,
create_time, `type`)
values (#{shareId,jdbcType=BIGINT}, #{panelGroupId,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT},
values (#{shareId,jdbcType=BIGINT}, #{panelGroupId,jdbcType=VARCHAR}, #{targetId,jdbcType=BIGINT},
#{createTime,jdbcType=BIGINT}, #{type,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.PanelShare">
@@ -114,8 +114,8 @@
<if test="panelGroupId != null">
panel_group_id,
</if>
<if test="userId != null">
user_id,
<if test="targetId != null">
target_id,
</if>
<if test="createTime != null">
create_time,
@@ -131,8 +131,8 @@
<if test="panelGroupId != null">
#{panelGroupId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=BIGINT},
<if test="targetId != null">
#{targetId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
@@ -157,8 +157,8 @@
<if test="record.panelGroupId != null">
panel_group_id = #{record.panelGroupId,jdbcType=VARCHAR},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
<if test="record.targetId != null">
target_id = #{record.targetId,jdbcType=BIGINT},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
@@ -175,7 +175,7 @@
update panel_share
set share_id = #{record.shareId,jdbcType=BIGINT},
panel_group_id = #{record.panelGroupId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=BIGINT},
target_id = #{record.targetId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT},
`type` = #{record.type,jdbcType=INTEGER}
<if test="_parameter != null">
@@ -188,8 +188,8 @@
<if test="panelGroupId != null">
panel_group_id = #{panelGroupId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
<if test="targetId != null">
target_id = #{targetId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
@@ -203,7 +203,7 @@
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.PanelShare">
update panel_share
set panel_group_id = #{panelGroupId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=BIGINT},
target_id = #{targetId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT},
`type` = #{type,jdbcType=INTEGER}
where share_id = #{shareId,jdbcType=BIGINT}

View File

@@ -3,12 +3,13 @@ package io.dataease.base.mapper.ext;
import io.dataease.base.domain.PanelShare;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.dto.panel.PanelShareDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtPanelShareMapper {
int batchInsert(List<PanelShare> shares);
int batchInsert(@Param("shares") List<PanelShare> shares);
List<PanelShareDto> query(GridExample example);

View File

@@ -6,13 +6,14 @@
<id column="id" property="id" />
<result column="name" property="name" />
<result column="pid" property="pid" />
<result column="creator" property="create_by" />
</resultMap>
<insert id="batchInsert" parameterType="io.dataease.base.domain.PanelStore">
INSERT INTO panel_store (panel_group_id,user_id,create_time)
<insert id="batchInsert" parameterType="io.dataease.base.domain.PanelShare">
INSERT INTO panel_share (panel_group_id,target_id,create_time,type)
VALUES
<foreach collection="list" item="store" separator=",">
(#{store.panelGroupId}, #{store.userId}, #{store.createTime})
<foreach collection="shares" item="share" separator=",">
(#{share.panelGroupId}, #{share.targetId}, #{share.createTime}, #{share.type})
</foreach>
</insert>
@@ -33,7 +34,7 @@
</select>
<select id="queryWithResource" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="io.dataease.base.mapper.PanelShareMapper.BaseResultMap">
select from panel_share
select * from panel_share
<if test="_parameter != null">
<include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
</if>

View File

@@ -8,9 +8,10 @@ import java.util.List;
@Data
public class PanelShareRequest implements Serializable {
@ApiModelProperty("分享目标用户集合")
private List<Long> userIds;
@ApiModelProperty(value = "分享目标类型", allowableValues = "0:user,1:role,2:dept")
private Integer type;
@ApiModelProperty("分享目标集合")
private List<Long> targetIds;
@ApiModelProperty("分享仪表板集合")
private List<String> panelIds;
}

View File

@@ -2,6 +2,7 @@ package io.dataease.service.panel;
import io.dataease.base.domain.PanelShare;
import io.dataease.base.domain.PanelShareExample;
import io.dataease.base.domain.SysUser;
import io.dataease.base.mapper.PanelShareMapper;
import io.dataease.base.mapper.ext.ExtPanelShareMapper;
import io.dataease.base.mapper.ext.query.GridExample;
@@ -36,21 +37,26 @@ public class ShareService {
public void save(PanelShareRequest request){
//1.先根据仪表板删除所有已经分享的
Integer type = request.getType();
List<String> panelIds = request.getPanelIds();
List<Long> userIds = request.getUserIds();
List<Long> targetIds = request.getTargetIds();
// 使用原生对象会导致事物失效 所以这里需要使用spring代理对象
if (CollectionUtils.isNotEmpty(panelIds)){
ShareService proxy = CommonBeanFactory.getBean(ShareService.class);
panelIds.forEach(proxy::delete);
panelIds.forEach(panelId -> {
proxy.delete(panelId, type);
});
}
if (CollectionUtils.isEmpty(userIds)) return;
if (CollectionUtils.isEmpty(targetIds)) return;
long now = System.currentTimeMillis();
List<PanelShare> shares = panelIds.stream().flatMap(panelId ->
userIds.stream().map(userId -> {
targetIds.stream().map(targetId -> {
PanelShare share = new PanelShare();
share.setCreateTime(now);
share.setPanelGroupId(panelId);
share.setUserId(userId);
share.setTargetId(targetId);
share.setType(type);
return share;
})
).collect(Collectors.toList());
@@ -64,20 +70,31 @@ public class ShareService {
* @param panel_group_id
*/
@Transactional
public void delete(String panel_group_id){
public void delete(String panel_group_id, Integer type){
PanelShareExample example = new PanelShareExample();
example.createCriteria().andPanelGroupIdEqualTo(panel_group_id);
example.createCriteria().andPanelGroupIdEqualTo(panel_group_id).andTypeEqualTo(type);
mapper.deleteByExample(example);
}
public List<PanelShareDto> queryTree(BaseGridRequest request){
Long userId = AuthUtils.getUser().getUserId();
SysUser user = AuthUtils.getUser();
Long userId = user.getUserId();
Long deptId = user.getDeptId();
List<Long> roleIds = new ArrayList<>();
List<Long> targetIds = new ArrayList<>();
targetIds.add(userId);
targetIds.add(deptId);
targetIds.addAll(roleIds);
ConditionEntity condition = new ConditionEntity();
condition.setField("s.user_id");
condition.setOperator("eq");
condition.setValue(userId);
condition.setField("s.target_id");
condition.setOperator("in");
condition.setValue(targetIds);
request.setConditions(new ArrayList<ConditionEntity>(){{add(condition);}});
GridExample example = request.convertExample();
List<PanelShareDto> datas = extPanelShareMapper.query(example);
return convertTree(datas);
@@ -86,7 +103,6 @@ public class ShareService {
//List构建Tree
private List<PanelShareDto> convertTree(List<PanelShareDto> datas){
Map<String, List<PanelShareDto>> map = datas.stream().collect(Collectors.groupingBy(PanelShareDto::getCreator));
List<PanelShareDto> roots = new ArrayList<>();
return map.entrySet().stream().map(entry -> PanelShareDto.builder().name(entry.getKey()).children(entry.getValue()).build()).collect(Collectors.toList());
}

View File

@@ -14,6 +14,7 @@ import io.dataease.controller.sys.request.DeptDeleteRequest;
import io.dataease.controller.sys.request.DeptStatusRequest;
import io.dataease.controller.sys.request.SimpleTreeNode;
import io.dataease.controller.sys.response.DeptTreeNode;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -134,8 +135,10 @@ public class DeptService {
List<SimpleTreeNode> targetNodes = nodeByCondition(request);
List<Long> ids = upTree(allNodes, targetNodes);
SysDeptExample example = new SysDeptExample();
SysDeptExample.Criteria criteria = example.createCriteria();
criteria.andDeptIdIn(ids);
if (CollectionUtils.isNotEmpty(ids)){
SysDeptExample.Criteria criteria = example.createCriteria();
criteria.andDeptIdIn(ids);
}
example.setOrderByClause("dept_sort");
List<SysDept> sysDepts = sysDeptMapper.selectByExample(example);
return sysDepts;