| | |
| | | <select id="findThreeProductionId" resultType="java.lang.String"> |
| | | SELECT TOP 1 t2.id id FROM mdc_user_production t1 LEFT JOIN mdc_production t2 ON t1.pro_id = t2.id WHERE t1.user_id = #{userId} AND t2.org_type = '3' |
| | | </select> |
| | | </mapper> |
| | | <select id="findAllProductionId" resultType="org.jeecg.modules.system.entity.MdcProduction"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | mdc_production t1 |
| | | LEFT JOIN mdc_user_production t2 ON t1.id = t2.pro_id |
| | | LEFT JOIN sys_user t3 on t3.ID=t2.user_id |
| | | WHERE |
| | | t3.id = #{userId} |
| | | AND t1.org_type = '3' |
| | | </select> |
| | | <select id="recursionChildrenByList" resultType="java.lang.String"> |
| | | WITH temp (id) AS ( |
| | | -- 初始查询,获取指定 id 的记录 |
| | | SELECT |
| | | id |
| | | FROM |
| | | mdc_production |
| | | WHERE |
| | | id IN |
| | | <foreach collection = "productionIds" item = "id" index = "index" open = "(" close = ")" separator = ","> |
| | | #{id} |
| | | </foreach> |
| | | UNION ALL |
| | | -- 递归查询,查找子节点 |
| | | SELECT |
| | | a.id |
| | | FROM |
| | | mdc_production a |
| | | INNER JOIN temp ON a.parent_id = temp.id |
| | | ) |
| | | -- 最终查询,使用 DISTINCT 去重 |
| | | SELECT DISTINCT |
| | | id |
| | | FROM |
| | | temp; |
| | | </select> |
| | | </mapper> |