fix: 1.用户添加多个角色 查询报错问题
This commit is contained in:
parent
432459a062
commit
bf52d4ec03
@ -38,38 +38,8 @@
|
|||||||
create_time,
|
create_time,
|
||||||
panel_type,
|
panel_type,
|
||||||
`name` AS label,
|
`name` AS label,
|
||||||
authInfo.`privileges`
|
get_auths(id,'panel',#{userId}) as `privileges`
|
||||||
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'panel') cids) t,panel_group
|
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'panel') cids) t,panel_group
|
||||||
left join
|
|
||||||
(SELECT
|
|
||||||
`sys_auth`.`auth_source` AS `auth_source`,
|
|
||||||
`sys_auth`.`auth_source_type` AS `auth_source_type`,
|
|
||||||
group_concat( sys_auth_detail.privilege_extend) AS `privileges`
|
|
||||||
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_target_type = 'dept'
|
|
||||||
AND sys_auth.auth_target = ( 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 = ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
|
|
||||||
)
|
|
||||||
)
|
|
||||||
GROUP BY
|
|
||||||
`sys_auth`.`auth_source`,
|
|
||||||
`sys_auth`.`auth_source_type`) authInfo
|
|
||||||
on panel_group.id = authInfo.auth_source and authInfo.auth_source_type='panel'
|
|
||||||
<where>
|
<where>
|
||||||
FIND_IN_SET(panel_group.id,cids)
|
FIND_IN_SET(panel_group.id,cids)
|
||||||
<if test="name != null">
|
<if test="name != null">
|
||||||
|
|||||||
@ -191,9 +191,8 @@ delimiter ;
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP FUNCTION IF EXISTS `get_auths`;
|
DROP FUNCTION IF EXISTS `get_auths`;
|
||||||
delimiter ;;
|
delimiter ;;
|
||||||
CREATE FUNCTION `get_auths`(authSource varchar(255),modelType varchar(255),userId varchar(255))
|
CREATE DEFINER=`root`@`%` FUNCTION `get_auths`(authSource varchar(255),modelType varchar(255),userId varchar(255)) RETURNS longtext CHARSET utf8
|
||||||
RETURNS longtext CHARSET utf8
|
READS SQL DATA
|
||||||
READS SQL DATA
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
DECLARE oTemp longtext;
|
DECLARE oTemp longtext;
|
||||||
@ -211,7 +210,7 @@ FROM
|
|||||||
AND (
|
AND (
|
||||||
(
|
(
|
||||||
sys_auth.auth_target_type = 'dept'
|
sys_auth.auth_target_type = 'dept'
|
||||||
AND sys_auth.auth_target = ( SELECT dept_id FROM sys_user WHERE user_id = userId )
|
AND sys_auth.auth_target in ( SELECT dept_id FROM sys_user WHERE user_id = userId )
|
||||||
)
|
)
|
||||||
OR (
|
OR (
|
||||||
sys_auth.auth_target_type = 'user'
|
sys_auth.auth_target_type = 'user'
|
||||||
@ -219,7 +218,7 @@ FROM
|
|||||||
)
|
)
|
||||||
OR (
|
OR (
|
||||||
sys_auth.auth_target_type = 'role'
|
sys_auth.auth_target_type = 'role'
|
||||||
AND sys_auth.auth_target = ( SELECT role_id FROM sys_users_roles WHERE user_id = userId )
|
AND sys_auth.auth_target in ( SELECT role_id FROM sys_users_roles WHERE user_id = userId )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
@ -303,8 +302,6 @@ delimiter ;
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Function structure for GET_V_AUTH_MODEL_ID_P_USE
|
-- Function structure for GET_V_AUTH_MODEL_ID_P_USE
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP FUNCTION IF EXISTS `GET_V_AUTH_MODEL_ID_P_USE`;
|
|
||||||
delimiter ;;
|
|
||||||
CREATE DEFINER=`root`@`%` FUNCTION `GET_V_AUTH_MODEL_ID_P_USE`(userId longtext,modelType varchar(255)) RETURNS longtext CHARSET utf8
|
CREATE DEFINER=`root`@`%` FUNCTION `GET_V_AUTH_MODEL_ID_P_USE`(userId longtext,modelType varchar(255)) RETURNS longtext CHARSET utf8
|
||||||
READS SQL DATA
|
READS SQL DATA
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -324,7 +321,7 @@ SELECT
|
|||||||
AND (
|
AND (
|
||||||
(
|
(
|
||||||
sys_auth.auth_target_type = 'dept'
|
sys_auth.auth_target_type = 'dept'
|
||||||
AND sys_auth.auth_target = ( SELECT dept_id FROM sys_user WHERE user_id = userId )
|
AND sys_auth.auth_target in ( SELECT dept_id FROM sys_user WHERE user_id = userId )
|
||||||
)
|
)
|
||||||
OR (
|
OR (
|
||||||
sys_auth.auth_target_type = 'user'
|
sys_auth.auth_target_type = 'user'
|
||||||
@ -332,7 +329,7 @@ SELECT
|
|||||||
)
|
)
|
||||||
OR (
|
OR (
|
||||||
sys_auth.auth_target_type = 'role'
|
sys_auth.auth_target_type = 'role'
|
||||||
AND sys_auth.auth_target = ( SELECT role_id FROM sys_users_roles WHERE user_id = userId )
|
AND sys_auth.auth_target in ( SELECT role_id FROM sys_users_roles WHERE user_id = userId )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
GROUP BY
|
GROUP BY
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user