<?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.web.mapper.plotmanage.AdFlatMapper">
    
    <resultMap type="AdFlat" id="AdFlatResult">
        <result property="id"    column="id"    />
        <result property="plotid"    column="plotId"    />
        <result property="name"    column="name"    />
        <result property="remake"    column="remake"    />
        <result property="createdate"    column="createDate"    />
        <result property="create"    column="create"    />
    </resultMap>

    <sql id="selectAdFlatVo">
        select id, plotId, name, remake, createDate, create from ad_flat
    </sql>

    <select id="selectAdFlatList" parameterType="AdFlat" resultMap="AdFlatResult">
        <include refid="selectAdFlatVo"/>
        <where>  
            <if test="plotid != null  and plotid != ''"> and plotId = #{plotid}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="remake != null  and remake != ''"> and remake = #{remake}</if>
            <if test="createdate != null "> and createDate = #{createdate}</if>
            <if test="create != null  and create != ''"> and create = #{create}</if>
        </where>
    </select>
    
    <select id="selectAdFlatById" parameterType="String" resultMap="AdFlatResult">
        <include refid="selectAdFlatVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAdFlat" parameterType="AdFlat">
        insert into ad_flat
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plotid != null and plotid != ''">plotId,</if>
            <if test="name != null">name,</if>
            <if test="remake != null">remake,</if>
            <if test="createdate != null">createDate,</if>
            <if test="create != null">create,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plotid != null and plotid != ''">#{plotid},</if>
            <if test="name != null">#{name},</if>
            <if test="remake != null">#{remake},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="create != null">#{create},</if>
         </trim>
    </insert>

    <update id="updateAdFlat" parameterType="AdFlat">
        update ad_flat
        <trim prefix="SET" suffixOverrides=",">
            <if test="plotid != null and plotid != ''">plotId = #{plotid},</if>
            <if test="name != null">name = #{name},</if>
            <if test="remake != null">remake = #{remake},</if>
            <if test="createdate != null">createDate = #{createdate},</if>
            <if test="create != null">create = #{create},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdFlatById" parameterType="String">
        delete from ad_flat where id = #{id}
    </delete>

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