<?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.ruoyi.cms.mapper.SubwayLineMapper">
    
    <resultMap type="SubwayLine" id="SubwayLineResult">
        <result property="lineId"    column="line_id"    />
        <result property="lineName"    column="line_name"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>
    <resultMap type="SubwayLine" id="SubwayLineStationResult">
        <id property="lineId"    column="line_id"    />
        <result property="lineName"    column="line_name"    />
        <collection  property="subwayStationList"   javaType="java.util.List"  resultMap="stationList" />
    </resultMap>
    <resultMap type="SubwayStation" id="stationList">
        <id property="stationId"    column="station_id"    />
        <result property="lineId"    column="line_id"    />
        <result property="stationName"    column="station_name"    />
        <result property="lineName"    column="line_name"    />
        <result property="latitude"    column="latitude"    />
        <result property="longitude"    column="longitude"    />
    </resultMap>
    <sql id="selectSubwayLineVo">
        select line_id, line_name, del_flag, create_by, create_time, update_by, update_time, remark from subway_line
    </sql>

    <select id="selectSubwayLineList" parameterType="SubwayLine" resultMap="SubwayLineResult">
        <include refid="selectSubwayLineVo"/>
        <where>  del_flag = '0'
            <if test="lineName != null  and lineName != ''"> and line_name like concat('%', #{lineName}, '%')</if>
        </where>
    </select>
    <select id="appSubway" resultMap="SubwayLineStationResult">
        select l.line_id, l.line_name,s.station_id, s.station_name, s.line_name,s.latitude, s.longitude,s.station_order
        from subway_line as l
        inner join subway_station as s on s.line_id = l.line_id
        where l.del_flag = '0' and s.del_flag = '0'
    </select>
</mapper>