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

    <resultMap id="BaseResultMap" type="com.sundot.airport.ledger.domain.LedgerLeaderDuty">
        <id property="id" column="id" />
        <result property="classComment" column="class_comment" />
        <result property="problemHandling" column="problem_handling" />
        <result property="workTip" column="work_tip" />
        <result property="submitter" column="submitter" />
        <result property="teamLeader" column="team_leader" />
        <result property="qualityOfficer" column="quality_officer" />
        <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" />
        <result property="syncFlag" column="sync_flag" />
    </resultMap>

    <sql id="selectVo">
        SELECT id, class_comment, problem_handling, work_tip, submitter, team_leader,
               quality_officer, import_batch, source_type, create_by, create_time, update_by, update_time, sync_flag
        FROM ledger_leader_duty
        WHERE del_flag = '0'
    </sql>

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

    <update id="updateSyncFlag">
        update ledger_leader_duty
        set sync_flag = '1'
        where sync_flag = '0'
    </update>
</mapper>
