<?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.plant.mapper.TCanteenCardMonthMapper">
    
    <resultMap type="TCanteenCardMonth" id="TCanteenCardMonthResult">
        <result property="id"    column="id"    />
        <result property="cardId"    column="card_id"    />
        <result property="swipYear"    column="swip_year"    />
        <result property="swipMonth"    column="swip_month"    />
        <result property="swipNum"    column="swip_num"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTCanteenCardMonthVo">
        select id, card_id, swip_year, swip_month, swip_num, status, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, remarks from t_canteen_card_month
    </sql>

    <select id="selectTCanteenCardMonthList" parameterType="TCanteenCardMonth" resultMap="TCanteenCardMonthResult">
        <include refid="selectTCanteenCardMonthVo"/>
        <where>  
            <if test="cardId != null "> and card_id = #{cardId}</if>
            <if test="swipYear != null  and swipYear != ''"> and swip_year = #{swipYear}</if>
            <if test="swipMonth != null  and swipMonth != ''"> and swip_month = #{swipMonth}</if>
            <if test="swipNum != null "> and swip_num = #{swipNum}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createrCode != null "> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null "> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTCanteenCardMonthById" parameterType="Long" resultMap="TCanteenCardMonthResult">
        <include refid="selectTCanteenCardMonthVo"/>
        where id = #{id}
    </select>

    <insert id="insertTCanteenCardMonth" parameterType="TCanteenCardMonth" useGeneratedKeys="true" keyProperty="id">
        insert into t_canteen_card_month
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cardId != null">card_id,</if>
            <if test="swipYear != null">swip_year,</if>
            <if test="swipMonth != null">swip_month,</if>
            <if test="swipNum != null">swip_num,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cardId != null">#{cardId},</if>
            <if test="swipYear != null">#{swipYear},</if>
            <if test="swipMonth != null">#{swipMonth},</if>
            <if test="swipNum != null">#{swipNum},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTCanteenCardMonth" parameterType="TCanteenCardMonth">
        update t_canteen_card_month
        <trim prefix="SET" suffixOverrides=",">
            <if test="cardId != null">card_id = #{cardId},</if>
            <if test="swipYear != null">swip_year = #{swipYear},</if>
            <if test="swipMonth != null">swip_month = #{swipMonth},</if>
            <if test="swipNum != null">swip_num = #{swipNum},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTCanteenCardMonthById" parameterType="Long">
        delete from t_canteen_card_month where id = #{id}
    </delete>

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