<?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.system.mapper.IntegralOrderLogMapper">
    
    <resultMap type="IntegralOrderLog" id="IntegralOrderLogResult">
        <result property="id"    column="id"    />
        <result property="oid"    column="oid"    />
        <result property="orderId"    column="order_id"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="type"    column="type"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
    </resultMap>

    <sql id="selectIntegralOrderLogVo">
        select id, oid, order_id, title, content, type, created_at, updated_at from integral_order_log
    </sql>

    <select id="selectIntegralOrderLogList" parameterType="IntegralOrderLog" resultMap="IntegralOrderLogResult">
        <include refid="selectIntegralOrderLogVo"/>
        <where>  
            <if test="oid != null "> and oid = #{oid}</if>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
        </where>
    </select>
    
    <select id="selectIntegralOrderLogById" parameterType="Long" resultMap="IntegralOrderLogResult">
        <include refid="selectIntegralOrderLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertIntegralOrderLog" parameterType="IntegralOrderLog" useGeneratedKeys="true" keyProperty="id">
        insert into integral_order_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="oid != null">oid,</if>
            <if test="orderId != null and orderId != ''">order_id,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="type != null">type,</if>
              created_at,
              updated_at
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="oid != null">#{oid},</if>
            <if test="orderId != null and orderId != ''">#{orderId},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="type != null">#{type},</if>
    NOW(),
            NOW()
         </trim>
    </insert>

    <update id="updateIntegralOrderLog" parameterType="IntegralOrderLog">
        update integral_order_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="oid != null">oid = #{oid},</if>
            <if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="type != null">type = #{type},</if>
            updated_at=NOW()
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteIntegralOrderLogById" parameterType="Long">
        delete from integral_order_log where id = #{id}
    </delete>

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