mirror of
https://github.com/dataease/dataease.git
synced 2025-02-25 12:03:05 +08:00
fix(仪表板): 删除分享仪表板报错
This commit is contained in:
parent
68a3b7630d
commit
f69332267f
@ -54,4 +54,8 @@ public interface ShareApi {
|
||||
@PostMapping("/removeShares")
|
||||
void removeShares(PanelShareRemoveRequest request);
|
||||
|
||||
@ApiOperation("删除仪表板所有分享")
|
||||
@PostMapping("/removePanelShares/{panelId}")
|
||||
void removePanelShares(@PathVariable("panelId") String panelId);
|
||||
|
||||
}
|
||||
|
@ -52,4 +52,9 @@ public class ShareServer implements ShareApi {
|
||||
public void removeShares(@RequestBody PanelShareRemoveRequest request) {
|
||||
shareService.removeShares(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePanelShares(String panelId) {
|
||||
shareService.removeSharesyPanel(panelId);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import io.dataease.plugins.common.base.mapper.PanelShareMapper;
|
||||
import io.dataease.service.message.DeMsgutil;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -386,6 +387,54 @@ public class ShareService {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void removeSharesyPanel(String panelId) {
|
||||
PanelGroup panelGroup = panelGroupMapper.selectByPrimaryKey(panelId);
|
||||
PanelShareRemoveRequest request = new PanelShareRemoveRequest();
|
||||
request.setPanelId(panelId);
|
||||
List<PanelShareOutDTO> panelShareOutDTOS = queryTargets(panelId);
|
||||
extPanelShareMapper.removeShares(request);
|
||||
if (CollectionUtils.isEmpty(panelShareOutDTOS) || ObjectUtils.isEmpty(panelGroup) || StringUtils.isBlank(panelGroup.getName())) {
|
||||
return;
|
||||
}
|
||||
panelShareOutDTOS.forEach(shareOut -> {
|
||||
SysLogConstants.SOURCE_TYPE buiType = buiType(shareOut.getType());
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelId, panelGroup.getPid(), shareOut.getTargetId(), buiType);
|
||||
});
|
||||
|
||||
Map<Integer, List<PanelShareOutDTO>> listMap = panelShareOutDTOS.stream().collect(Collectors.groupingBy(dto -> dto.getType()));
|
||||
AuthURD urd = new AuthURD();
|
||||
for (Map.Entry<Integer, List<PanelShareOutDTO>> entry : listMap.entrySet()) {
|
||||
List<PanelShareOutDTO> dtoList = entry.getValue();
|
||||
if(CollectionUtils.isNotEmpty(dtoList)) {
|
||||
List<Long> curTargetIds = dtoList.stream().map(dto -> Long.parseLong(dto.getTargetId())).collect(Collectors.toList());
|
||||
buildRedAuthURD(entry.getKey(), curTargetIds, urd);
|
||||
}
|
||||
}
|
||||
Set<Long> userIds = AuthUtils.userIdsByURD(urd);
|
||||
if (CollectionUtils.isNotEmpty(userIds)) {
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
Gson gson = new Gson();
|
||||
userIds.forEach(userId -> {
|
||||
if (!user.getUserId().equals(userId)) {
|
||||
String msg = panelGroup.getName();
|
||||
List<String> msgParam = new ArrayList<>();
|
||||
msgParam.add(panelId);
|
||||
DeMsgutil.sendMsg(userId, 3L, user.getNickName() + " 取消分享了仪表板【" + msg + "】,请查收!", gson.toJson(msgParam));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private SysLogConstants.SOURCE_TYPE buiType(Integer type) {
|
||||
SysLogConstants.SOURCE_TYPE targetType = SysLogConstants.SOURCE_TYPE.USER;
|
||||
if (type == 1) {
|
||||
targetType = SysLogConstants.SOURCE_TYPE.ROLE;
|
||||
}else if (type == 2) {
|
||||
targetType = SysLogConstants.SOURCE_TYPE.DEPT;
|
||||
}
|
||||
return targetType;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void removeShares(PanelShareRemoveRequest removeRequest) {
|
||||
String panelId = removeRequest.getPanelId();
|
||||
@ -393,12 +442,7 @@ public class ShareService {
|
||||
|
||||
extPanelShareMapper.removeShares(removeRequest);
|
||||
|
||||
SysLogConstants.SOURCE_TYPE targetType = SysLogConstants.SOURCE_TYPE.USER;
|
||||
if (removeRequest.getType() == 1) {
|
||||
targetType = SysLogConstants.SOURCE_TYPE.ROLE;
|
||||
}else if (removeRequest.getType() == 2) {
|
||||
targetType = SysLogConstants.SOURCE_TYPE.DEPT;
|
||||
}
|
||||
SysLogConstants.SOURCE_TYPE targetType = buiType(removeRequest.getType());
|
||||
|
||||
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelId, panelGroup.getPid(), removeRequest.getTargetId(), targetType);
|
||||
|
||||
@ -407,9 +451,8 @@ public class ShareService {
|
||||
buildRedAuthURD(removeRequest.getType(), removeIds, sharedAuthURD);
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
Gson gson = new Gson();
|
||||
PanelGroup panel = panelGroupMapper.selectByPrimaryKey(panelId);
|
||||
|
||||
String msg = panel.getName();
|
||||
String msg = panelGroup.getName();
|
||||
|
||||
List<String> msgParam = new ArrayList<>();
|
||||
msgParam.add(panelId);
|
||||
|
@ -26,6 +26,14 @@ export function removeShares(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function removePanelShares(panelId) {
|
||||
return request({
|
||||
url: '/api/share/removePanelShares/' + panelId,
|
||||
method: 'post',
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
export function loadShares(data) {
|
||||
return request({
|
||||
url: '/api/share/queryWithResourceId',
|
||||
|
@ -69,7 +69,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { loadTree, loadShareOutTree, removeShares } from '@/api/panel/share'
|
||||
import { loadTree, loadShareOutTree, removePanelShares } from '@/api/panel/share'
|
||||
import { uuid } from 'vue-uuid'
|
||||
import { initPanelData } from '@/api/panel/panel'
|
||||
import { proxyInitPanelData } from '@/api/panel/shareProxy'
|
||||
@ -172,16 +172,12 @@ export default {
|
||||
})
|
||||
},
|
||||
removeCurrent(node) {
|
||||
const param = {
|
||||
panelId: node.id
|
||||
}
|
||||
|
||||
this.$confirm(this.$t('panel.remove_share_confirm'), '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
cancelButtonText: this.$t('commons.cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
removeShares(param).then(res => {
|
||||
removePanelShares(node.id).then(res => {
|
||||
this.panelInfo && this.panelInfo.id && node.id === this.panelInfo.id && this.setMainNull()
|
||||
this.initOutData().then(res => {
|
||||
this.outDatas = res.data
|
||||
|
Loading…
Reference in New Issue
Block a user