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

    <resultMap type="QuoteLog" id="QuoteLogResult">
        <result property="id" column="id"/>
        <result property="wangwang" column="wangwang"/>
        <result property="userId" column="user_id"/>
        <result property="ip" column="ip"/>
        <result property="os" column="os"/>
        <result property="productId" column="product_id"/>
        <result property="price" column="price"/>
        <result property="content" column="content"/>
        <result property="updateContent" column="update_content"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectQuoteLogVo">
        select id,
               wangwang,
               user_id,
               ip,
               os,
               price,
               product_id,
               content,
               update_content,
               create_by,
               create_time,
               update_by,
               update_time
        from quote_log
    </sql>

    <select id="selectQuoteLogList" parameterType="QuoteLog" resultMap="QuoteLogResult">
        <include refid="selectQuoteLogVo"/>
        <where>
            <if test="wangwang != null  and wangwang != ''">and wangwang like concat('%',#{wangwang},'%')</if>
            <if test="ip != null  and ip != ''">and ip = like concat('%',#{ip},'%')</if>
            <if test="os != null  and os != ''">and os = #{os}</if>
        </where>
    </select>

    <select id="selectQuoteLogById" parameterType="Long" resultMap="QuoteLogResult">
        <include refid="selectQuoteLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertQuoteLog" parameterType="QuoteLog">
        insert into quote_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="wangwang != null">wangwang,</if>
            <if test="userId != null">user_id,</if>
            <if test="ip != null">ip,</if>
            <if test="os != null">os,</if>
            <if test="price != null">price,</if>
            <if test="productId != null">product_id,</if>
            <if test="content != null">content,</if>
            <if test="updateContent != null">update_content,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            create_time,update_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="wangwang != null">#{wangwang},</if>
            <if test="userId != null">#{userId},</if>
            <if test="ip != null">#{ip},</if>
            <if test="os != null">#{os},</if>
            <if test="price != null">#{price},</if>
            <if test="productId != null">#{productId},</if>
            <if test="content != null">#{content},</if>
            <if test="updateContent != null">#{updateContent},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            sysdate(),sysdate()
        </trim>
    </insert>

    <update id="updateQuoteLog" parameterType="QuoteLog">
        update quote_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="updateContent != null">update_content = #{updateContent},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = sysdate(),</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQuoteLogById" parameterType="Long">
        delete
        from quote_log
        where id = #{id}
    </delete>

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