<?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.szxc.mapper.SzxcOffRecardMapper">
    
    <resultMap type="SzxcOffRecard" id="SzxcOffRecardResult">
        <result property="id"    column="id"    />
        <result property="jmId"    column="jm_id"    />
        <result property="name"    column="name"    />
        <result property="cardId"    column="card_id"    />
        <result property="reason"    column="reason"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcOffRecardVo">
        select id, jm_id, name, card_id, reason, remark, create_by, create_time, update_by, update_time, user_id from szxc_off_recard
    </sql>

    <select id="selectSzxcOffRecardList" parameterType="SzxcOffRecard" resultMap="SzxcOffRecardResult">
        <include refid="selectSzxcOffRecardVo"/>
        <where>  
            <if test="jmId != null "> and jm_id = #{jmId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="cardId != null  and cardId != ''"> and card_id = #{cardId}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>
    
    <select id="selectSzxcOffRecardById" parameterType="Long" resultMap="SzxcOffRecardResult">
        <include refid="selectSzxcOffRecardVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSzxcOffRecard" parameterType="SzxcOffRecard" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_off_recard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jmId != null">jm_id,</if>
            <if test="name != null">name,</if>
            <if test="cardId != null">card_id,</if>
            <if test="reason != null">reason,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="userId != null">user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jmId != null">#{jmId},</if>
            <if test="name != null">#{name},</if>
            <if test="cardId != null">#{cardId},</if>
            <if test="reason != null">#{reason},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="userId != null">#{userId},</if>
         </trim>
    </insert>

    <update id="updateSzxcOffRecard" parameterType="SzxcOffRecard">
        update szxc_off_recard
        <trim prefix="SET" suffixOverrides=",">
            <if test="jmId != null">jm_id = #{jmId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="cardId != null">card_id = #{cardId},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcOffRecardById" parameterType="Long">
        delete from szxc_off_recard where id = #{id}
    </delete>

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