refactor(仪表板): 公共链接视图明细导出权限优化,导出权限跟随分享人 #4649

This commit is contained in:
wangjiahao 2023-03-08 16:57:29 +08:00
parent 52822aabc7
commit 923ab6034b
8 changed files with 68 additions and 16 deletions

View File

@ -54,8 +54,8 @@ public interface LinkApi {
boolean validatePwd(PasswordRequest request) throws Exception; boolean validatePwd(PasswordRequest request) throws Exception;
@ApiOperation("资源详细信息") @ApiOperation("资源详细信息")
@GetMapping("/resourceDetail/{resourceId}") @GetMapping("/resourceDetail/{resourceId}/{userId}")
Object resourceDetail(@PathVariable String resourceId); Object resourceDetail(@PathVariable String resourceId,@PathVariable String userId);
@ApiOperation("视图详细信息") @ApiOperation("视图详细信息")
@PostMapping("/viewDetail/{viewId}/{panelId}") @PostMapping("/viewDetail/{viewId}/{panelId}")

View File

@ -94,8 +94,8 @@ public class LinkServer implements LinkApi {
} }
@Override @Override
public Object resourceDetail(@PathVariable String resourceId) { public Object resourceDetail(@PathVariable String resourceId,@PathVariable String userId) {
return panelLinkService.resourceInfo(resourceId); return panelLinkService.resourceInfo(resourceId,userId);
} }
@Override @Override
@ -125,7 +125,7 @@ public class LinkServer implements LinkApi {
operateType = SysLogConstants.OPERATE_TYPE.MB_VIEW; operateType = SysLogConstants.OPERATE_TYPE.MB_VIEW;
} }
if (ObjectUtils.isEmpty(userId)) return; if (ObjectUtils.isEmpty(userId)) return;
PanelGroupWithBLOBs panelGroupWithBLOBs = panelLinkService.resourceInfo(panelId); PanelGroupWithBLOBs panelGroupWithBLOBs = panelLinkService.resourceInfo(panelId,String.valueOf(userId));
String pid = panelGroupWithBLOBs.getPid(); String pid = panelGroupWithBLOBs.getPid();
DeLogUtils.save(operateType, SysLogConstants.SOURCE_TYPE.LINK, panelId, pid, userId, SysLogConstants.SOURCE_TYPE.USER); DeLogUtils.save(operateType, SysLogConstants.SOURCE_TYPE.LINK, panelId, pid, userId, SysLogConstants.SOURCE_TYPE.USER);
} }

View File

