<?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.PosMarginMapper">
    
    <resultMap type="PosMargin" id="PosMarginResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="amount"    column="amount"    />
        <result property="illustrate"    column="illustrate"    />
    </resultMap>

    <sql id="selectPosMarginVo">
        select id, type, amount, illustrate from pos_margin
    </sql>

    <select id="selectPosMarginList" parameterType="PosMargin" resultMap="PosMarginResult">
        <include refid="selectPosMarginVo"/>
        <where>  
            <if test="type != null "> and type = #{type}</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="illustrate != null  and illustrate != ''"> and illustrate = #{illustrate}</if>
        </where>
    </select>
    
    <select id="selectPosMarginById" parameterType="Long" resultMap="PosMarginResult">
        <include refid="selectPosMarginVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPosMargin" parameterType="PosMargin" useGeneratedKeys="true" keyProperty="id">
        insert into pos_margin
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null">type,</if>
            <if test="amount != null">amount,</if>
            <if test="illustrate != null">illustrate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null">#{type},</if>
            <if test="amount != null">#{amount},</if>
            <if test="illustrate != null">#{illustrate},</if>
         </trim>
    </insert>

    <update id="updatePosMargin" parameterType="PosMargin">
        update pos_margin
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="illustrate != null">illustrate = #{illustrate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePosMarginById" parameterType="Long">
        delete from pos_margin where id = #{id}
    </delete>

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