<?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.sundot.airport.ledger.mapper.LedgerDormFireSafetyMapper">

    <resultMap id="BaseResultMap" type="com.sundot.airport.ledger.domain.LedgerDormFireSafety">
        <id property="id" column="id" />
        <result property="checkDate" column="check_date" />
        <result property="dormLocation" column="dorm_location" />
        <result property="dormNo" column="dorm_no" />
        <result property="checkItems" column="check_items" />
        <result property="riskStatus" column="risk_status" />
        <result property="foundRisk" column="found_risk" />
        <result property="photos" column="photos" />
        <result property="rectifyPerson" column="rectify_person" />
        <result property="rectifyTime" column="rectify_time" />
        <result property="submitTime" column="submit_time" />
        <result property="submitter" column="submitter" />
        <result property="importBatch" column="import_batch" />
        <result property="sourceType" column="source_type" />
        <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>

    <sql id="selectVo">
        SELECT id, check_date, dorm_location, dorm_no, check_items, risk_status, found_risk,
               photos, rectify_person, rectify_time, submit_time, submitter,
               import_batch, source_type, create_by, create_time, update_by, update_time
        FROM ledger_dorm_fire_safety
        WHERE del_flag = '0'
    </sql>

    <select id="selectList" parameterType="com.sundot.airport.ledger.domain.LedgerDormFireSafety" resultMap="BaseResultMap">
        <include refid="selectVo"/>
        <if test="dormLocation != null and dormLocation != ''">AND dorm_location LIKE CONCAT('%', #{dormLocation}, '%')</if>
        <if test="submitter != null and submitter != ''">AND submitter LIKE CONCAT('%', #{submitter}, '%')</if>
        <if test="dormNo != null and dormNo != ''">AND dorm_no LIKE CONCAT('%', #{dormNo}, '%')</if>
        <if test="params != null and params.beginTime != null and params.beginTime != ''">
            AND check_date &gt;= #{params.beginTime}
        </if>
        <if test="params != null and params.endTime != null and params.endTime != ''">
            AND check_date &lt;= #{params.endTime}
        </if>
        ORDER BY id DESC
    </select>

</mapper>
