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

    <resultMap id="BaseResultMap" type="com.ho.business.entity.PageConfig">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="stationId" column="station_id" jdbcType="INTEGER"/>
            <result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
            <result property="deviceCol" column="device_col" jdbcType="VARCHAR"/>
            <result property="deviceColId" column="device_col_id" jdbcType="INTEGER"/>
            <result property="deviceColIdName" column="device_col_id_name" jdbcType="VARCHAR"/>
            <result property="modelCol" column="model_col" jdbcType="VARCHAR"/>
            <result property="modelColId" column="model_col_id" jdbcType="INTEGER"/>
            <result property="modelColIdName" column="model_col_id_name" jdbcType="VARCHAR"/>
            <result property="modelType" column="model_type" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,station_id,device_type,
        device_col,device_col_id,device_col_id_name,
        model_col,model_col_id,model_col_id_name,
        model_type
    </sql>
    <insert id="addBatch">
        insert into page_config (<include refid="Base_Column_List"/>)
        values
        <foreach item="item" collection="list" index="index" separator=",">
            (
            #{item.id},
            #{item.stationId},#{item.deviceType},
            #{item.deviceCol},#{item.deviceColId},#{item.deviceColIdName},
            #{item.modelCol}, #{item.modelColId}, #{item.modelColIdName},
            #{item.modelType}
            )
        </foreach>
    </insert>
    <delete id="deleteBatch">
        delete from page_config
        where id in
        <foreach collection="ids" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>

    <select id="selectPage" resultType="com.ho.business.entity.PageConfig">
        select
        <include refid="Base_Column_List"/>
        from page_config
        <where>
            <if test="pageConfig.stationId!=null">
                and station_id = #{pageConfig.stationId}
            </if>
            <if test="pageConfig.deviceType!=null">
                and device_type = #{pageConfig.deviceType}
            </if>
            <if test="pageConfig.modelType!=null">
                and model_type = #{pageConfig.modelType}
            </if>
        </where>
    </select>

    <delete id="deleteStationId">
        delete
        from page_config
        where station_id = #{stationId}
    </delete>
</mapper>
