<?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.srs.routine.mapper.RtFuResourceMapper">

    <resultMap type="RtFuResource" id="RtFuResourceResult">
        <result property="resId"    column="res_id"    />
        <result property="roNo"    column="ro_no"    />
        <result property="resNo"    column="res_no"    />
        <result property="resType"    column="res_type"    />
        <result property="resMainNo"    column="res_main_no"    />
        <result property="resName"    column="res_name"    />
        <result property="resPath"    column="res_path"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectRtFuResourceVo">
        select res_id, ro_no, res_no, res_type, res_main_no, res_name, res_path, status, del_flag, create_by, create_time, update_by, update_time
        from rt_fu_resource
    </sql>

    <select id="selectRtFuResourceList" parameterType="RtFuResource" resultMap="RtFuResourceResult">
        <include refid="selectRtFuResourceVo"/>
        <where>
            <if test="roNo != null  and roNo != ''"> and ro_no = #{roNo}</if>
            <if test="resNo != null  and resNo != ''"> and res_no = #{resNo}</if>
            <if test="resType != null  and resType != ''"> and res_type = #{resType}</if>
            <if test="resMainNo != null  and resMainNo != ''"> and res_main_no = #{resMainNo}</if>
            <if test="resName != null  and resName != ''"> and res_name like concat('%', #{resName}, '%')</if>
            <if test="resPath != null  and resPath != ''"> and res_path = #{resPath}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="getRtFuresLIst" resultType="com.srs.routine.domain.vo.RtFuResourceVo">
        <include refid="selectRtFuResourceVo"/>
        <where>
            <if test="roNo != null  and roNo != ''"> and ro_no = #{roNo}</if>
            <if test="resNo != null  and resNo != ''"> and res_no = #{resNo}</if>
            <if test="resType != null  and resType != ''"> and res_type = #{resType}</if>
            <if test="resMainNo != null  and resMainNo != ''"> and res_main_no = #{resMainNo}</if>
            <if test="resName != null  and resName != ''"> and res_name like concat('%', #{resName}, '%')</if>
            <if test="resPath != null  and resPath != ''"> and res_path = #{resPath}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectRtFuResourceLists" resultType="com.srs.routine.domain.vo.RtFuResourceVo">
        <include refid="selectRtFuResourceVo"/>
        <where>
            <if test="roNo != null  and roNo != ''"> and ro_no = #{roNo}</if>
            <if test="resNo != null  and resNo != ''"> and res_no = #{resNo}</if>
            <if test="resType != null  and resType != ''"> and res_type = #{resType}</if>
            <if test="resMainNo != null  and resMainNo != ''"> and res_main_no = #{resMainNo}</if>
            <if test="resName != null  and resName != ''"> and res_name like concat('%', #{resName}, '%')</if>
            <if test="resPath != null  and resPath != ''"> and res_path = #{resPath}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectRtFuResourceByResId" parameterType="Long" resultMap="RtFuResourceResult">
        <include refid="selectRtFuResourceVo"/>
        where res_id = #{resId}
    </select>
    <select id="selectRtFuResourceByMainNo" parameterType="String" resultMap="RtFuResourceResult">
        <include refid="selectRtFuResourceVo"/>
        where res_main_no = #{resMainNo}
    </select>

    <insert id="insertRes" parameterType="com.srs.routine.domain.vo.RtFuResourceVo">
        insert into rt_fu_resource
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="resId != null">res_id,</if>
            <if test="roNo != null">ro_no,</if>
            <if test="resNo != null">res_no,</if>
            <if test="resType != null">res_type,</if>
            <if test="resMainNo != null">res_main_no,</if>
            <if test="resName != null">res_name,</if>
            <if test="resPath != null">res_path,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="resId != null">#{resId},</if>
            <if test="roNo != null">#{roNo},</if>
            <if test="resNo != null">#{resNo},</if>
            <if test="resType != null">#{resType},</if>
            <if test="resMainNo != null">#{resMainNo},</if>
            <if test="resName != null">#{resName},</if>
            <if test="resPath != null">#{resPath},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</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>
        </trim>
    </insert>

    <insert id="insertRtFuResource" parameterType="RtFuResource">
        insert into rt_fu_resource
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="resId != null">res_id,</if>
            <if test="roNo != null">ro_no,</if>
            <if test="resNo != null">res_no,</if>
            <if test="resType != null">res_type,</if>
            <if test="resMainNo != null">res_main_no,</if>
            <if test="resName != null">res_name,</if>
            <if test="resPath != null">res_path,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</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>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="resId != null">#{resId},</if>
            <if test="roNo != null">#{roNo},</if>
            <if test="resNo != null">#{resNo},</if>
            <if test="resType != null">#{resType},</if>
            <if test="resMainNo != null">#{resMainNo},</if>
            <if test="resName != null">#{resName},</if>
            <if test="resPath != null">#{resPath},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</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>
        </trim>
    </insert>


    <update id="updateRtFuResource" parameterType="RtFuResource">
        update rt_fu_resource
        <trim prefix="SET" suffixOverrides=",">
            <if test="roNo != null">ro_no = #{roNo},</if>
            <if test="resNo != null">res_no = #{resNo},</if>
            <if test="resType != null">res_type = #{resType},</if>
            <if test="resMainNo != null">res_main_no = #{resMainNo},</if>
            <if test="resName != null">res_name = #{resName},</if>
            <if test="resPath != null">res_path = #{resPath},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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>
        </trim>
        where res_id = #{resId}
    </update>
    <update id="updateAudit">
        update rt_fu_audit set au_status=#{auStatus} where re_no = #{reNo}
    </update>

    <delete id="deleteRtFuResourceByResId" parameterType="Long">
        delete from rt_fu_resource where res_id = #{resId}
    </delete>

    <delete id="deleteRtFuResourceByResManNo" parameterType="String">
        delete from rt_fu_resource where res_main_no = #{resMainNo}
    </delete>

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