完成了第一版
This commit is contained in:
@ -12,8 +12,6 @@
|
||||
<result property="promoCodeLink" column="promoCodeLink" jdbcType="VARCHAR"/>
|
||||
<result property="projectName" column="projectName" jdbcType="VARCHAR"/>
|
||||
<result property="projectImage" column="projectImage" jdbcType="VARCHAR"/>
|
||||
<result property="maxProjectPrice" column="maxProjectPrice" jdbcType="DECIMAL"/>
|
||||
<result property="minProjectPrice" column="minProjectPrice" jdbcType="DECIMAL"/>
|
||||
<result property="userId" column="userId" jdbcType="BIGINT"/>
|
||||
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
|
||||
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
|
||||
|
@ -25,4 +25,26 @@
|
||||
userRole,parentUserId,superUserList,
|
||||
isDelete,createTime,updateTime
|
||||
</sql>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 查询从 userId 一路到根节点的所有 id,按 depth 倒序(根先出)-->
|
||||
<select id="findPathToRoot" resultType="java.lang.Long">
|
||||
WITH RECURSIVE user_path AS (
|
||||
SELECT id, parentUserId, 1 AS depth
|
||||
FROM user_info
|
||||
WHERE id = #{userId}
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT u.id, u.parentUserId, up.depth + 1
|
||||
FROM user_info u
|
||||
JOIN user_path up ON u.id = up.parentUserId
|
||||
WHERE up.depth < 50000
|
||||
)
|
||||
SELECT id
|
||||
FROM user_path
|
||||
ORDER BY depth DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user