<?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="cn.iocoder.yudao.module.knowledge.mapper.TTrainReportMapper">

    <resultMap type="cn.iocoder.yudao.module.knowledge.entity.TTrainReport" id="tTrainReportMap">
        <result property="id" column="id"/>
        <result property="trainId" column="train_id"/>
        <result property="name" column="name"/>
        <result property="holdUnit" column="hold_unit"/>
        <result property="purpose" column="purpose"/>
        <result property="content" column="content"/>
        <result property="studentsum" column="studentSum"/>
        <result property="attendance" column="attendance"/>
        <result property="holdForm" column="hold_form"/>
        <result property="examForm" column="exam_form"/>
        <result property="passSum" column="pass_sum"/>
        <result property="failSum" column="fail_sum"/>
        <result property="competencyRate" column="competency_rate"/>
        <result property="appointmentRate" column="appointment_rate"/>
        <result property="teacherName" column="teacher_name"/>
        <result property="teacherEducation" column="teacher_education"/>
        <result property="jobTitle" column="job_title"/>
        <result property="isNote" column="is_note"/>
        <result property="isFinishPlan" column="is_finish_plan"/>
        <result property="teachLevel" column="teach_level"/>
        <result property="teachMethod" column="teach_method"/>
        <result property="evaluateOne" column="evaluate_one"/>
        <result property="evaluateTwo" column="evaluate_two"/>
        <result property="evaluateThree" column="evaluate_three"/>
        <result property="isAchievePurpose" column="is_achieve_purpose"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="deptId" column="dept_id"/>
        <result property="identityId" column="identity_id"/>
        <result property="deleted" column="deleted"/>
    </resultMap>

    <!-- 用于select查询公用抽取的列 -->
    <sql id="columns">
        id
        ,train_id,name,hold_unit,purpose,content,studentSum,attendance,hold_form,exam_form,pass_sum,fail_sum,competency_rate,appointment_rate,teacher_name,teacher_education,job_title,is_note,is_finish_plan,teach_level,teach_method,evaluate_one,evaluate_two,evaluate_three,is_achieve_purpose,create_time,update_time,dept_id,identity_id,deleted
    </sql>

    <select id="findList" resultMap="tTrainReportMap">
        select
        ttr.*
        from t_train_report ttr
        inner join t_train tt on ttr.train_id = tt.id and tt.deleted = 0
        <where>
            ttr.deleted = 0
            <if test="params.name != '' and params.name != null">
                AND ttr.`name` LIKE CONCAT( '%',#{params.name}, '%')
            </if>
            <if test="params.startTime != '' and params.startTime != null">
                AND ttr.`update_time` LIKE CONCAT(#{params.startTime}, '%')
            </if>
        </where>
        order by update_time desc
    </select>

    <select id="selectByTrainId" resultMap="tTrainReportMap">
        select
        *
        from t_train_report
        <where>
            deleted = 0
            and train_id = #{trainId}
        </where>
        order by update_time desc
        limit 1
    </select>

</mapper>
