<?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.warehouse.mapper.CheckWarehouseMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="checkWarehouseResultMap" type="org.springblade.bank.warehouse.entity.CheckWarehouse">
        <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="check_time_begin" property="checkTimeBegin"/>
        <result column="check_time_end" property="checkTimeEnd"/>
        <result column="check_unit" property="checkUnit"/>
        <result column="check_purpose" property="checkPurpose"/>
        <result column="check_content" property="checkContent"/>
        <result column="check_result" property="checkResult"/>
        <result column="check_person_no" property="checkPersonNo"/>
        <result column="check_person_name" property="checkPersonName"/>
        <result column="remark" property="remark"/>
        <result column="filling_date" property="fillingDate"/>
        <result column="filling_person" property="fillingPerson"/>
        <result column="enclosure" property="enclosure"/>
    </resultMap>


    <select id="selectCheckWarehousePage" resultMap="checkWarehouseResultMap">
        select * from zh_record_check_warehouse where is_deleted = 0
        <if test="checkWarehouse!=null">
            <if test="checkWarehouse.createUser!=null">
                AND create_user like '%${checkWarehouse.createUser}%'
            </if>
            <if test="checkWarehouse.bankNo!=null">
                AND bank_no = '${checkWarehouse.bankNo}'
            </if>
            <if test="checkWarehouse.checkUnit!=null">
                AND check_unit in
                <foreach item="checkUnit" collection="checkWarehouse.checkUnits" separator="," open="(" close=")" index="">
                    #{checkUnit}
                </foreach>
            </if>
            <if test="checkWarehouse.checkContent!=null">
                AND check_content in
                <foreach item="checkContent" collection="checkWarehouse.checkContents" separator="," open="(" close=")" index="">
                    #{checkContent}
                </foreach>
            </if>
            <if test="checkWarehouse.orgNos!=null">
                AND org_no in
                <foreach item="orgNo" collection="checkWarehouse.orgNos" separator="," open="(" close=")" index="">
                    #{orgNo}
                </foreach>
            </if>
            <if test="checkWarehouse.checkTime_begin!=null and checkWarehouse.checkTime_end!=null">
                and (
                    check_time_begin BETWEEN '${checkWarehouse.checkTime_begin}' and '${checkWarehouse.checkTime_end}'
                    or
                    check_time_end BETWEEN '${checkWarehouse.checkTime_begin}' and '${checkWarehouse.checkTime_end}'
                )
            </if>
        </if>
        ORDER BY create_time DESC
    </select>

</mapper>
