<?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="org.springblade.bank.postchange.mapper.PostChangeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="postChangeResultMap" type="org.springblade.bank.postchange.entity.PostChange">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="bank_no" property="bankNo"/>
        <result column="org_no" property="orgNo"/>
        <result column="director" property="director"/>
        <result column="manager" property="manager"/>
        <result column="type" property="type"/>
        <result column="key_pwd" property="keyPwd"/>
        <result column="holder" property="holder"/>
        <result column="backup_person" property="backupPerson"/>
        <result column="apply_date" property="applyDate"/>
        <result column="effective_date" property="effectiveDate"/>
        <result column="remark" property="remark"/>
        <result column="person_id" property="personId"/>
        <result column="person_no" property="personNo"/>
        <result column="person_name" property="personName"/>
        <result column="approve_time" property="approveTime"/>
        <result column="process" property="process"/>
        <result column="is_completed" property="isCompleted"/>
        <result column="previous_id" property="previousId"/>
    </resultMap>


    <select id="selectPostChangePage" resultMap="postChangeResultMap">
        select * from zh_record_post_change where is_deleted = 0 and id != 1
        and (
        process != 2 or
        (process = 2 and (create_user = '${postChange.currentuserId}' or person_id = '${postChange.currentuserId}' ))
        )
        <if test="postChange!=null">
            <if test="postChange.createUser!=null">
                AND create_user like '%${postChange.createUser}%'
            </if>
            <if test="postChange.bankNo!=null">
                AND bank_no = '${postChange.bankNo}'
            </if>
            <if test="postChange.orgNo!=null">
                AND org_no = '${postChange.orgNo}'
            </if>
            <if test="postChange.process!=null">
                AND process = '${postChange.process}'
            </if>
            <if test="postChange.effectiveDate_begin!=null and postChange.effectiveDate_end!=null">
                and effective_date BETWEEN '${postChange.effectiveDate_begin}' and '${postChange.effectiveDate_end}'
            </if>
        </if>
        order by create_time DESC
    </select>

</mapper>
