<?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.AdManagementMapper">
    
    <resultMap type="AdManagement" id="AdManagementResult">
        <result property="id"    column="id"    />
        <result property="plotid"    column="plotid"    />
        <result property="flatid"    column="flatid"    />
        <result property="floor"    column="floor"    />
        <result property="area"    column="area"    />
        <result property="status"    column="status"    />
        <result property="rent"    column="rent"    />
        <result property="renttype"    column="rentType"    />
        <result property="addtime"    column="addtime"    />
        <result property="isadd"    column="iSadd"    />
    </resultMap>

    <sql id="selectAdManagementVo">
        select id, plotid, flatid, floor, area, status, rent, rentType, addtime, iSadd from ad_management
    </sql>

    <select id="selectAdManagementList" parameterType="AdManagement" resultMap="AdManagementResult">
        <include refid="selectAdManagementVo"/>
        <where>  
            <if test="plotid != null  and plotid != ''"> and plotid = #{plotid}</if>
            <if test="flatid != null  and flatid != ''"> and flatid = #{flatid}</if>
            <if test="floor != null  and floor != ''"> and floor = #{floor}</if>
            <if test="area != null  and area != ''"> and area = #{area}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="rent != null  and rent != ''"> and rent = #{rent}</if>
            <if test="renttype != null  and renttype != ''"> and rentType = #{renttype}</if>
            <if test="addtime != null "> and addtime = #{addtime}</if>
            <if test="isadd != null  and isadd != ''"> and iSadd = #{isadd}</if>
        </where>
    </select>
    
    <select id="selectAdManagementById" parameterType="Long" resultMap="AdManagementResult">
        <include refid="selectAdManagementVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAdManagement" parameterType="AdManagement" useGeneratedKeys="true" keyProperty="id">
        insert into ad_management
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="plotid != null and plotid != ''">plotid,</if>
            <if test="flatid != null and flatid != ''">flatid,</if>
            <if test="floor != null">floor,</if>
            <if test="area != null">area,</if>
            <if test="status != null">status,</if>
            <if test="rent != null">rent,</if>
            <if test="renttype != null">rentType,</if>
            <if test="addtime != null">addtime,</if>
            <if test="isadd != null">iSadd,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="plotid != null and plotid != ''">#{plotid},</if>
            <if test="flatid != null and flatid != ''">#{flatid},</if>
            <if test="floor != null">#{floor},</if>
            <if test="area != null">#{area},</if>
            <if test="status != null">#{status},</if>
            <if test="rent != null">#{rent},</if>
            <if test="renttype != null">#{renttype},</if>
            <if test="addtime != null">#{addtime},</if>
            <if test="isadd != null">#{isadd},</if>
         </trim>
    </insert>

    <update id="updateAdManagement" parameterType="AdManagement">
        update ad_management
        <trim prefix="SET" suffixOverrides=",">
            <if test="plotid != null and plotid != ''">plotid = #{plotid},</if>
            <if test="flatid != null and flatid != ''">flatid = #{flatid},</if>
            <if test="floor != null">floor = #{floor},</if>
            <if test="area != null">area = #{area},</if>
            <if test="status != null">status = #{status},</if>
            <if test="rent != null">rent = #{rent},</if>
            <if test="renttype != null">rentType = #{renttype},</if>
            <if test="addtime != null">addtime = #{addtime},</if>
            <if test="isadd != null">iSadd = #{isadd},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdManagementById" parameterType="Long">
        delete from ad_management where id = #{id}
    </delete>

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