<?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.project.business.mapper.contract.TqContractLiftSnMapper">
    
    <resultMap type="TqContractLiftSn" id="TqContractLiftSnResult">
        <result property="id"    column="id"    />
        <result property="sn"    column="sn"    />
        <result property="snEnterTime"    column="sn_enter_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
        <result property="permissionChar"    column="permission_char"    />
    </resultMap>

    <sql id="selectTqContractLiftSnVo">
        select id, sn, sn_enter_time, del_flag, create_time, create_by, update_time, update_by, remark, permission_char from tq_contract_lift_sn
    </sql>

    <select id="selectTqContractLiftSnList"  resultMap="TqContractLiftSnResult">
        <include refid="selectTqContractLiftSnVo"/>
        <where>
            del_flag = '0'
            <if test="sn != null  and sn != ''"> and sn = #{sn}</if>
            <if test="snEnterTime != null and snEnterTime.length == 2"> and sn_enter_time
                <foreach collection="snEnterTime" item="item" open="between " separator=" and " >
                    #{item}
                </foreach>
            </if>
            <if test="snEnterTime != null and snEnterTime.length == 2"> and sn_enter_time
                <foreach collection="snEnterTime" item="item" open="between " separator=" and " >
                    #{item}
                </foreach>
            </if>
            <if test="snEnterTime != null and snEnterTime.length == 1"> and sn_enter_time =
                <foreach collection="snEnterTime" item="item" >
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
    
    <select id="selectTqContractLiftSnById" parameterType="Long" resultMap="TqContractLiftSnResult">
        <include refid="selectTqContractLiftSnVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTqContractLiftSn" parameterType="TqContractLiftSn">
        insert into tq_contract_lift_sn
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="sn != null">sn,</if>
            <if test="snEnterTime != null">sn_enter_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
            <if test="permissionChar != null">permission_char,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="sn != null">#{sn},</if>
            <if test="snEnterTime != null">#{snEnterTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
            <if test="permissionChar != null">#{permissionChar},</if>
         </trim>
    </insert>

    <update id="updateTqContractLiftSn" parameterType="TqContractLiftSn">
        update tq_contract_lift_sn
        <trim prefix="SET" suffixOverrides=",">
            <if test="sn != null">sn = #{sn},</if>
            <if test="snEnterTime != null">sn_enter_time = #{snEnterTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="permissionChar != null">permission_char = #{permissionChar},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateTqContractLiftSnByEnterTime" parameterType="TqContractLiftSn">
        update tq_contract_lift_sn
        <trim prefix="SET" suffixOverrides=",">
            <if test="sn != null">sn = #{sn},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="permissionChar != null">permission_char = #{permissionChar},</if>
        </trim>
        where sn_enter_time = #{snEnterTime}
    </update>

    <delete id="deleteTqContractLiftSnById" parameterType="Long">
        delete from tq_contract_lift_sn where id = #{id}
    </delete>

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