Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

部门权限不随切换部门而改变 #4137

Closed
zhangdaiscott opened this issue Oct 27, 2022 · 0 comments
Closed

部门权限不随切换部门而改变 #4137

zhangdaiscott opened this issue Oct 27, 2022 · 0 comments

Comments

@zhangdaiscott
Copy link
Member

版本号:2.4.3
问题描述:用户具有A、B两个部门时,A部门可看菜单1,B部门可看菜单2,在给用户分配了相应权限后,无论怎么切换,均可同时看到菜单1和菜单2,我认为还是切换不同部门看不同菜单好一些。

追踪了代码后发现,问题在SysPermissionMapper.xml的queryByUser方法里,方法如下:

<select id="queryByUser" parameterType="Object"  resultMap="SysPermission">
	   SELECT * FROM (
		   SELECT p.*
		   FROM  sys_permission p
		   WHERE (exists(
					select a.id from sys_role_permission a
					join sys_role b on a.role_id = b.id
					join sys_user_role c on c.role_id = b.id
					join sys_user d on d.id = c.user_id
					where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
				)
				or (p.url like '%:code' and p.url like '/online%' and p.hidden = 1)
				or p.url = '/online')
		   and p.del_flag = 0
		<!--update begin Author:lvdandan  Date:20200213 for:加入部门权限 -->
		   UNION
		   SELECT p.*
		   FROM  sys_permission p
		   WHERE exists(
				select a.id from sys_depart_role_permission a
				join sys_depart_role b on a.role_id = b.id
				join sys_depart_role_user c on c.drole_id = b.id
				join sys_user d on d.id = c.user_id
				where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
		   )
		   and p.del_flag = 0
		<!--update end Author:lvdandan  Date:20200213 for:加入部门权限 -->
	   ) h order by h.sort_no ASC
</select>> 

建议在此位置加入部门过滤子句。
输入图片说明

友情提示: 未按格式要求发帖,会直接删掉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant