<?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.ExCoursePhaseMapper">
|
<resultMap type="com.gkhy.exam.system.domain.ExCoursePhase" id="ExCoursePhaseResult">
|
<result property="id" column="id" />
|
<result property="name" column="name" />
|
<result property="code" column="code" />
|
<result property="companyId" column="company_id" />
|
<result property="courseId" column="course_id" />
|
<result property="level" column="level" />
|
<result property="delFlag" column="del_flag" />
|
<result property="version" column="version" />
|
<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="remark" column="remark" />
|
<result property="courseName" column="course_name" />
|
<result property="companyName" column="company_name" />
|
<result property="studentCount" column="student_count" />
|
<result property="finishCount" column="finish_count" />
|
<association property="coursePeriod" javaType="java.lang.Long" select="getCoursePeriod" column="{courseId=course_id}"/>
|
<association property="finishCount" javaType="java.lang.Integer" select="getFinishStudentCount" column="{courseId=course_id,phaseId=id}"/>
|
</resultMap>
|
|
<sql id="selectCoursePhaseVo">
|
select a.id, a.name, a.code, a.company_id, a.course_id,a.level,a.del_flag,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as course_name
|
from ex_course_phase a
|
left join ex_course b on b.id=a.course_id
|
</sql>
|
|
<update id="deleteByPhaseId">
|
update ex_course_phase set del_flag=1 where id=#{phaseId}
|
</update>
|
|
<select id="selectCoursePhaseList" resultMap="ExCoursePhaseResult">
|
select a.id, a.name, a.code, a.company_id, a.course_id,a.level,a.del_flag,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
|
b.name as course_name,c.name as company_name,
|
(select count(1) from ex_phase_student where phase_id=a.id) as student_count
|
from ex_course_phase a
|
left join ex_course b on b.id=a.course_id
|
left join sys_company c on c.id=a.company_id
|
<where>
|
and a.del_flag=0
|
<if test="name != null and name != ''">
|
AND a.name like concat('%', #{name}, '%')
|
</if>
|
<if test="code != null and code != ''">
|
AND a.code like concat('%', #{code}, '%')
|
</if>
|
<if test="companyId != null and companyId != ''">
|
AND a.company_id =#{companyId}
|
</if>
|
<if test="courseId != null and courseId != ''">
|
AND a.course_id =#{courseId}
|
</if>
|
<if test="level != null">
|
AND a.level =#{level}
|
</if>
|
</where>
|
order by a.create_time desc
|
</select>
|
|
<select id="selectCoursePhaseById" resultMap="ExCoursePhaseResult">
|
<include refid="selectCoursePhaseVo"/>
|
where a.id=#{phaseId}
|
</select>
|
|
<select id="checkNameUnique" resultType="com.gkhy.exam.system.domain.ExCoursePhase">
|
select id,name from ex_course_phase where del_flag=0 and name=#{name} limit 1
|
</select>
|
|
<select id="selectCountByCourseId" resultType="java.lang.Integer">
|
select count(1) from ex_course_phase where del_flag=0 and course_id=#{courseId}
|
</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="getFinishStudentCount" resultType="java.lang.Integer">
|
select count(1) from (select student_id,count(1) as study_count from ex_student_study where phase_id=#{phaseId} group by student_id) as a
|
where a.study_count=(select count(1) as period_count from ex_course_chapter_period where course_id=#{courseId})
|
</select>
|
</mapper>
|