zhangf
2024-06-24 21362fd048558832cdcaca8ee957d2d7aa753be2
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
<?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.institutionalaccess.mapper.ThStudyDetailMapper">
    <select id="listByPage" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStudyDetailVO">
        SELECT
            d.*,
            s.name,
            b.batch_name,
            c.course_name,
            cc.chapter_name
        FROM
            th_study_detail d
                LEFT JOIN th_student s ON s.idcard = d.idcard
                LEFT JOIN th_batch b ON b.uuid = d.batch_uuid
                LEFT JOIN th_course c ON c.uuid = d.course_uuid
                LEFT JOIN th_course_chapter cc ON cc.uuid = d.chapter_uuid
        where d.del_flag = 0
        <if test="query.idcard != null and query.idcard != ''">
            and d.idcard = #{query.idcard}
        </if>
        <if test="query.courseUuid != null and query.courseUuid != ''">
            and d.course_uuid = #{query.courseUuid}
        </if>
        <if test="query.name != null and query.name != ''">
            and s.name like concat('%', #{query.name}, '%')
        </if>
        <if test="query.startTime != null"><!-- 开始时间检索 -->
            and date_format(d.create_time,'%y-%m-%d') &gt;= date_format(#{query.startTime},'%y-%m-%d')
        </if>
        <if test="query.endTime != null"><!-- 结束时间检索 -->
            and date_format(d.create_time,'%y-%m-%d') &lt;= date_format(#{query.endTime},'%y-%m-%d')
        </if>
        order by d.create_time desc
    </select>
 
    <select id="statisticDurationByIdcard" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStudyVO">
        SELECT
            d.idcard,
            sum( d.duration ) duration
        FROM
            th_study_detail d
        WHERE
            d.del_flag = 0
          AND d.batch_uuid = #{batchUuid}
        GROUP BY
            d.idcard
    </select>
    <select id="listByBatchUuid" resultType="com.gkhy.exam.institutionalaccess.model.vo.ThStudyDetailVO">
        SELECT
            d.*,
            cc.chapter_name,
            cc.lesson_num
 
        FROM
            th_study_detail d
                LEFT JOIN th_course_chapter cc ON cc.uuid = d.chapter_uuid
        where d.del_flag = 0
          AND d.batch_uuid = #{batchUuid}
    </select>
 
</mapper>