@ -11,6 +11,7 @@ import io.dataease.controller.request.panel.link.OverTimeRequest;
import io.dataease.controller.request.panel.link.PasswordRequest; import io.dataease.controller.request.panel.link.PasswordRequest;
import io.dataease.dto.panel.PanelGroupDTO; import io.dataease.dto.panel.PanelGroupDTO;
import io.dataease.dto.panel.link.GenerateDto; import io.dataease.dto.panel.link.GenerateDto;
import io.dataease.ext.ExtPanelGroupMapper;
import io.dataease.ext.ExtPanelLinkMapper; import io.dataease.ext.ExtPanelLinkMapper;
import io.dataease.plugins.common.base.domain.*; import io.dataease.plugins.common.base.domain.*;
import io.dataease.plugins.common.base.mapper.PanelGroupMapper; import io.dataease.plugins.common.base.mapper.PanelGroupMapper;
@ -49,6 +50,8 @@ public class PanelLinkService {
private PanelLinkMappingMapper panelLinkMappingMapper; private PanelLinkMappingMapper panelLinkMappingMapper;
@Resource @Resource
private PanelWatermarkMapper panelWatermarkMapper; private PanelWatermarkMapper panelWatermarkMapper;
@Resource
private ExtPanelGroupMapper extPanelGroupMapper;
@Transactional @Transactional
public void changeValid(LinkRequest request) { public void changeValid(LinkRequest request) {
@ -234,12 +237,10 @@ public class PanelLinkService {
return pass; return pass;
} }
public PanelGroupDTO resourceInfo(String resourceId) { public PanelGroupDTO resourceInfo(String resourceId,String userId) {
PanelGroupWithBLOBs result = panelGroupMapper.selectByPrimaryKey(resourceId); PanelGroupDTO result = extPanelGroupMapper.findOneWithPrivileges(resourceId,userId);
PanelGroupDTO panelGroupDTO = new PanelGroupDTO(); result.setWatermarkInfo(panelWatermarkMapper.selectByPrimaryKey("system_default"));
BeanUtils.copyBean(panelGroupDTO, result); return result;
panelGroupDTO.setWatermarkInfo(panelWatermarkMapper.selectByPrimaryKey("system_default"));
return panelGroupDTO;
} }
public String getShortUrl(String resourceId) { public String getShortUrl(String resourceId) {

View File

@ -2,3 +2,54 @@ UPDATE `my_plugin`
SET `version` = '1.18.5' SET `version` = '1.18.5'
where `plugin_id` > 0 where `plugin_id` > 0
and `version` = '1.18.4'; and `version` = '1.18.4';
DROP FUNCTION IF EXISTS `get_auths`;
delimiter ;;
CREATE FUNCTION `get_auths`(authSource varchar(255),modelType varchar(255),userId varchar(255))
RETURNS longtext CHARSET utf8mb4
READS SQL DATA
BEGIN
DECLARE oTemp longtext;
DECLARE isAdmin int;
select sys_user.is_admin INTO isAdmin from sys_user where user_id =userId;
IF isAdmin = 1 THEN
return 'ignore';
ELSE
SELECT
group_concat( DISTINCT sys_auth_detail.privilege_extend) into oTemp
FROM
(
`sys_auth`
LEFT JOIN `sys_auth_detail` ON ((
`sys_auth`.`id` = `sys_auth_detail`.`auth_id`
)))
where sys_auth_detail.privilege_value =1
and sys_auth.auth_source=authSource
AND (
(
sys_auth.auth_target_type = 'dept'
AND sys_auth.auth_target in ( SELECT dept_id FROM sys_user WHERE user_id = userId )
)
OR (
sys_auth.auth_target_type = 'user'
AND sys_auth.auth_target = userId
)
OR (
sys_auth.auth_target_type = 'role'
AND sys_auth.auth_target in ( SELECT role_id FROM sys_users_roles WHERE user_id = userId )
)
)
GROUP BY
`sys_auth`.`auth_source`,
`sys_auth`.`auth_source_type`;
RETURN oTemp;
END if;
END
;;
delimiter ;

View File

@ -66,9 +66,9 @@ export function loadGenerate(resourceId) {
}) })
} }
export function loadResource(resourceId) { export function loadResource(resourceId,userId) {
return request({ return request({
url: 'api/link/resourceDetail/' + resourceId, url: 'api/link/resourceDetail/' + resourceId+'/'+ userId,
method: 'get' method: 'get'
}) })
} }

View File

@ -113,7 +113,7 @@ Vue.use(VueVideoPlayer)
Vue.use(proportion) Vue.use(proportion)
Vue.prototype.hasDataPermission = function(pTarget, pSource) { Vue.prototype.hasDataPermission = function(pTarget, pSource) {
if (this.$store.state.user.user.isAdmin) { if (this.$store.state.user.user.isAdmin || pSource === 'ignore') {
return true return true
} }
if (pSource && pTarget) { if (pSource && pTarget) {

View File

@ -9,7 +9,7 @@ export function checkPermission(pers) {
} }
export function hasDataPermission(pTarget, pSource) { export function hasDataPermission(pTarget, pSource) {
if (store.state.user.user.isAdmin) { if (store.state.user.user.isAdmin || pSource === 'ignore') {
return true return true
} }
if (pSource && pTarget) { if (pSource && pTarget) {

View File

@ -77,7 +77,7 @@ export default {
}) })
}, },
setPanelInfo() { setPanelInfo() {
loadResource(this.resourceId).then(res => { loadResource(this.resourceId,this.user).then(res => {
this.show = false this.show = false
let loadingCount = 0 let loadingCount = 0
const watermarkInfo = { const watermarkInfo = {