<?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.supervision.grassrootsregistration.mapper.BdglIpaddressConfigMapper">

    <resultMap type="BdglIpaddressConfig" id="BdglIpaddressConfigResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="ip"    column="ip"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectBdglIpaddressConfigVo">
        select id, name, ip, create_time, update_time from bdgl_ipaddress_config
    </sql>

    <select id="selectBdglIpaddressConfigList" parameterType="BdglIpaddressConfig" resultMap="BdglIpaddressConfigResult">
        <include refid="selectBdglIpaddressConfigVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="ip != null  and ip != ''"> and ip = #{ip}</if>
        </where>
    </select>

    <select id="selectBdglIpaddressConfigById" parameterType="Integer" resultMap="BdglIpaddressConfigResult">
        <include refid="selectBdglIpaddressConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertBdglIpaddressConfig" parameterType="BdglIpaddressConfig" useGeneratedKeys="true" keyProperty="id">
        insert into bdgl_ipaddress_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="ip != null">ip,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="ip != null">#{ip},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateBdglIpaddressConfig" parameterType="BdglIpaddressConfig">
        update bdgl_ipaddress_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="ip != null">ip = #{ip},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBdglIpaddressConfigById" parameterType="Integer">
        delete from bdgl_ipaddress_config where id = #{id}
    </delete>

    <delete id="deleteBdglIpaddressConfigByIds" parameterType="String">
        delete from bdgl_ipaddress_config where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>