<?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.gkhy.exam.system.mapper.ExPhaseStudentMapper">
|
<resultMap type="com.gkhy.exam.system.domain.ExPhaseStudent" id="ExPhaseStudentResult">
|
<result property="id" column="id" />
|
<result property="phaseId" column="phase_id" />
|
<result property="studentId" column="student_id" />
|
<result property="createId" column="create_id" />
|
<result property="createTime" column="create_time" />
|
<result property="studentName" column="student_name" />
|
<result property="studentPhone" column="student_phone" />
|
<result property="phaseName" column="phase_name" />
|
<result property="createName" column="create_name" />
|
<association property="course" javaType="com.gkhy.exam.system.domain.ExCourse" resultMap="courseResult" />
|
<collection property="totalProgress" ofType="java.math.BigDecimal" select="getTotalProgress" column="{phaseId=phase_id,studentId=student_id}"/>
|
<collection property="startTime" ofType="java.time.LocalDateTime" select="getStartTime" column="{phaseId=phase_id,studentId=student_id}"/>
|
</resultMap>
|
|
<resultMap id="courseResult" type="com.gkhy.exam.system.domain.ExCourse">
|
<id property="id" column="course_id" />
|
<result property="name" column="course_name" />
|
<result property="logo" column="course_logo" />
|
<association property="period" javaType="java.lang.Long" select="getCoursePeriod" column="{courseId=course_id}"/>
|
</resultMap>
|
|
<insert id="batchInsert" parameterType="java.util.List">
|
insert into ex_phase_student(phase_id,student_id,create_id) values
|
<foreach collection="list" item="item" index="index" separator=",">
|
(#{item.phaseId},#{item.studentId},#{item.createId})
|
</foreach>
|
</insert>
|
|
<select id="countByPhaseId" resultType="java.lang.Integer">
|
select count(1) from ex_phase_student where phase_id=#{phaseId}
|
</select>
|
|
<select id="selectPhaseStudentById" resultType="com.gkhy.exam.system.domain.ExPhaseStudent">
|
select a.*,b.phone as student_phone,b.name as student_name from ex_phase_student a
|
left join ex_student b on a.student_id=b.id
|
where a.id=#{phaseStudentId}
|
</select>
|
|
<select id="getTotalProgress" resultType="java.math.BigDecimal">
|
select sum(progress) from ex_student_study where phase_id=#{phaseId} and student_id=#{studentId}
|
</select>
|
|
<select id="getStartTime" resultType="java.time.LocalDateTime">
|
select create_time from ex_student_study where phase_id=#{phaseId} and student_id=#{studentId} order by create_time asc limit 1
|
</select>
|
|
<select id="selectPhaseStudentList" resultMap="ExPhaseStudentResult">
|
select a.*,b.phone as student_phone,b.name as student_name,c.name as phase_name,e.name as create_name,d.id as course_id,d.logo as course_logo,d.name as course_name from ex_phase_student a
|
left join ex_student b on a.student_id=b.id
|
left join ex_course_phase c on c.id=a.phase_id
|
left join ex_course d on d.id=c.course_id
|
left join sys_user e on e.id=a.create_id
|
<where>
|
and c.del_flag=0 and b.del_flag=0
|
<if test="phaseId!=null">
|
and a.phase_id=#{phaseId}
|
</if>
|
<if test="studentName!=null and studentName!=''">
|
and b.name like concat('%',#{studentName},'%')
|
</if>
|
<if test="studentPhone!=null and studentPhone!=''">
|
and b.phone like concat('%',#{studentPhone},'%')
|
</if>
|
<if test="studentId!=null">
|
and a.student_id=#{studentId}
|
</if>
|
</where>
|
order by a.id desc
|
</select>
|
|
<select id="selectCountByPhaseStudentId" resultType="java.lang.Integer">
|
select count(1) from ex_phase_student where phase_id=#{phaseId} and student_id=#{studentId}
|
</select>
|
|
|
<select id="getCoursePeriod" resultType="java.lang.Long">
|
select sum(b.resource_length) from ex_course_chapter_period a
|
inner join ex_resource b on a.resource_id=b.id
|
where a.course_id=#{courseId}
|
</select>
|
|
<select id="selectPhaseStudentByStudentId" resultType="com.gkhy.exam.system.domain.ExPhaseStudent"
|
parameterType="java.lang.Long">
|
select a.*,b.name as phase_name,c.id as company_id,c.name as company_name from ex_phase_student a
|
left join ex_course_phase b on b.id=a.phase_id
|
left join sys_company c on c.id=b.company_id
|
where a.student_id=#{studentId}
|
</select>
|
|
|
</mapper>
|