<?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.goldenwater.slaj.hidd.mapper.BisOrgMonRepRevoMapper">
    <resultMap type="com.goldenwater.slaj.hidd.domain.BisOrgMonRepRevo" id="BisOrgMonRepRevoResult">
        <result property="guid" column="guid"/>
        <result property="repGuid" column="rep_guid"/>
        <result property="revoOrgGuid" column="revo_org_guid"/>
        <result property="veriOrgGuid" column="veri_org_guid"/>
        <result property="revoReas" column="revo_reas"/>
        <result property="repResc" column="rep_resc"/>
        <result property="returnDesc" column="return_desc"/>
        <result property="revoVeriOpin" column="revo_veri_opin"/>
        <result property="revoVeriResu" column="revo_veri_resu"/>
        <result property="note" column="note"/>
        <result property="collTime" column="coll_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="recPers" column="rec_pers"/>
    </resultMap>
    <sql id="selectBisOrgMonRepRevoVo">
        select guid, rep_guid, revo_org_guid, veri_org_guid, revo_reas, rep_resc, return_desc,
               revo_veri_opin, revo_veri_resu, note, coll_time, upd_time, rec_pers
        from bis_org_mon_rep_revo
    </sql>
    <select id="selectBisOrgMonRepRevoByGuid" parameterType="String" resultMap="BisOrgMonRepRevoResult">
        <include refid="selectBisOrgMonRepRevoVo"/>
        where guid = #{guid}
    </select>
    <resultMap type="java.util.Map" id="BisOrgMonRepRevoListResult">
        <result property="guid" column="guid"/>
        <result property="repGuid" column="rep_guid"/>
        <result property="revoOrgGuid" column="revo_org_guid"/>
        <result property="repOrgName" column="rep_org_name"/>
        <result property="repTime" column="rep_time"/>
        <result property="reportDesc" column="report_desc"/>
        <result property="revocDesc" column="revoc_desc"/>
        <result property="revoReas" column="revo_reas"/>
        <result property="revoVeriResu" column="revo_veri_resu"/>
        <result property="collTime" column="coll_time"/>
    </resultMap>
    <select id="selectBisOrgMonRepRevoList" parameterType="com.goldenwater.slaj.hidd.domain.BisOrgMonRepRevo" resultMap="BisOrgMonRepRevoListResult">
        SELECT r.guid, r.rep_guid, r.revo_org_guid,
               ao.org_name AS rep_org_name,
               p.rep_time,
               p.note AS report_desc,
               r.revo_reas AS revoc_desc,
               r.revo_reas,
               r.revo_veri_resu,
               r.coll_time
        FROM bis_org_mon_rep_revo r
        LEFT JOIN bis_org_mon_rep_peri p ON r.rep_guid = p.guid
        LEFT JOIN att_org_base ao ON p.rep_org_guid = ao.guid
        <where>
            <if test="repGuid != null and repGuid != ''">AND r.rep_guid = #{repGuid}</if>
            <if test="revoOrgGuid != null and revoOrgGuid != ''">AND r.revo_org_guid = #{revoOrgGuid}</if>
        </where>
        ORDER BY r.coll_time DESC
    </select>
    <insert id="insertBisOrgMonRepRevo" parameterType="com.goldenwater.slaj.hidd.domain.BisOrgMonRepRevo">
        insert into bis_org_mon_rep_revo (guid, rep_guid, revo_org_guid, veri_org_guid, revo_reas, rep_resc, return_desc, revo_veri_opin, revo_veri_resu, note, coll_time, upd_time, rec_pers)
        values (#{guid}, #{repGuid}, #{revoOrgGuid}, #{veriOrgGuid}, #{revoReas}, #{repResc}, #{returnDesc}, #{revoVeriOpin}, #{revoVeriResu}, #{note}, #{collTime}, #{updTime}, #{recPers}, )
    </insert>
    <update id="updateBisOrgMonRepRevo" parameterType="com.goldenwater.slaj.hidd.domain.BisOrgMonRepRevo">
        update bis_org_mon_rep_revo
        <set>
            <if test="repGuid != null">rep_guid = #{repGuid},</if>
            <if test="revoOrgGuid != null">revo_org_guid = #{revoOrgGuid},</if>
            <if test="veriOrgGuid != null">veri_org_guid = #{veriOrgGuid},</if>
            <if test="revoReas != null">revo_reas = #{revoReas},</if>
            <if test="repResc != null">rep_resc = #{repResc},</if>
            <if test="returnDesc != null">return_desc = #{returnDesc},</if>
            <if test="revoVeriOpin != null">revo_veri_opin = #{revoVeriOpin},</if>
            <if test="revoVeriResu != null">revo_veri_resu = #{revoVeriResu},</if>
            <if test="note != null">note = #{note},</if>
            <if test="collTime != null">coll_time = #{collTime},</if>
            <if test="updTime != null">upd_time = #{updTime},</if>
            <if test="recPers != null">rec_pers = #{recPers},</if>
        </set>
        where guid = #{guid}
    </update>
    <delete id="deleteBisOrgMonRepRevoByGuid" parameterType="String">
        delete from bis_org_mon_rep_revo where guid = #{guid}
    </delete>
    <delete id="deleteBisOrgMonRepRevoByGuids" parameterType="String">
        delete from bis_org_mon_rep_revo where guid in
        <foreach item="guid" collection="array" open="(" separator="," close=")">
            #{guid}
        </foreach>
    </delete>
</mapper>
