<?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.PosCollectMapper">
    
    <resultMap type="PosCollect" id="PosCollectResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="mdId"    column="md_id"    />
        <result property="cretim"    column="cretim"    />
    </resultMap>

    <sql id="selectPosCollectVo">
        select id, user_id, md_id, cretim from pos_collect
    </sql>

    <select id="selectPosCollectList" parameterType="PosCollect" resultMap="PosCollectResult">
        <include refid="selectPosCollectVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="mdId != null "> and md_id = #{mdId}</if>
        </where>
        order by id desc
    </select>
    
    <select id="selectPosCollectById" parameterType="Long" resultMap="PosCollectResult">
        <include refid="selectPosCollectVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPosCollect" parameterType="PosCollect" useGeneratedKeys="true" keyProperty="id">
        insert into pos_collect
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="mdId != null">md_id,</if>
            <if test="cretim != null">cretim,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="mdId != null">#{mdId},</if>
            <if test="cretim != null">#{cretim},</if>
         </trim>
    </insert>

    <update id="updatePosCollect" parameterType="PosCollect">
        update pos_collect
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="mdId != null">md_id = #{mdId},</if>
            <if test="cretim != null">cretim = #{cretim},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePosCollectById" parameterType="Long">
        delete from pos_collect where id = #{id}
    </delete>

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