达梦适配修改
This commit is contained in:
@@ -260,32 +260,40 @@
|
||||
</select>
|
||||
|
||||
<select id="selectAllOrganizationById" resultType="java.lang.Long" parameterType="java.lang.Long">
|
||||
SELECT
|
||||
organization_id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
t1.organization_id,
|
||||
t1.organization_name,
|
||||
t1.parent_organization_id,
|
||||
IF
|
||||
(
|
||||
find_in_set( parent_organization_id, @pids ) > 0,
|
||||
@pids := concat( @pids, ',', organization_id ),
|
||||
IF
|
||||
( t1.organization_id = #{organizationId}, #{organizationId}, - 1 )
|
||||
) AS ischild
|
||||
FROM
|
||||
( SELECT organization_id, parent_organization_id, organization_name FROM sys_organization t ) t1,
|
||||
( SELECT @pids := #{organizationId} ) t2
|
||||
) t3
|
||||
WHERE
|
||||
ischild != - 1
|
||||
<!-- SELECT-->
|
||||
<!-- organization_id-->
|
||||
<!-- FROM-->
|
||||
<!-- (-->
|
||||
<!-- SELECT-->
|
||||
<!-- t1.organization_id,-->
|
||||
<!-- t1.organization_name,-->
|
||||
<!-- t1.parent_organization_id,-->
|
||||
<!-- IF-->
|
||||
<!-- (-->
|
||||
<!-- find_in_set( parent_organization_id, @pids ) > 0,-->
|
||||
<!-- @pids := concat( @pids, ',', organization_id ),-->
|
||||
<!-- IF-->
|
||||
<!-- ( t1.organization_id = #{organizationId}, #{organizationId}, - 1 )-->
|
||||
<!-- ) AS ischild-->
|
||||
<!-- FROM-->
|
||||
<!-- ( SELECT organization_id, parent_organization_id, organization_name FROM sys_organization t ) t1,-->
|
||||
<!-- ( SELECT @pids := #{organizationId} ) t2-->
|
||||
<!-- ) t3-->
|
||||
<!--WHERE-->
|
||||
<!--ischild != - 1-->
|
||||
WITH RECURSIVE org_tree(org_id) AS (
|
||||
-- 初始查询:找到指定组织
|
||||
SELECT organization_id
|
||||
FROM sys_organization
|
||||
WHERE organization_id = #{organizationId}
|
||||
UNION ALL
|
||||
-- 递归查询:找到所有子组织
|
||||
SELECT child.organization_id
|
||||
FROM sys_organization child
|
||||
INNER JOIN org_tree parent
|
||||
ON child.parent_organization_id = parent.org_id
|
||||
)
|
||||
SELECT org_id AS organization_id FROM org_tree;
|
||||
</select>
|
||||
<select id="getAllOrganization"
|
||||
resultType="com.linke.product.domain.organization.repository.po.OrganizationPo">
|
||||
|
||||
Reference in New Issue
Block a user