feat: 新增我分享的

This commit is contained in:
fit2cloud-chenyw 2021-11-09 18:23:45 +08:00
parent 3f7d1be0f8
commit db55c0782a
10 changed files with 121 additions and 36 deletions

View File

@ -10,12 +10,14 @@ import java.util.Map;
public interface ExtPanelShareMapper { public interface ExtPanelShareMapper {
int batchInsert(@Param("shares") List<PanelShare> shares); int batchInsert(@Param("shares") List<PanelShare> shares, @Param("userName") String userName);
int batchDelete(@Param("shareIds") List<Long> shareIds); int batchDelete(@Param("shareIds") List<Long> shareIds);
List<PanelSharePo> query(Map<String, Object> param); List<PanelSharePo> query(Map<String, Object> param);
List<PanelSharePo> queryOut(String userName);
List<PanelShare> queryWithResource(GridExample example); List<PanelShare> queryWithResource(GridExample example);
List<Long> queryUserIdWithRoleIds(Map<String, List<Long>> param); List<Long> queryUserIdWithRoleIds(Map<String, List<Long>> param);

View File

@ -9,10 +9,10 @@
</resultMap> </resultMap>
<insert id="batchInsert" parameterType="io.dataease.base.domain.PanelShare"> <insert id="batchInsert" parameterType="io.dataease.base.domain.PanelShare">
INSERT INTO panel_share (panel_group_id,target_id,create_time,type) INSERT INTO panel_share (panel_group_id,target_id,granter,create_time,type)
VALUES VALUES
<foreach collection="shares" item="share" separator=","> <foreach collection="shares" item="share" separator=",">
(#{share.panelGroupId}, #{share.targetId}, #{share.createTime}, #{share.type}) (#{share.panelGroupId}, #{share.targetId}, #{userName}, #{share.createTime}, #{share.type})
</foreach> </foreach>
</insert> </insert>
@ -25,7 +25,7 @@
</delete> </delete>
<select id="query" resultMap="treeNodeMap"> <select id="query" resultMap="treeNodeMap">
select distinct s.panel_group_id as id, g.create_by as creator, g.name select distinct s.panel_group_id as id, IFNULL(s.granter,g.create_by) as creator, g.name
from panel_share s from panel_share s
left join panel_group g on g.id = s.panel_group_id left join panel_group g on g.id = s.panel_group_id
where where
@ -42,6 +42,15 @@
</select> </select>
<select id="queryOut" resultMap="treeNodeMap">
select distinct s.panel_group_id as id, g.name
from panel_share s
left join panel_group g on g.id = s.panel_group_id
where ( s.granter is not null and s.granter = #{userName} ) or ( s.granter is null and g.create_by = #{userName} )
order by s.create_time desc
</select>
<select id="queryWithResource" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="io.dataease.base.mapper.PanelShareMapper.BaseResultMap"> <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"> <if test="_parameter != null">

View File

@ -6,6 +6,7 @@ import io.dataease.controller.request.panel.PanelShareFineDto;
import io.dataease.controller.request.panel.PanelShareRequest; import io.dataease.controller.request.panel.PanelShareRequest;
import io.dataease.controller.sys.base.BaseGridRequest; import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelShareDto; import io.dataease.dto.panel.PanelShareDto;
import io.dataease.dto.panel.PanelSharePo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -22,14 +23,19 @@ import java.util.List;
@RequestMapping("/api/share") @RequestMapping("/api/share")
public interface ShareApi { public interface ShareApi {
@ApiIgnore /*@ApiIgnore
@PostMapping("/") @PostMapping("/")
void share(PanelShareRequest request); void share(PanelShareRequest request);*/
@ApiOperation("查询分享") @ApiOperation("查询分享给我")
@PostMapping("/treeList") @PostMapping("/treeList")
List<PanelShareDto> treeList(BaseGridRequest request); List<PanelShareDto> treeList(BaseGridRequest request);
@ApiOperation("查询我分享的")
@PostMapping("/shareOut")
List<PanelSharePo> shareOut();
@ApiOperation("根据资源查询分享") @ApiOperation("根据资源查询分享")
@PostMapping("/queryWithResourceId") @PostMapping("/queryWithResourceId")

View File

@ -6,6 +6,7 @@ import io.dataease.controller.request.panel.PanelShareFineDto;
import io.dataease.controller.request.panel.PanelShareRequest; import io.dataease.controller.request.panel.PanelShareRequest;
import io.dataease.controller.sys.base.BaseGridRequest; import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.dto.panel.PanelShareDto; import io.dataease.dto.panel.PanelShareDto;
import io.dataease.dto.panel.PanelSharePo;
import io.dataease.service.panel.ShareService; import io.dataease.service.panel.ShareService;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -18,16 +19,20 @@ public class ShareServer implements ShareApi {
@Resource @Resource
private ShareService shareService; private ShareService shareService;
@Override /*@Override
public void share(@RequestBody PanelShareRequest request) { public void share(@RequestBody PanelShareRequest request) {
shareService.save(request); shareService.save(request);
} }*/
@Override @Override
public List<PanelShareDto> treeList(@RequestBody BaseGridRequest request) { public List<PanelShareDto> treeList(@RequestBody BaseGridRequest request) {
return shareService.queryTree(request); return shareService.queryTree(request);
} }
@Override
public List<PanelSharePo> shareOut() {
return shareService.queryShareOut();
}
@Override @Override
public List<PanelShare> queryWithResourceId(@RequestBody BaseGridRequest request) { public List<PanelShare> queryWithResourceId(@RequestBody BaseGridRequest request) {

View File

@ -115,7 +115,7 @@ public class ShareService {
} }
if (CollectionUtils.isNotEmpty(addShares)){ if (CollectionUtils.isNotEmpty(addShares)){
extPanelShareMapper.batchInsert(addShares); extPanelShareMapper.batchInsert(addShares, AuthUtils.getUser().getUsername());
} }
// 以上是业务代码 // 以上是业务代码
@ -241,7 +241,7 @@ public class ShareService {
}) })
).collect(Collectors.toList()); ).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(shares)){ if (CollectionUtils.isNotEmpty(shares)){
extPanelShareMapper.batchInsert(shares); extPanelShareMapper.batchInsert(shares, AuthUtils.getUser().getUsername());
} }
// 下面是发送提醒消息逻辑 // 下面是发送提醒消息逻辑
@ -287,6 +287,15 @@ public class ShareService {
mapper.deleteByExample(example); mapper.deleteByExample(example);
} }
public List<PanelSharePo> shareOut() {
return null;
}
public List<PanelSharePo> queryShareOut() {
String username = AuthUtils.getUser().getUsername();
List<PanelSharePo> panelSharePos = extPanelShareMapper.queryOut(username);
return panelSharePos;
}
public List<PanelShareDto> queryTree(BaseGridRequest request){ public List<PanelShareDto> queryTree(BaseGridRequest request){
CurrentUserDto user = AuthUtils.getUser(); CurrentUserDto user = AuthUtils.getUser();

View File

@ -0,0 +1,5 @@
-- ----------------------------
-- 新增我分享出去的功能
-- ----------------------------
ALTER TABLE `dataease`.`panel_share`
ADD COLUMN `granter` varchar(255) NULL COMMENT '分享人' AFTER `target_id`;

View File

@ -1,13 +1,13 @@
import request from '@/utils/request' import request from '@/utils/request'
export function saveShare(data) { /* export function saveShare(data) {
return request({ return request({
url: '/api/share/', url: '/api/share/',
method: 'post', method: 'post',
loading: true, loading: true,
data data
}) })
} } */
export function loadShares(data) { export function loadShares(data) {
return request({ return request({
@ -27,6 +27,14 @@ export function loadTree(data) {
}) })
} }
export function loadShareOutTree() {
return request({
url: '/api/share/shareOut',
method: 'post',
loading: true
})
}
export function fineSave(data) { export function fineSave(data) {
return request({ return request({
url: '/api/share/fineSave', url: '/api/share/fineSave',

View File

@ -17,7 +17,8 @@
<script> <script>
import { roleGrid } from '@/api/system/user' import { roleGrid } from '@/api/system/user'
import { formatCondition } from '@/utils/index' import { formatCondition } from '@/utils/index'
import { saveShare, loadShares } from '@/api/panel/share' import { loadShares } from '@/api/panel/share'
/* import { saveShare, loadShares } from '@/api/panel/share' */
export default { export default {
name: 'GrantRole', name: 'GrantRole',
props: { props: {
@ -85,7 +86,7 @@ export default {
} }
}, },
save(msg) { /* save(msg) {
const rows = this.$refs.table.store.states.selection const rows = this.$refs.table.store.states.selection
const request = this.buildRequest(rows) const request = this.buildRequest(rows)
saveShare(request).then(res => { saveShare(request).then(res => {
@ -95,7 +96,7 @@ export default {
this.$error(err.message) this.$error(err.message)
return false return false
}) })
}, }, */
cancel() { cancel() {
}, },

View File

@ -1,24 +1,47 @@
<template> <template>
<div> <el-col style="padding: 0 5px 0 5px;">
<el-row>
<el-tree :data="datas" :props="defaultProps" node-key="name" :default-expanded-keys="expandNodes" @node-click="handleNodeClick"> <span class="header-title">分享给我</span>
<span slot-scope="{ data }" class="custom-tree-node"> <div class="block" style="margin-top:8px;">
<span :class="!!data.msgNode ? 'msg-node-class': ''"> <el-tree :data="datas" :props="defaultProps" node-key="name" :default-expanded-keys="expandNodes" @node-click="handleNodeClick">
<span v-if="!!data.id"> <span slot-scope="{ data }" class="custom-tree-node">
<el-button <span :class="!!data.msgNode ? 'msg-node-class': ''">
icon="el-icon-picture-outline" <span v-if="!!data.id">
type="text" <el-button
/> icon="el-icon-picture-outline"
type="text"
/>
</span>
<span style="margin-left: 6px">{{ data.name }}</span>
</span>
</span> </span>
<span style="margin-left: 6px">{{ data.name }}</span> </el-tree>
</span> </div>
</span> </el-row>
</el-tree>
</div> <el-row>
<span class="header-title">我分享的</span>
<div class="block" style="margin-top:8px;">
<el-tree :data="outDatas" :props="defaultProps" node-key="name" :default-expand-all="true" @node-click="handleNodeClick">
<span slot-scope="{ data }" class="custom-tree-node">
<span>
<span v-if="!!data.id">
<el-button
icon="el-icon-picture-outline"
type="text"
/>
</span>
<span style="margin-left: 6px">{{ data.name }}</span>
</span>
</span>
</el-tree>
</div>
</el-row>
</el-col>
</template> </template>
<script> <script>
import { loadTree } from '@/api/panel/share' import { loadTree, loadShareOutTree } from '@/api/panel/share'
import { uuid } from 'vue-uuid' import { uuid } from 'vue-uuid'
import { get } from '@/api/panel/panel' import { get } from '@/api/panel/panel'
import bus from '@/utils/bus' import bus from '@/utils/bus'
@ -37,7 +60,8 @@ export default {
children: 'children', children: 'children',
label: 'name' label: 'name'
}, },
expandNodes: [] expandNodes: [],
outDatas: []
} }
}, },
created() { created() {
@ -47,6 +71,9 @@ export default {
this.expandMsgNode(this.msgPanelIds) this.expandMsgNode(this.msgPanelIds)
} }
}) })
this.initOutData().then(res => {
this.outDatas = res.data
})
}, },
methods: { methods: {
@ -54,6 +81,9 @@ export default {
const param = {} const param = {}
return loadTree(param) return loadTree(param)
}, },
initOutData() {
return loadShareOutTree()
},
handleNodeClick(data) { handleNodeClick(data) {
get('panel/group/findOne/' + data.id).then(response => { get('panel/group/findOne/' + data.id).then(response => {
this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData))) this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
@ -96,6 +126,15 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.header-title {
font-size: 14px;
flex: 1;
color: var(--TextPrimary, #606266);
font-weight: bold;
display: block;
height: 100%;
/*line-height: 36px;*/
}
.msg-node-class { .msg-node-class {
color: red; color: red;
>>> i{ >>> i{

View File

@ -25,7 +25,8 @@
<script> <script>
import { userLists } from '@/api/system/user' import { userLists } from '@/api/system/user'
import { formatCondition } from '@/utils/index' import { formatCondition } from '@/utils/index'
import { saveShare, loadShares } from '@/api/panel/share' import { loadShares } from '@/api/panel/share'
/* import { saveShare, loadShares } from '@/api/panel/share' */
export default { export default {
name: 'GrantUser', name: 'GrantUser',
props: { props: {
@ -92,7 +93,7 @@ export default {
} }
}, },
save(msg) { /* save(msg) {
const rows = this.$refs.table.store.states.selection const rows = this.$refs.table.store.states.selection
const request = this.buildRequest(rows) const request = this.buildRequest(rows)
saveShare(request).then(response => { saveShare(request).then(response => {
@ -102,7 +103,7 @@ export default {
this.$error(err.message) this.$error(err.message)
return false return false
}) })
}, }, */
cancel() { cancel() {
console.log('user cancel') console.log('user cancel')