Merge branch 'main' of https://github.com/dataease/dataease into main

This commit is contained in:
TaoJinlong
2021-03-18 18:00:23 +08:00
44 changed files with 1476 additions and 140 deletions

View File

@@ -9,9 +9,11 @@ public class PanelShare implements Serializable {
private String panelGroupId;
private Long userId;
private Long targetId;
private Long createTime;
private Integer type;
private static final long serialVersionUID = 1L;
}

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;
}
@@ -353,6 +353,66 @@ public class PanelShareExample {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@@ -4,8 +4,9 @@
<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>
<sql id="Example_Where_Clause">
<where>
@@ -66,7 +67,7 @@
</where>
</sql>
<sql id="Base_Column_List">
share_id, panel_group_id, user_id, create_time
share_id, panel_group_id, target_id, create_time, `type`
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.PanelShareExample" resultMap="BaseResultMap">
select
@@ -99,10 +100,10 @@
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.PanelShare">
insert into panel_share (share_id, panel_group_id, user_id,
create_time)
values (#{shareId,jdbcType=BIGINT}, #{panelGroupId,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT},
#{createTime,jdbcType=BIGINT})
insert into panel_share (share_id, panel_group_id, target_id,
create_time, `type`)
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">
insert into panel_share
@@ -113,12 +114,15 @@
<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,
</if>
<if test="type != null">
`type`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="shareId != null">
@@ -127,12 +131,15 @@
<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},
</if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.PanelShareExample" resultType="java.lang.Long">
@@ -150,12 +157,15 @@
<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},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@@ -165,8 +175,9 @@
update panel_share
set share_id = #{record.shareId,jdbcType=BIGINT},
panel_group_id = #{record.panelGroupId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT}
target_id = #{record.targetId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=BIGINT},
`type` = #{record.type,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@@ -177,20 +188,24 @@
<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},
</if>
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
</if>
</set>
where share_id = #{shareId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.PanelShare">
update panel_share
set panel_group_id = #{panelGroupId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT}
target_id = #{targetId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=BIGINT},
`type` = #{type,jdbcType=INTEGER}
where share_id = #{shareId,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -3,12 +3,15 @@ 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);
List<PanelShare> queryWithResource(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>
@@ -32,6 +33,18 @@
</select>
<select id="queryWithResource" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="io.dataease.base.mapper.PanelShareMapper.BaseResultMap">
select * from panel_share
<if test="_parameter != null">
<include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>

View File

@@ -1,5 +1,6 @@
package io.dataease.controller.panel.api;
import io.dataease.base.domain.PanelShare;
import io.dataease.controller.request.panel.PanelShareRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelShareDto;
@@ -25,5 +26,10 @@ public interface ShareApi {
@PostMapping("/treeList")
List<PanelShareDto> treeList(BaseGridRequest request);
@ApiOperation("根据资源查询分享")
@PostMapping("/queryWithResourceId")
List<PanelShare> queryWithResourceId(BaseGridRequest request);
}

View File

@@ -1,15 +1,19 @@
package io.dataease.controller.panel.server;
import io.dataease.base.domain.PanelShare;
import io.dataease.controller.panel.api.ShareApi;
import io.dataease.controller.request.panel.PanelShareRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelShareDto;
import io.dataease.service.panel.ShareService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
public class ShareServer implements ShareApi {
@Resource
@@ -23,4 +27,10 @@ public class ShareServer implements ShareApi {
public List<PanelShareDto> treeList(@RequestBody BaseGridRequest request) {
return shareService.queryTree(request);
}
@Override
public List<PanelShare> queryWithResourceId(@RequestBody BaseGridRequest request) {
return shareService.queryWithResource(request);
}
}

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,9 +103,13 @@ 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());
}
public List<PanelShare> queryWithResource(BaseGridRequest request){
GridExample example = request.convertExample();
return extPanelShareMapper.queryWithResource(example);
}
}

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;

View File

@@ -58,6 +58,8 @@ spring.cache.ehcache.config=classpath:/ehcache/ehcache.xml
logging.level.org.springframework.web=trace
logging.level.org.springframework.boot.web=trace
spring.mvc.log-request-details=true
pagehelper.PageRowBounds=true

View File

@@ -67,7 +67,7 @@ CREATE TABLE `panel_store` (
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
`create_time` bigint(13) DEFAULT NULL COMMENT '创建日期',
PRIMARY KEY (`store_id`) USING BTREE,
UNIQUE KEY `UK_store_user_id` (`user_id`) USING BTREE
KEY `UK_store_user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='仪表板收藏';
@@ -86,11 +86,14 @@ DROP TABLE IF EXISTS `panel_share`;
CREATE TABLE `panel_share` (
`share_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分享ID',
`panel_group_id` varchar(50) DEFAULT NULL COMMENT '仪表板ID',
`user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
`target_id` bigint(20) DEFAULT NULL COMMENT '目标ID',
`create_time` bigint(13) DEFAULT NULL COMMENT '创建日期',
`type` int(8) DEFAULT NULL COMMENT '类型0:user,1:role,2dept',
PRIMARY KEY (`share_id`) USING BTREE,
UNIQUE KEY `UK_share_user_id` (`user_id`) USING BTREE,
UNIQUE KEY `UK_share_panel_group_id` (`panel_group_id`) USING BTREE
KEY `UK_share_arget_id` (`target_id`) ,
KEY `UK_share_panel_group_id` (`panel_group_id`) ,
KEY `UK_share_type` (`type`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='仪表板分享';