XiaoRuby
2023-08-24 e0ef38a77c4bbe67d8a9eab46134ed00fb1e8293
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yuanchu.limslaboratory.mapper.OrganizationalMapper">
 
    <resultMap id="OrganizationalMap" type="map">
        <id property="id" column="id"/>
        <result property="department" column="department"/>
        <collection property="children" select="OrganizationalTree" column="id" javaType="list"/>
    </resultMap>
 
    <select id="OrganizationalTree" resultMap="OrganizationalMap">
        SELECT o.id, o.`department` FROM organizational o where o.`father_id` = #{father_id}
    </select>
 
    <select id="getDepartmentListTable" resultType="map">
        SELECT o.`id`, o.`department`
        FROM organizational o
        WHERE o.`father_id` = #{departmentId}
          AND o.`state` = 1
    </select>
</mapper>