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

    <resultMap type="AdPlot" id="AdPlotResult">
        <result property="id"    column="id"    />
        <result property="plotname"    column="plotName"    />
        <result property="updata"    column="updata"    />
        <result property="added"    column="added"    />
    </resultMap>

    <sql id="selectAdPlotVo">
        select id, plotName, updata, added from ad_plot
    </sql>

    <select id="selectAdPlotList" parameterType="AdPlot" resultMap="AdPlotResult">
        <include refid="selectAdPlotVo"/>
        <where>
            <if test="plotname != null  and plotname != ''"> and plotName like concat('%', #{plotname}, '%')</if>
            <if test="updata != null "> and updata = #{updata}</if>
            <if test="added != null "> and added = #{added}</if>
        </where>
    </select>

    <select id="selectAdPlotById" parameterType="String" resultMap="AdPlotResult">
        <include refid="selectAdPlotVo"/>
        where id = #{id}
    </select>

    <insert id="insertAdPlot" parameterType="AdPlot">
        insert into ad_plot
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="plotname != null">plotName,</if>
            <if test="updata != null">updata,</if>
            <if test="added != null">added,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="plotname != null">#{plotname},</if>
            <if test="updata != null">#{updata},</if>
            <if test="added != null">#{added},</if>
        </trim>
    </insert>

    <update id="updateAdPlot" parameterType="AdPlot">
        update ad_plot
        <trim prefix="SET" suffixOverrides=",">
            <if test="plotname != null">plotName = #{plotname},</if>
            <if test="updata != null">updata = #{updata},</if>
            <if test="added != null">added = #{added},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdPlotById" parameterType="String">
        delete from ad_plot where id = #{id}
    </delete>

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