<?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.MallPurchaseNotesMapper">
    
    <resultMap type="MallPurchaseNotes" id="MallPurchaseNotesResult">
        <result property="id"    column="id"    />
        <result property="content"    column="content"    />
        <result property="createAt"    column="create_at"    />
        <result property="updateAt"    column="update_at"    />
    </resultMap>

    <sql id="selectMallPurchaseNotesVo">
        select id, content, create_at, update_at from mall_purchase_notes
    </sql>

    <select id="selectMallPurchaseNotesList" parameterType="MallPurchaseNotes" resultMap="MallPurchaseNotesResult">
        <include refid="selectMallPurchaseNotesVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="createAt != null  and createAt != ''"> and create_at = #{createAt}</if>
            <if test="updateAt != null  and updateAt != ''"> and update_at = #{updateAt}</if>
        </where>
    </select>
    
    <select id="selectMallPurchaseNotesById" parameterType="Integer" resultMap="MallPurchaseNotesResult">
        <include refid="selectMallPurchaseNotesVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMallPurchaseNotes" parameterType="MallPurchaseNotes" useGeneratedKeys="true" keyProperty="id">
        insert into mall_purchase_notes
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="content != null">content,</if>
            <if test="createAt != null">create_at,</if>
            <if test="updateAt != null">update_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="content != null">#{content},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="updateAt != null">#{updateAt},</if>
         </trim>
    </insert>

    <update id="updateMallPurchaseNotes" parameterType="MallPurchaseNotes">
        update mall_purchase_notes
        <trim prefix="SET" suffixOverrides=",">
            <if test="content != null">content = #{content},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="updateAt != null">update_at = #{updateAt},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallPurchaseNotesById" parameterType="Integer">
        delete from mall_purchase_notes where id = #{id}
    </delete>

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