<?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.zhongzheng.modules.course.mapper.TeacherProjectMapper">

    <resultMap type="com.zhongzheng.modules.course.domain.TeacherProject" id="TeacherProjectResult">
        <result property="id" column="id"/>
        <result property="projectId" column="project_id"/>
        <result property="teacherId" column="teacher_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
    <resultMap type="com.zhongzheng.modules.course.vo.TeacherProjectVo" id="TeacherProjectVo">
        <result property="id" column="id"/>
        <result property="projectId" column="project_id"/>
        <result property="teacherId" column="teacher_id"/>
        <result property="educationId" column="education_id"/>
        <result property="projectName" column="project_name"/>
        <result property="educationName" column="education_name"/>
        <result property="educationId" column="education_id"/>
    </resultMap>


    <select id="queryTeacher" parameterType="Long"  resultMap="TeacherProjectVo">
        SELECT
        p.*,
        t.project_name,
        t.id as project_id,
        e.id as education_id,
        e.education_name
        FROM
        teacher_project p
        LEFT JOIN course_project_type t on p.project_id=t.id
        LEFT JOIN course_education_type e on t.education_id = e.id
        WHERE
        1 =1
        <if test="id != null and id!=0 ">
            AND p.teacher_id = #{id}
        </if>
        order by p.update_time desc
    </select>

</mapper>
