<?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.mall.mapper.DemandReportMapper">
    <resultMap type="com.ruoyi.mall.domain.DemandReport" id="DemandReportResult">
        <result property="id" column="id"/>
        <result property="productTitle" column="product_title"/>
        <result property="demand" column="demand"/>
        <result property="remark" column="remark"/>
        <result property="productImages" column="product_images"/>
        <result property="uploader" column="uploader"/>
        <result property="creatTime" column="creat_time"/>
        <result property="uploadername" column="uploadername"/>
        <result property="phone" column="phone"/>
    </resultMap>
    <sql id="selectDemandReportVo">
        select id, product_title, demand, remark, product_images, uploader, creat_time,uploadername,phone
        from demand_report
    </sql>

    <select id="selectDemandReportList" parameterType="DemandReport" resultMap="DemandReportResult">
        <include refid="selectDemandReportVo"/>
        <where>
            <if test="productTitle != null  and productTitle != ''">
                and product_title = #{productTitle}
            </if>
            <if test="demand != null  and demand != ''">
                and demand = #{demand}
            </if>
            <if test="productImages != null  and productImages != ''">
                and product_images = #{productImages}
            </if>
            <if test="uploader != null  and uploader != ''">
                and uploader = #{uploader}
            </if>
            <if test="creatTime != null ">
                and creat_time = #{creatTime}
            </if>
            <if test="uploadername != null  and uploadername != ''">
                and uploadername = #{uploadername}
            </if>
            <if test="phone != null  and phone != ''">
                and phone = #{phone}
            </if>
        </where>
        order by creat_time desc
    </select>

    <select id="selectDemandReportById" parameterType="Long" resultMap="DemandReportResult">
        <include refid="selectDemandReportVo"/>
        where id = #{id}
    </select>

    <insert id="insertDemandReport" parameterType="com.ruoyi.mall.domain.DemandReport">
        insert into demand_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="productTitle != null">
                product_title,
            </if>
            <if test="demand != null">
                demand,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="productImages != null">
                product_images,
            </if>
            <if test="uploader != null">
                uploader,
            </if>
            <if test="creatTime != null">
                creat_time,
            </if>
            <if test="uploadername != null">
                uploadername,
            </if>
            <if test="phone != null">
                phone,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="productTitle != null">
                #{productTitle},
            </if>
            <if test="demand != null">
                #{demand},
            </if>
            <if test="remark != null">
                #{remark},
            </if>
            <if test="productImages != null">
                #{productImages},
            </if>
            <if test="uploader != null">
                #{uploader},
            </if>
            <if test="creatTime != null">
                #{creatTime},
            </if>
            <if test="uploadername != null">
                #{uploadername},
            </if>
            <if test="phone != null">
                #{phone},
            </if>
        </trim>
    </insert>

    <update id="updateDemandReport" parameterType="DemandReport">
        update demand_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="productTitle != null">
                product_title = #{productTitle},
            </if>
            <if test="demand != null">
                demand = #{demand},
            </if>
            <if test="remark != null">
                remark = #{remark},
            </if>
            <if test="productImages != null">
                product_images = #{productImages},
            </if>
            <if test="uploader != null">
                uploader = #{uploader},
            </if>
            <if test="creatTime != null">
                creat_time = #{creatTime},
            </if>
            <if test="uploadername != null">
                uploadername = #{uploadername},
            </if>
            <if test="phone != null">
                phone = #{phone},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDemandReportById" parameterType="Long">
        delete
        from demand_report
        where id = #{id}
    </delete>

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