<?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.ho.business.mapper.StationStatusMapper">

    <resultMap id="BaseResultMap" type="com.ho.business.entity.StationStatus">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="stationId" column="station_id" jdbcType="INTEGER"/>
        <result property="stationStatus" column="station_status" jdbcType="VARCHAR"/>
        <result property="time" column="time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        ,station_id,station_status,
        `time`
    </sql>

    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.StationStatus"
            useGeneratedKeys="true">
        insert into station_status
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="stationId != null">station_id,</if>
            <if test="stationStatus != null">station_status,</if>
            <if test="time != null">`time`,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="stationId != null">#{stationId},</if>
            <if test="stationStatus != null">#{stationStatus},</if>
            <if test="time != null">#{time},</if>
        </trim>
    </insert>

    <select id="selectByStationId" resultType="com.ho.business.entity.StationStatus">
        select
        <include refid="Base_Column_List"/>
        from station_status
        <where>
            station_id in
            <foreach separator="," collection="stationIds" item="item" open="(" close=")">
                #{item}
            </foreach>

        </where>
        and time BETWEEN #{beginTime}
        AND #{endTime}
    </select>
</mapper>
