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

    <sql id="Base_Column_List">
        id,name,station_id,permission_id,page_location,div_location,device_id
    </sql>

    <insert id="insertOne" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
        insert into dynamic_config_title (name,name_en,station_id,permission_id,page_location,div_location,device_id)
        values (#{name},#{nameEn},#{stationId},#{permissionId},#{pageLocation},#{divLocation},#{deviceId})
    </insert>

    <update id="updateById">
        update dynamic_config_title
        <set>
            <if test="name != null">
                name = #{name},
            </if>
            <if test="nameEn != null">
                name_en = #{nameEn},
            </if>
            <if test="stationId != null">
                station_id = #{stationId},
            </if>
            <if test="permissionId != null">
                permission_id = #{permissionId},
            </if>
            <if test="pageLocation != null">
                page_location = #{pageLocation},
            </if>
            <if test="divLocation != null">
                div_location = #{divLocation},
            </if>
            <if test="deviceId != null">
                device_id = #{deviceId},
            </if>
        </set>
        where id = #{id}
    </update>

    <select id="selectByParam" resultType="com.ho.business.entity.DynamicConfigTitle">
       SELECT
       <include refid="Base_Column_List"/>
       FROM dynamic_config_title
       <where>
           <if test="name != null">and name like concat('%',#{name},'%')</if>
           <if test="stationId != null">and station_id = #{stationId}</if>
           <if test="permissionId != null">and permission_id = #{permissionId}</if>
           <if test="pageLocation != null">and page_location = #{pageLocation}</if>
           <if test="divLocation != null">and div_location = #{divLocation}</if>
           <if test="deviceId != null">and device_id = #{deviceId}</if>
       </where>
    </select>

    <delete id="deleteById">
        delete
        from dynamic_config_title where
        id = #{id}
    </delete>

    <delete id="deleteByIds">
        delete
        from dynamic_config_title
        <where>
            <if test="ids != null and ids.size() != 0">
                and id in
                <foreach collection="ids" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>
        </where>
    </delete>

</mapper>
