<?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.ExCourseChapterMapper">
|
<resultMap type="com.gkhy.exam.system.domain.ExCourseChapter" id="ExChapterResult">
|
<result property="id" column="id" />
|
<result property="name" column="name" />
|
<result property="courseId" column="course_id" />
|
<result property="companyId" column="company_id" />
|
<result property="status" column="status" />
|
<result property="sort" column="sort" />
|
<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" />
|
<collection property="chapterPeriods" ofType="com.gkhy.exam.system.domain.ExCourseChapterPeriod" select="getChapterPeriodByChapterId" column="{chapterId=id,status=filterStatus}"/>
|
</resultMap>
|
|
<resultMap type="com.gkhy.exam.system.domain.ExCourseChapterPeriod" id="ExPeriodResult">
|
<result property="id" column="id" />
|
<result property="name" column="name" />
|
<result property="courseId" column="course_id" />
|
<result property="chapterId" column="chapter_id" />
|
<result property="status" column="status" />
|
<result property="companyId" column="company_id" />
|
<result property="resourceId" column="resource_id" />
|
<result property="period" column="period" />
|
<result property="sort" column="sort" />
|
<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" />
|
<association property="resource" javaType="com.gkhy.exam.system.domain.ExResource" resultMap="ExResourceResult" />
|
</resultMap>
|
|
<resultMap type="com.gkhy.exam.system.domain.ExResource" id="ExResourceResult">
|
<result property="id" column="resource_id" />
|
<result property="name" column="resource_name" />
|
<result property="resourcePath" column="resource_path" />
|
</resultMap>
|
|
<sql id="selectChapterVo">
|
select a.id, a.name, a.course_id, a.status,a.company_id, a.sort,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark
|
from ex_course_chapter a
|
</sql>
|
|
<select id="selectChapterList" resultMap="ExChapterResult">
|
select a.id, a.name, a.course_id, a.status,a.company_id, a.sort,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,#{status} as filterStatus
|
from ex_course_chapter a
|
<where>
|
and a.course_id=#{courseId}
|
<if test="name != null and name != ''">
|
AND a.name like concat('%', #{name}, '%')
|
</if>
|
<if test="status != null ">
|
AND a.status =#{status}
|
</if>
|
</where>
|
order by a.sort asc,a.id desc
|
</select>
|
|
<select id="selectChapterById" resultMap="ExChapterResult">
|
<include refid="selectChapterVo"/>
|
where a.id=#{chapterId}
|
</select>
|
|
<select id="checkNameUnique" resultType="com.gkhy.exam.system.domain.ExCourseChapter">
|
select id,name,course_id from ex_course_chapter where name=#{name} and course_id=#{courseId} limit 1
|
</select>
|
|
|
<select id="selectChapterByCourseId" resultMap="ExChapterResult">
|
select *,#{status} as filterStatus from ex_course_chapter where course_id=#{courseId}
|
<if test="status!=null">
|
and status=#{status}
|
</if>
|
order by sort asc,id desc
|
</select>
|
|
<select id="selectCountByCourseId" resultType="java.lang.Integer">
|
select count(1) from ex_course_chapter where course_id=#{courseId}
|
</select>
|
|
<select id="getChapterPeriodByChapterId" resultMap="ExPeriodResult">
|
select a.id,a.name,a.course_id,a.chapter_id,a.status,a.company_id,a.resource_id,
|
b.resource_length as period,b.name as resource_name,b.resource_path from ex_course_chapter_period a
|
left join ex_resource b on b.id=a.resource_id
|
where a.chapter_id=#{chapterId}
|
<if test="status!=null">
|
a.status=#{status}
|
</if>
|
order by a.sort asc,a.id desc
|
</select>
|
|
<select id="selectPeriodCountById" resultType="java.lang.Integer">
|
select count(1) from ex_course_chapter_period where chapter_id=#{chapterId}
|
</select>
|
|
</mapper>
|