<?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="cn.reghao.tnb.content.app.geo.db.mapper.BusStationMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into geo_bus_station
        (`lng`,`lat`,`station_name`,`pm`,`tid`,`line_name`)
        values
        (#{lng},#{lat},#{stationName},#{pm},#{tid},#{lineName})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into geo_bus_station
        (`lng`,`lat`,`station_name`,`pm`,`tid`,`line_name`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.lng},#{item.lat},#{item.stationName},#{item.pm},#{item.tid},#{item.lineName})
        </foreach>
    </insert>

    <select id="findAll" resultType="cn.reghao.tnb.content.app.geo.model.po.BusStation">
        select *
        from geo_bus_station
        where type=2
    </select>
    <select id="findByLineName" resultType="cn.reghao.tnb.content.app.geo.model.vo.PublicBus">
        select line_name,pm as pos,station_name
        from geo_bus_station
        where type=2 and line_name=#{lineName}
        order by pm asc
    </select>
    <select id="findByStationName" resultType="cn.reghao.tnb.content.app.geo.model.po.BusStation">
        select *
        from geo_bus_station
        where type=2 and station_name=#{stationName}
    </select>
    <select id="findByGroupLineName" resultType="java.lang.String">
        select line_name
        from geo_bus_station
        where type=2
        group by line_name
        order by line_name asc
    </select>
</mapper>
