CreditExceptionApplyMapper.xml 12.8 KB
<?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.credit.cy.business.mapper.CreditExceptionApplyMapper">
    
    <resultMap type="CreditExceptionApply" id="CreditExceptionApplyResult">
        <result property="id"    column="id"    />
        <result property="applyType"    column="apply_type"    />
        <result property="exceptionType"    column="exception_type"    />
        <result property="applyContent"    column="apply_content"    />
        <result property="applyFile"    column="apply_file"    />
        <result property="businessFile"    column="business_file"    />
        <result property="applyMemo"    column="apply_memo"    />
        <result property="reportDate"    column="report_date"    />
        <result property="reportDept"    column="report_dept"    />
        <result property="applyStatus"    column="apply_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>

    <resultMap id="CreditExceptionApplyCreditExceptionDataResult" type="CreditExceptionApply" extends="CreditExceptionApplyResult">
        <collection property="creditExceptionDataList" notNullColumn="sub_id" javaType="java.util.List" resultMap="CreditExceptionDataResult" />
    </resultMap>

    <resultMap type="CreditExceptionData" id="CreditExceptionDataResult">
        <result property="id"    column="sub_id"    />
        <result property="parentId"    column="sub_parent_id"    />
        <result property="recoverId"    column="sub_recover_id"    />
        <result property="dataType"    column="sub_data_type"    />
        <result property="counterpartName"    column="sub_counterpart_name"    />
        <result property="counterpartCode"    column="sub_counterpart_code"    />
        <result property="counterpartType"    column="sub_counterpart_type"    />
        <result property="decisionSequence"    column="sub_decision_sequence"    />
        <result property="decisionCreditCode"    column="sub_decision_credit_code"    />
        <result property="rightCounterpartName"    column="sub_right_counterpart_name"    />
        <result property="rightCounterpartCode"    column="sub_right_counterpart_code"    />
        <result property="rightCounterpartType"    column="sub_right_counterpart_type"    />
        <result property="rightDecisionSequence"    column="sub_right_decision_sequence"    />
        <result property="rightDecisionCreditCode"    column="sub_right_decision_credit_code"    />
        <result property="handleStatus"    column="sub_handle_status"    />
        <result property="applyTime"    column="sub_apply_time"    />
        <result property="applyUser"    column="sub_apply_user"    />
        <result property="applyDept"    column="sub_apply_dept"    />
        <result property="delFlag"    column="sub_del_flag"    />
        <result property="createBy"    column="sub_create_by"    />
        <result property="createTime"    column="sub_create_time"    />
        <result property="updateTime"    column="sub_update_time"    />
    </resultMap>

    <sql id="selectCreditExceptionApplyVo">
        select id, apply_type, exception_type, apply_content, apply_file, business_file, apply_memo, report_date, report_dept, apply_status, del_flag, create_by, create_time, update_by, update_time from credit_exception_apply
    </sql>

    <sql id="selectApplyJoinData">
        select a.id, a.apply_type, a.exception_type, a.apply_content, a.apply_file, a.business_file, a.apply_memo, a.report_date, a.report_dept, a.apply_status, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time,
               b.id as sub_id, b.parent_id as sub_parent_id, b.recover_id as sub_recover_id, b.data_type as sub_data_type, b.counterpart_name as sub_counterpart_name, b.counterpart_code as sub_counterpart_code, b.counterpart_type as sub_counterpart_type, b.decision_sequence as sub_decision_sequence, b.decision_credit_code as sub_decision_credit_code, b.right_counterpart_name as sub_right_counterpart_name, b.right_counterpart_code as sub_right_counterpart_code, b.right_counterpart_type as sub_right_counterpart_type, b.right_decision_sequence as sub_right_decision_sequence, b.right_decision_credit_code as sub_right_decision_credit_code, b.handle_status as sub_handle_status, b.apply_time as sub_apply_time, b.apply_user as sub_apply_user, b.apply_dept as sub_apply_dept, b.del_flag as sub_del_flag, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_time as sub_update_time
        from credit_exception_apply a
                 join credit_exception_data b on b.parent_id = a.id
    </sql>


    <select id="selectCreditExceptionApplyList" parameterType="CreditExceptionApply" resultMap="CreditExceptionApplyResult">
        <include refid="selectCreditExceptionApplyVo"/>
        <where>
            <if test="applyType != null  and applyType != ''"> and apply_type = #{applyType}</if>
            <if test="exceptionType != null  and exceptionType != ''"> and exception_type = #{exceptionType}</if>
            <if test="applyContent != null  and applyContent != ''"> and apply_content = #{applyContent}</if>
            <if test="applyFile != null  and applyFile != ''"> and apply_file = #{applyFile}</if>
            <if test="businessFile != null  and businessFile != ''"> and business_file = #{businessFile}</if>
            <if test="applyMemo != null  and applyMemo != ''"> and apply_memo >= #{applyMemo}</if>
            <if test="params.beginTime != null and params.beginTime != '' "> and  date_format(report_date,'%y%m%d') >= date_format(#{params.beginTime}, '%y%m%d')</if>
            <if test="params.endTime != null and params.endTime != '' "> and date_format(report_date,'%y%m%d') &lt; date_format(#{params.endTime}, '%y%m%d') </if>
            <if test="reportDept != null  and reportDept != ''"> and report_dept = #{reportDept}</if>
            <if test="applyStatus != null "> and apply_status = #{applyStatus}</if>
        </where>
    </select>
    
    <select id="selectCreditExceptionApplyById" parameterType="Long" resultMap="CreditExceptionApplyCreditExceptionDataResult">
        <include refid="selectApplyJoinData" />
        where a.id = #{id}
    </select>

    <select id="selectCreditExceptionApplyAndData" parameterType="CreditExceptionApply" resultMap="CreditExceptionApplyCreditExceptionDataResult">
        <include refid="selectApplyJoinData" />
        <where>
            <if test="exceptionType != null  and exceptionType != ''"> a.exception_type = #{exceptionType}</if>
            <if test="params.beginTime != null and params.beginTime != '' "> and  date_format(a.report_date,'%y%m%d') >= date_format(#{params.beginTime}, '%y%m%d')</if>
            <if test="params.endTime != null and params.endTime != '' "> and date_format(a.report_date,'%y%m%d') &lt; date_format(#{params.endTime}, '%y%m%d') </if>
            <if test="reportDept != null  and reportDept != ''"> and a.report_dept = #{reportDept}</if>
        </where>
    </select>

    <select id="selectSingleExceptionApplyById" parameterType="Long" resultMap="CreditExceptionApplyResult">
        <include refid="selectCreditExceptionApplyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCreditExceptionApply" parameterType="CreditExceptionApply" useGeneratedKeys="true" keyProperty="id">
        insert into credit_exception_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="applyType != null and applyType != ''">apply_type,</if>
            <if test="exceptionType != null and exceptionType != ''">exception_type,</if>
            <if test="applyContent != null">apply_content,</if>
            <if test="applyFile != null">apply_file,</if>
            <if test="businessFile != null">business_file,</if>
            <if test="applyMemo != null">apply_memo,</if>
            <if test="reportDate != null">report_date,</if>
            <if test="reportDept != null">report_dept,</if>
            <if test="applyStatus != null">apply_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="applyType != null and applyType != ''">#{applyType},</if>
            <if test="exceptionType != null and exceptionType != ''">#{exceptionType},</if>
            <if test="applyContent != null">#{applyContent},</if>
            <if test="applyFile != null">#{applyFile},</if>
            <if test="businessFile != null">#{businessFile},</if>
            <if test="applyMemo != null">#{applyMemo},</if>
            <if test="reportDate != null">#{reportDate},</if>
            <if test="reportDept != null">#{reportDept},</if>
            <if test="applyStatus != null">#{applyStatus},</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="updateCreditExceptionApply" parameterType="CreditExceptionApply">
        update credit_exception_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="applyType != null and applyType != ''">apply_type = #{applyType},</if>
            <if test="exceptionType != null and exceptionType != ''">exception_type = #{exceptionType},</if>
            <if test="applyContent != null">apply_content = #{applyContent},</if>
            <if test="applyFile != null">apply_file = #{applyFile},</if>
            <if test="businessFile != null">business_file = #{businessFile},</if>
            <if test="applyMemo != null">apply_memo = #{applyMemo},</if>
            <if test="applyStatus != null">apply_status = #{applyStatus},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCreditExceptionApplyById" parameterType="Long">
        delete from credit_exception_apply where id = #{id}
    </delete>

    <delete id="deleteCreditExceptionApplyByIds" parameterType="String">
        delete from credit_exception_apply where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
    <delete id="deleteCreditExceptionDataByParentIds" parameterType="String">
        delete from credit_exception_data where parent_id in 
        <foreach item="parentId" collection="array" open="(" separator="," close=")">
            #{parentId}
        </foreach>
    </delete>

    <delete id="deleteCreditExceptionDataByParentId" parameterType="Long">
        delete from credit_exception_data where parent_id = #{parentId}
    </delete>

    <insert id="batchCreditExceptionData">
        insert into credit_exception_data( id, parent_id, recover_id, data_type, counterpart_name, counterpart_code, counterpart_type, decision_sequence, decision_credit_code, right_counterpart_name, right_counterpart_code, right_counterpart_type, right_decision_sequence, right_decision_credit_code, handle_status, apply_time, apply_user, apply_dept, del_flag, create_by, create_time, update_time) values
		<foreach item="item" index="index" collection="list" separator=",">
            ( #{item.id}, #{item.parentId}, #{item.recoverId}, #{item.dataType}, #{item.counterpartName}, #{item.counterpartCode}, #{item.counterpartType}, #{item.decisionSequence}, #{item.decisionCreditCode}, #{item.rightCounterpartName}, #{item.rightCounterpartCode}, #{item.rightCounterpartType}, #{item.rightDecisionSequence}, #{item.rightDecisionCreditCode}, #{item.handleStatus}, #{item.applyTime}, #{item.applyUser}, #{item.applyDept}, #{item.delFlag}, #{item.createBy}, #{item.createTime}, #{item.updateTime})
        </foreach>
    </insert>

    <update id="updateCreditExceptionData" parameterType="CreditExceptionData">
        update credit_exception_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="handleStatus != null">handle_status = #{handleStatus},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

</mapper>