<?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.zehong.system.mapper.BaseExportTempMapper">
    
    <resultMap type="BaseExportTemp" id="BaseExportTempResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="code"    column="code"    />
        <result property="tempFileName"    column="temp_file_name"    />
        <result property="prefix"    column="prefix"    />
        <result property="fileStoreDir"    column="file_store_dir"    />
        <result property="fullPath"    column="full_path"    />
        <result property="content"    column="content"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="createUserName"    column="create_user_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateUserId"    column="update_user_id"    />
        <result property="updateUserName"    column="update_user_name"    />
        <result property="updateTime"    column="update_time"    />
        <result property="enableFlag"    column="enable_flag"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="remark"    column="remark"    />
        <result property="spareParam1"    column="spare_param_1"    />
        <result property="spareParam2"    column="spare_param_2"    />
        <result property="spareParam3"    column="spare_param_3"    />
        <result property="spareParam4"    column="spare_param_4"    />
        <result property="spareParam5"    column="spare_param_5"    />
    </resultMap>

    <sql id="selectBaseExportTempVo">
        select id, name, code, temp_file_name, prefix, file_store_dir, full_path, content, create_user_id, create_user_name, create_time, update_user_id, update_user_name, update_time, enable_flag, delete_flag, remark, spare_param_1, spare_param_2, spare_param_3, spare_param_4, spare_param_5 from base_export_temp
    </sql>

    <select id="selectBaseExportTempList" parameterType="BaseExportTemp" resultMap="BaseExportTempResult">
        <include refid="selectBaseExportTempVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="tempFileName != null  and tempFileName != ''"> and temp_file_name like concat('%', #{tempFileName}, '%')</if>
            <if test="prefix != null  and prefix != ''"> and prefix = #{prefix}</if>
            <if test="fileStoreDir != null  and fileStoreDir != ''"> and file_store_dir = #{fileStoreDir}</if>
            <if test="fullPath != null  and fullPath != ''"> and full_path = #{fullPath}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="createUserName != null  and createUserName != ''"> and create_user_name like concat('%', #{createUserName}, '%')</if>
            <if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
            <if test="updateUserName != null  and updateUserName != ''"> and update_user_name like concat('%', #{updateUserName}, '%')</if>
            <if test="enableFlag != null  and enableFlag != ''"> and enable_flag = #{enableFlag}</if>
            <if test="deleteFlag != null  and deleteFlag != ''"> and delete_flag = #{deleteFlag}</if>
            <if test="spareParam1 != null  and spareParam1 != ''"> and spare_param_1 = #{spareParam1}</if>
            <if test="spareParam2 != null  and spareParam2 != ''"> and spare_param_2 = #{spareParam2}</if>
            <if test="spareParam3 != null  and spareParam3 != ''"> and spare_param_3 = #{spareParam3}</if>
            <if test="spareParam4 != null  and spareParam4 != ''"> and spare_param_4 = #{spareParam4}</if>
            <if test="spareParam5 != null  and spareParam5 != ''"> and spare_param_5 = #{spareParam5}</if>
        </where>
    </select>
    
    <select id="selectBaseExportTempById" parameterType="Long" resultMap="BaseExportTempResult">
        <include refid="selectBaseExportTempVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBaseExportTemp" parameterType="BaseExportTemp">
        insert into base_export_temp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="code != null">code,</if>
            <if test="tempFileName != null">temp_file_name,</if>
            <if test="prefix != null">prefix,</if>
            <if test="fileStoreDir != null">file_store_dir,</if>
            <if test="fullPath != null">full_path,</if>
            <if test="content != null">content,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="createUserName != null">create_user_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateUserId != null">update_user_id,</if>
            <if test="updateUserName != null">update_user_name,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="enableFlag != null">enable_flag,</if>
            <if test="deleteFlag != null">delete_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="spareParam1 != null">spare_param_1,</if>
            <if test="spareParam2 != null">spare_param_2,</if>
            <if test="spareParam3 != null">spare_param_3,</if>
            <if test="spareParam4 != null">spare_param_4,</if>
            <if test="spareParam5 != null">spare_param_5,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="code != null">#{code},</if>
            <if test="tempFileName != null">#{tempFileName},</if>
            <if test="prefix != null">#{prefix},</if>
            <if test="fileStoreDir != null">#{fileStoreDir},</if>
            <if test="fullPath != null">#{fullPath},</if>
            <if test="content != null">#{content},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="createUserName != null">#{createUserName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="updateUserName != null">#{updateUserName},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="enableFlag != null">#{enableFlag},</if>
            <if test="deleteFlag != null">#{deleteFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="spareParam1 != null">#{spareParam1},</if>
            <if test="spareParam2 != null">#{spareParam2},</if>
            <if test="spareParam3 != null">#{spareParam3},</if>
            <if test="spareParam4 != null">#{spareParam4},</if>
            <if test="spareParam5 != null">#{spareParam5},</if>
         </trim>
    </insert>

    <update id="updateBaseExportTemp" parameterType="BaseExportTemp">
        update base_export_temp
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="code != null">code = #{code},</if>
            <if test="tempFileName != null">temp_file_name = #{tempFileName},</if>
            <if test="prefix != null">prefix = #{prefix},</if>
            <if test="fileStoreDir != null">file_store_dir = #{fileStoreDir},</if>
            <if test="fullPath != null">full_path = #{fullPath},</if>
            <if test="content != null">content = #{content},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="createUserName != null">create_user_name = #{createUserName},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateUserId != null">update_user_id = #{updateUserId},</if>
            <if test="updateUserName != null">update_user_name = #{updateUserName},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="enableFlag != null">enable_flag = #{enableFlag},</if>
            <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="spareParam1 != null">spare_param_1 = #{spareParam1},</if>
            <if test="spareParam2 != null">spare_param_2 = #{spareParam2},</if>
            <if test="spareParam3 != null">spare_param_3 = #{spareParam3},</if>
            <if test="spareParam4 != null">spare_param_4 = #{spareParam4},</if>
            <if test="spareParam5 != null">spare_param_5 = #{spareParam5},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBaseExportTempById" parameterType="Long">
        delete from base_export_temp where id = #{id}
    </delete>

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

    <!-- 逻辑删除 -->
    <update id="setDeleteById">
        update base_export_temp set delete_flag="Y",update_time=sysdate(),update_user_id=#{operId},update_user_name=#{operName} where id = #{id}
    </update>

    <!-- 逻辑删除 -->
    <update id="setDeleteByIds">
        update base_export_temp set delete_flag="Y",update_time=sysdate(),update_user_id=#{operId},update_user_name=#{operName} where id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <!-- **************************自定义SQL区域************************** -->
    <!-- 根据code查询参数 -->
    <select id="selectParamByCode" parameterType="string" resultMap="BaseExportTempResult">
        <include refid="selectBaseExportTempVo"/>
        where code = #{code}
    </select>
    <!-- 根据模板的存放路径查询唯一的模板信息 -->
    <select id="selectSignleByFullPath" parameterType="string" resultMap="BaseExportTempResult">
        <include refid="selectBaseExportTempVo"/>
        where full_path = #{fullPath}
    </select>
</mapper>