diff --git a/backend/src/main/java/io/dataease/controller/panel/api/LinkApi.java b/backend/src/main/java/io/dataease/controller/panel/api/LinkApi.java index a27b37eae3..a984e4c23d 100644 --- a/backend/src/main/java/io/dataease/controller/panel/api/LinkApi.java +++ b/backend/src/main/java/io/dataease/controller/panel/api/LinkApi.java @@ -54,8 +54,8 @@ public interface LinkApi { boolean validatePwd(PasswordRequest request) throws Exception; @ApiOperation("资源详细信息") - @GetMapping("/resourceDetail/{resourceId}") - Object resourceDetail(@PathVariable String resourceId); + @GetMapping("/resourceDetail/{resourceId}/{userId}") + Object resourceDetail(@PathVariable String resourceId,@PathVariable String userId); @ApiOperation("视图详细信息") @PostMapping("/viewDetail/{viewId}/{panelId}") diff --git a/backend/src/main/java/io/dataease/controller/panel/server/LinkServer.java b/backend/src/main/java/io/dataease/controller/panel/server/LinkServer.java index 2e0be45aec..e23d9981bf 100644 --- a/backend/src/main/java/io/dataease/controller/panel/server/LinkServer.java +++ b/backend/src/main/java/io/dataease/controller/panel/server/LinkServer.java @@ -94,8 +94,8 @@ public class LinkServer implements LinkApi { } @Override - public Object resourceDetail(@PathVariable String resourceId) { - return panelLinkService.resourceInfo(resourceId); + public Object resourceDetail(@PathVariable String resourceId,@PathVariable String userId) { + return panelLinkService.resourceInfo(resourceId,userId); } @Override @@ -125,7 +125,7 @@ public class LinkServer implements LinkApi { operateType = SysLogConstants.OPERATE_TYPE.MB_VIEW; } if (ObjectUtils.isEmpty(userId)) return; - PanelGroupWithBLOBs panelGroupWithBLOBs = panelLinkService.resourceInfo(panelId); + PanelGroupWithBLOBs panelGroupWithBLOBs = panelLinkService.resourceInfo(panelId,String.valueOf(userId)); String pid = panelGroupWithBLOBs.getPid(); DeLogUtils.save(operateType, SysLogConstants.SOURCE_TYPE.LINK, panelId, pid, userId, SysLogConstants.SOURCE_TYPE.USER); } diff --git a/backend/src/main/java/io/dataease/service/panel/PanelLinkService.java b/backend/src/main/java/io/dataease/service/panel/PanelLinkService.java index 6caf7c6e57..d9baa4281c 100644 --- a/backend/src/main/java/io/dataease/service/panel/PanelLinkService.java +++ b/backend/src/main/java/io/dataease/service/panel/PanelLinkService.java @@ -11,6 +11,7 @@ import io.dataease.controller.request.panel.link.OverTimeRequest; import io.dataease.controller.request.panel.link.PasswordRequest; import io.dataease.dto.panel.PanelGroupDTO; import io.dataease.dto.panel.link.GenerateDto; +import io.dataease.ext.ExtPanelGroupMapper; import io.dataease.ext.ExtPanelLinkMapper; import io.dataease.plugins.common.base.domain.*; import io.dataease.plugins.common.base.mapper.PanelGroupMapper; @@ -49,6 +50,8 @@ public class PanelLinkService { private PanelLinkMappingMapper panelLinkMappingMapper; @Resource private PanelWatermarkMapper panelWatermarkMapper; + @Resource + private ExtPanelGroupMapper extPanelGroupMapper; @Transactional public void changeValid(LinkRequest request) { @@ -234,12 +237,10 @@ public class PanelLinkService { return pass; } - public PanelGroupDTO resourceInfo(String resourceId) { - PanelGroupWithBLOBs result = panelGroupMapper.selectByPrimaryKey(resourceId); - PanelGroupDTO panelGroupDTO = new PanelGroupDTO(); - BeanUtils.copyBean(panelGroupDTO, result); - panelGroupDTO.setWatermarkInfo(panelWatermarkMapper.selectByPrimaryKey("system_default")); - return panelGroupDTO; + public PanelGroupDTO resourceInfo(String resourceId,String userId) { + PanelGroupDTO result = extPanelGroupMapper.findOneWithPrivileges(resourceId,userId); + result.setWatermarkInfo(panelWatermarkMapper.selectByPrimaryKey("system_default")); + return result; } public String getShortUrl(String resourceId) { diff --git a/backend/src/main/resources/db/migration/V52__1.18.5.sql b/backend/src/main/resources/db/migration/V52__1.18.5.sql index 388bf70ea5..6367a06935 100644 --- a/backend/src/main/resources/db/migration/V52__1.18.5.sql +++ b/backend/src/main/resources/db/migration/V52__1.18.5.sql @@ -2,3 +2,54 @@ UPDATE `my_plugin` SET `version` = '1.18.5' where `plugin_id` > 0 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 ; \ No newline at end of file diff --git a/frontend/src/api/link/index.js b/frontend/src/api/link/index.js index 1b25ae6822..52d1481148 100644 --- a/frontend/src/api/link/index.js +++ b/frontend/src/api/link/index.js @@ -66,9 +66,9 @@ export function loadGenerate(resourceId) { }) } -export function loadResource(resourceId) { +export function loadResource(resourceId,userId) { return request({ - url: 'api/link/resourceDetail/' + resourceId, + url: 'api/link/resourceDetail/' + resourceId+'/'+ userId, method: 'get' }) } diff --git a/frontend/src/main.js b/frontend/src/main.js index 673cf928ec..8081fd0d2b 100644 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -113,7 +113,7 @@ Vue.use(VueVideoPlayer) Vue.use(proportion) Vue.prototype.hasDataPermission = function(pTarget, pSource) { - if (this.$store.state.user.user.isAdmin) { + if (this.$store.state.user.user.isAdmin || pSource === 'ignore') { return true } if (pSource && pTarget) { diff --git a/frontend/src/utils/permission.js b/frontend/src/utils/permission.js index 13677e4877..030767a630 100644 --- a/frontend/src/utils/permission.js +++ b/frontend/src/utils/permission.js @@ -9,7 +9,7 @@ export function checkPermission(pers) { } export function hasDataPermission(pTarget, pSource) { - if (store.state.user.user.isAdmin) { + if (store.state.user.user.isAdmin || pSource === 'ignore') { return true } if (pSource && pTarget) { diff --git a/frontend/src/views/link/view/index.vue b/frontend/src/views/link/view/index.vue index 733a0b103b..fa18d5e76e 100644 --- a/frontend/src/views/link/view/index.vue +++ b/frontend/src/views/link/view/index.vue @@ -77,7 +77,7 @@ export default { }) }, setPanelInfo() { - loadResource(this.resourceId).then(res => { + loadResource(this.resourceId,this.user).then(res => { this.show = false let loadingCount = 0 const watermarkInfo = {