<?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.ruoyi.project.system.mapper.SysIpMapper">

    <resultMap type="SysIp" id="SysIpResult">
        <result property="id" column="id"/>
        <result property="agreeIp" column="agreeIp"/>
        <result property="remark" column="remark"/>
        <result property="createBy" column="createBy"/>
        <result property="createDate" column="createDate"/>
        <result property="updateBy" column="updateBy"/>
        <result property="updateTime" column="updateTime"/>
    </resultMap>

    <sql id="selectSysIpVo">
        select id, agreeIp, remark, createBy, createDate, updateBy, updateTime
        from sys_ip
    </sql>

    <select id="selectSysIpList" parameterType="SysIp" resultMap="SysIpResult">
        <include refid="selectSysIpVo"/>
        <where>
            <if test="agreeIp != null  and agreeIp != ''">and agreeIp like concat('%', #{agreeIp}, '%')</if>
            <if test="createBy != null  and createBy != ''">and createBy = #{createBy}</if>
            <if test="createDate != null ">and createDate = #{createDate}</if>
            <if test="updateBy != null  and updateBy != ''">and updateBy = #{updateBy}</if>
            <if test="updateTime != null ">and updateTime = #{updateTime}</if>
        </where>
    </select>

    <select id="selectSysIpById" parameterType="Long" resultMap="SysIpResult">
        <include refid="selectSysIpVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysIp" parameterType="SysIp" useGeneratedKeys="true" keyProperty="id">
        insert into sys_ip
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="agreeIp != null">agreeIp,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">createBy,</if>
            createDate,
            <if test="updateBy != null">updateBy,</if>
            updateTime,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="agreeIp != null">#{agreeIp},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            sysdate(),
            <if test="updateBy != null">#{updateBy},</if>
            sysdate()
        </trim>
    </insert>

    <update id="updateSysIp" parameterType="SysIp">
        update sys_ip
        <trim prefix="SET" suffixOverrides=",">
            <if test="agreeIp != null">agreeIp = #{agreeIp},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="updateBy != null">updateBy = #{updateBy},</if>
            <if test="updateTime != null">updateTime = sysdate(),</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysIpById" parameterType="Long">
        delete
        from sys_ip
        where id = #{id}
    </delete>

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