CreditRecoverMapper.xml 11.4 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.CreditRecoverMapper">
    
    <resultMap type="CreditRecover" id="CreditRecoverResult">
        <result property="id"    column="id"    />
        <result property="recoverId"    column="recover_id"    />
        <result property="recoverType"    column="recover_type"    />
        <result property="counterpartName"    column="counterpart_name"    />
        <result property="counterpartCode"    column="counterpart_code"    />
        <result property="decisionSequence"    column="decision_sequence"    />
        <result property="decisionDept"    column="decision_dept"    />
        <result property="decisionRegion"    column="decision_region"    />
        <result property="handleDept"    column="handle_dept"    />
        <result property="handleUser"    column="handle_user"    />
        <result property="auditDate"    column="audit_date"    />
        <result property="handleStatus"    column="handle_status"    />
        <result property="handlerReason"    column="handler_reason"    />
        <result property="applyTime"    column="apply_time"    />
        <result property="applyUser"    column="apply_user"    />
        <result property="applyDept"    column="apply_dept"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deptName"    column="dept_name"    />
    </resultMap>

    <sql id="selectCreditRecoverVo">
        select id, recover_id, recover_type, counterpart_name, counterpart_code, decision_sequence, decision_dept, decision_region, handle_dept, handle_user, audit_date, handle_status, handler_reason, apply_time, apply_user, apply_dept, del_flag, create_by, create_time, update_time from credit_recover
    </sql>

    <select id="selectCreditRecoverList" parameterType="CreditRecover" resultMap="CreditRecoverResult">
        <include refid="selectCreditRecoverVo"/>
        <where>  
            <if test="recoverId != null "> and recover_id = #{recoverId}</if>
            <if test="recoverType != null  and recoverType != ''"> and recover_type = #{recoverType}</if>
            <if test="counterpartName != null  and counterpartName != ''"> and counterpart_name like concat('%', #{counterpartName}, '%')</if>
            <if test="counterpartCode != null  and counterpartCode != ''"> and counterpart_code = #{counterpartCode}</if>
            <if test="decisionSequence != null  and decisionSequence != ''"> and decision_sequence = #{decisionSequence}</if>
            <if test="decisionDept != null  and decisionDept != ''"> and decision_dept = #{decisionDept}</if>
            <if test="decisionRegion != null  and decisionRegion != ''"> and decision_region = #{decisionRegion}</if>
            <if test="handleDept != null "> and handle_dept = #{handleDept}</if>
            <if test="handleUser != null "> and handle_user = #{handleUser}</if>
            <if test="auditDate != null "> and audit_date = #{auditDate}</if>
            <if test="handleStatus != null "> and handle_status = #{handleStatus}</if>
            <if test="handlerReason != null  and handlerReason != ''"> and handler_reason = #{handlerReason}</if>
            <if test="applyTime != null "> and apply_time = #{applyTime}</if>
            <if test="applyUser != null "> and apply_user = #{applyUser}</if>
            <if test="applyDept != null "> and apply_dept = #{applyDept}</if>
        </where>
    </select>

    <select id="selectCreditRecoverListNew" parameterType="CreditRecover" resultMap="CreditRecoverResult">
        select c.*,s.dept_name from credit_recover c, sys_dept s
        <where>
            1=1 and c.handle_dept=s.dept_id
            <if test="recoverId != null "> and c.recover_id = #{recoverId}</if>
            <if test="recoverType != null  and recoverType != ''"> and c.recover_type = #{recoverType}</if>
            <if test="counterpartName != null  and counterpartName != ''"> and c.counterpart_name like concat('%', #{counterpartName}, '%')</if>
            <if test="counterpartCode != null  and counterpartCode != ''"> and c.counterpart_code = #{counterpartCode}</if>
            <if test="decisionSequence != null  and decisionSequence != ''"> and c.decision_sequence = #{decisionSequence}</if>
            <if test="decisionDept != null  and decisionDept != ''"> and c.decision_dept = #{decisionDept}</if>
            <if test="decisionRegion != null  and decisionRegion != ''"> and c.decision_region = #{decisionRegion}</if>
            <if test="handleDept != null "> and c.handle_dept = #{handleDept}</if>
            <if test="handleUser != null "> and c.handle_user = #{handleUser}</if>
            <if test="auditDate != null "> and c.audit_date = #{auditDate}</if>
            <if test="handleStatus != null "> and c.handle_status = #{handleStatus}</if>
            <if test="handlerReason != null  and handlerReason != ''"> and c.handler_reason = #{handlerReason}</if>
            <if test="applyTime != null "> and c.apply_time = #{applyTime}</if>
            <if test="applyUser != null "> and c.apply_user = #{applyUser}</if>
            <if test="applyDept != null "> and c.apply_dept = #{applyDept}</if>
        </where>
    </select>

    <select id="queryLastCreditRecover" parameterType="CreditRecover" resultMap="CreditRecoverResult">
        <include refid="selectCreditRecoverVo"/>
        <where>
            <if test="recoverId != null "> and recover_id = #{recoverId}</if>
            <if test="recoverType != null  and recoverType != ''"> and recover_type = #{recoverType}</if>
            <if test="counterpartName != null  and counterpartName != ''"> and counterpart_name like concat('%', #{counterpartName}, '%')</if>
            <if test="counterpartCode != null  and counterpartCode != ''"> and counterpart_code = #{counterpartCode}</if>
            <if test="decisionSequence != null  and decisionSequence != ''"> and decision_sequence like concat('%', #{decisionSequence}, '%')</if>
        </where>
    </select>
    
    <select id="selectCreditRecoverById" parameterType="Long" resultMap="CreditRecoverResult">
        <include refid="selectCreditRecoverVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCreditRecover" parameterType="CreditRecover" useGeneratedKeys="true" keyProperty="id">
        insert into credit_recover
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="recoverId != null">recover_id,</if>
            <if test="recoverType != null and recoverType != ''">recover_type,</if>
            <if test="counterpartName != null and counterpartName != ''">counterpart_name,</if>
            <if test="counterpartCode != null and counterpartCode != ''">counterpart_code,</if>
            <if test="decisionSequence != null and decisionSequence != ''">decision_sequence,</if>
            <if test="decisionDept != null">decision_dept,</if>
            <if test="decisionRegion != null">decision_region,</if>
            <if test="handleDept != null">handle_dept,</if>
            <if test="handleUser != null">handle_user,</if>
            <if test="auditDate != null">audit_date,</if>
            <if test="handleStatus != null">handle_status,</if>
            <if test="handlerReason != null">handler_reason,</if>
            <if test="applyTime != null">apply_time,</if>
            <if test="applyUser != null">apply_user,</if>
            <if test="applyDept != null">apply_dept,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="recoverId != null">#{recoverId},</if>
            <if test="recoverType != null and recoverType != ''">#{recoverType},</if>
            <if test="counterpartName != null and counterpartName != ''">#{counterpartName},</if>
            <if test="counterpartCode != null and counterpartCode != ''">#{counterpartCode},</if>
            <if test="decisionSequence != null and decisionSequence != ''">#{decisionSequence},</if>
            <if test="decisionDept != null">#{decisionDept},</if>
            <if test="decisionRegion != null">#{decisionRegion},</if>
            <if test="handleDept != null">#{handleDept},</if>
            <if test="handleUser != null">#{handleUser},</if>
            <if test="auditDate != null">#{auditDate},</if>
            <if test="handleStatus != null">#{handleStatus},</if>
            <if test="handlerReason != null">#{handlerReason},</if>
            <if test="applyTime != null">#{applyTime},</if>
            <if test="applyUser != null">#{applyUser},</if>
            <if test="applyDept != null">#{applyDept},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateCreditRecover" parameterType="CreditRecover">
        update credit_recover
        <trim prefix="SET" suffixOverrides=",">
            <if test="recoverId != null">recover_id = #{recoverId},</if>
            <if test="recoverType != null and recoverType != ''">recover_type = #{recoverType},</if>
            <if test="counterpartName != null and counterpartName != ''">counterpart_name = #{counterpartName},</if>
            <if test="counterpartCode != null and counterpartCode != ''">counterpart_code = #{counterpartCode},</if>
            <if test="decisionSequence != null and decisionSequence != ''">decision_sequence = #{decisionSequence},</if>
            <if test="decisionDept != null">decision_dept = #{decisionDept},</if>
            <if test="decisionRegion != null">decision_region = #{decisionRegion},</if>
            <if test="handleDept != null">handle_dept = #{handleDept},</if>
            <if test="handleUser != null">handle_user = #{handleUser},</if>
            <if test="auditDate != null">audit_date = #{auditDate},</if>
            <if test="handleStatus != null">handle_status = #{handleStatus},</if>
            <if test="handlerReason != null">handler_reason = #{handlerReason},</if>
            <if test="applyTime != null">apply_time = #{applyTime},</if>
            <if test="applyUser != null">apply_user = #{applyUser},</if>
            <if test="applyDept != null">apply_dept = #{applyDept},</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="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCreditRecoverById" parameterType="Long">
        delete from credit_recover where id = #{id}
    </delete>

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

</mapper>