kongzy
2024-06-24 4910e41f81a85c03a9dfc83f8ec9c1e71c123d49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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="getChapterPeriodById" column="{chapterId=id}"/>
    </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,
               b.id as period_id,a.id as chapter_id,b.name as period_name,b.resource_id
        from ex_course_chapter a
        left join ex_course_chapter_period b on b.chapter_id=a.id
    </sql>
 
    <select id="selectChapterList" resultMap="ExChapterResult">
        <include refid="selectChapterVo"/>
        <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 * from ex_course_chapter where course_id=#{courseId}
        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="getChapterPeriodById" resultType="com.gkhy.exam.system.domain.ExCourseChapterPeriod">
        select * from ex_course_chapter_period where chapter_id=#{chapterId}
    </select>
 
    <select id="selectPeriodCountById" resultType="java.lang.Integer">
        select count(1) from ex_course_chapter_period where chapter_id=#{chapterId}
    </select>
 
</mapper>