shuishen
2021-09-07 d012d12ca32309ce3867511efc3b33a5790e9753
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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="org.springblade.modules.basinSation.mapper.BasinStationMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="basinStationResultMap" type="org.springblade.modules.basinSation.entity.BasinStation">
        <id column="BASIN_STATION_ID" property="basinStationId"/>
        <result column="STATION_CODE" property="stationCode"/>
        <result column="STATION_NAME" property="stationName"/>
        <result column="BASIN_CODE" property="basinCode"/>
        <result column="WEIGHT" property="weight"/>
        <result column="SPARE1" property="spare1"/>
        <result column="SPARE2" property="spare2"/>
        <result column="SPARE3" property="spare3"/>
    </resultMap>
 
    <resultMap id="treeNodeResulTMap" type="org.springblade.core.tool.node.TreeNode">
        <id column="id" property="id"/>
        <result column="parent_id" property="parentId"/>
        <result column="title" property="title"/>
        <result column="value" property="value"/>
        <result column="key" property="key"/>
        <result column="has_children" property="hasChildren"/>
    </resultMap>
 
    <select id="selectBasinStationPage" resultMap="basinStationResultMap">
        select * from ZHSW_BASIN_STATION where 1=1
        <if test="deptId!=null and deptId != ''">
            and STATION_CODE = #{deptId}
        </if>
        <if test="parentId!=null and parentId != ''">
            and BASIN_CODE = #{parentId}
        </if>
    </select>
 
    <select id="selectBasins" resultMap="basinStationResultMap">
        select * from ZHSW_BASIN_STATION where 1=1
        <if test="deptId!=null and deptId != ''">
            and BASIN_CODE = #{deptId}
        </if>
    </select>
 
    <select id="lazyTree" resultMap="treeNodeResulTMap">
        SELECT
            dept.STATION_CODE AS id,
            dept.BASIN_CODE AS parent_id,
            dept.STATION_NAME AS title,
            dept.STATION_CODE AS "value",
            dept.STATION_CODE AS "key",
            ( SELECT CASE WHEN COUNT ( 1 ) > 0 THEN 1 ELSE 0 END FROM ZHSW_BASIN_STATION WHERE BASIN_CODE = dept.STATION_CODE ) AS "has_children"
        FROM
            ZHSW_BASIN_STATION dept WHERE dept.BASIN_CODE=#{code}
    </select>
</mapper>