<?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.StationSnMapper">


    <sql id="Base_Column_List">
        id
        ,station_id,sn
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List"/>
        from station_sn
        where id = #{id,jdbcType=INTEGER}
    </select>

    <select id="selectByStationId" resultType="com.ho.business.entity.StationSn">
        select
        <include refid="Base_Column_List"/>
        from station_sn
        where station_id = #{stationId}
    </select>

    <select id="selectBySn" resultType="com.ho.business.entity.StationSn">
        select
        <include refid="Base_Column_List"/>
        from station_sn
        where sn = #{sn}
    </select>


    <select id="selectBySnList" resultType="com.ho.business.entity.StationSn">
        select
        <include refid="Base_Column_List"/>
        from station_sn
        <where>
            sn in
            <foreach separator="," collection="snList" item="item" open="(" close=")">
              #{item}
            </foreach>
        </where>
    </select>

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

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from station_sn
        where id = #{id,jdbcType=INTEGER}
    </delete>


    <delete id="deleteByStationIds">
        delete
        from station_sn
        <where>
            station_id in
            <foreach collection="ids" open="(" close=")" separator="," item="stationId">
                #{stationId}
            </foreach>
        </where>
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.StationSn"
            useGeneratedKeys="true">
        insert into station_sn
        (id, stationId, sn)
        values (#{id,jdbcType=INTEGER}, #{stationid,jdbcType=INTEGER}, #{sn,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.StationSn"
            useGeneratedKeys="true">
        insert into station_sn
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="station_id != null">stationId,</if>
            <if test="sn != null">sn,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=INTEGER},</if>
            <if test="station_id != null">#{stationid,jdbcType=INTEGER},</if>
            <if test="sn != null">#{sn,jdbcType=VARCHAR},</if>
        </trim>
    </insert>

    <insert id="insertSNList">
        insert into station_sn
        (station_id, sn)
        values
        <foreach separator="," collection="stationSnList" item="item">
            (#{item.stationId},#{item.sn})
        </foreach>
    </insert>


    <update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.StationSn">
        update station_sn
        <set>
            <if test="stationId != null">
                station_id = #{stationid,jdbcType=INTEGER},
            </if>
            <if test="sn != null">
                sn = #{sn,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ho.business.entity.StationSn">
        update station_sn
        set station_id = #{stationid,jdbcType=INTEGER},
            sn        = #{sn,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>
