<?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.LedgerHealthSoldierMapper">

    <resultMap id="BaseResultMap" type="com.sundot.airport.ledger.domain.LedgerHealthSoldier">
        <id property="id" column="id" />
        <result property="chronicDisease" column="chronic_disease" />
        <result property="submitter" column="submitter" />
        <result property="recentSymptoms" column="recent_symptoms" />
        <result property="hasPhysicalExam" column="has_physical_exam" />
        <result property="examReportAbnormal" column="exam_report_abnormal" />
        <result property="majorDiseaseRecent" column="major_disease_recent" />
        <result property="dailyHabits" column="daily_habits" />
        <result property="mentalState" column="mental_state" />
        <result property="workPressure" column="work_pressure" />
        <result property="evidenceFile" column="evidence_file" />
        <result property="extMajorDisease" column="ext_major_disease" />
        <result property="extExamAbnormal" column="ext_exam_abnormal" />
        <result property="extRecentSymptoms" column="ext_recent_symptoms" />
        <result property="extChronicMild" column="ext_chronic_mild" />
        <result property="extChronicSevere" column="ext_chronic_severe" />
        <result property="medicalHistory" column="medical_history" />
        <result property="extMedicalHistory" column="ext_medical_history" />
        <result property="submitTime" column="submit_time" />
        <result property="teamName" column="team_name" />
        <result property="teamLeader" column="team_leader" />
        <result property="subHealthStatus" column="sub_health_status" />
        <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, chronic_disease, submitter, recent_symptoms, has_physical_exam, exam_report_abnormal,
               major_disease_recent, daily_habits, mental_state, work_pressure, evidence_file,
               ext_major_disease, ext_exam_abnormal, ext_recent_symptoms, ext_chronic_mild, ext_chronic_severe,
               medical_history, ext_medical_history, submit_time, team_name, team_leader, sub_health_status,
               import_batch, source_type, create_by, create_time, update_by, update_time
        FROM ledger_health_soldier
        WHERE del_flag = '0'
    </sql>

    <select id="selectList" parameterType="com.sundot.airport.ledger.domain.LedgerHealthSoldier" resultMap="BaseResultMap">
        <include refid="selectVo"/>
        <if test="submitter != null and submitter != ''">AND submitter LIKE CONCAT('%', #{submitter}, '%')</if>
        <if test="teamName != null and teamName != ''">AND team_name LIKE CONCAT('%', #{teamName}, '%')</if>
        <if test="teamLeader != null and teamLeader != ''">AND team_leader LIKE CONCAT('%', #{teamLeader}, '%')</if>
        <if test="subHealthStatus != null and subHealthStatus != ''">AND sub_health_status LIKE CONCAT('%', #{subHealthStatus}, '%')</if>
        <if test="params != null and params.beginTime != null and params.beginTime != ''">
            AND submit_time &gt;= #{params.beginTime}
        </if>
        <if test="params != null and params.endTime != null and params.endTime != ''">
            AND submit_time &lt;= #{params.endTime}
        </if>
        ORDER BY id DESC
    </select>

</mapper>
