PaperDictMapper.xml
3.19 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?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.subsidy.mapper.PaperDictMapper">
<select id="queryPapers" parameterType="com.subsidy.model.PaperDictDO" resultType="com.subsidy.vo.paper.QueryPapersVO">
SELECT
t.id,
t2.vod_name,
paper_name,
paper_status
FROM
paper_dict t
left join vod_dict t2 on t.vod_id = t2.id
WHERE
t.delete_date is null
and t.course_id = #{courseId}
<if test="paperName != null and paperName !=''">
AND t.paper_name LIKE concat('%',#{paperName} ,'%')
</if>
<if test="paperStatus != null and paperStatus !=''">
AND t.paper_status = #{paperStatus}
</if>
</select>
<select id="completeCount" resultType="integer">
SELECT
count( DISTINCT t.member_id ) AS cnt
FROM
exercise_done_result t
WHERE
t.delete_date IS NULL
AND t.paper_id = #{paperId}
and t.class_id = #{classId}
</select>
<select id="queryCoursePapersCnt" parameterType="long" resultType="integer">
SELECT
count( 1 )
FROM
paper_dict t
WHERE
t.delete_date IS NULL
AND t.course_id = #{courseId}
</select>
<select id="memberMaxScore" resultType="com.subsidy.vo.paper.MemberMaxScoreVO">
SELECT
t4.right_counts,
t4.total_counts,
t4.result,
t3.paper_id
FROM
(
SELECT
t.class_id,
t.paper_id,
t.member_id,
t2.paper_name,
max( score ) AS score
FROM
exercise_done_result t
LEFT JOIN paper_dict t2 ON t.paper_id = t2.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t.class_id = #{classId}
AND t2.vod_id = #{vodId}
AND t.member_id = #{memberId}
GROUP BY
t.class_id,
t.paper_id,
t.member_id,
t2.paper_name
) t3
LEFT JOIN exercise_done_result t4 ON t3.score = t4.score
AND t3.member_id = t4.member_id
AND t3.paper_id = t4.paper_id
AND t3.class_id = t4.class_id
LIMIT 1
</select>
<select id="lastPaper" parameterType="long" resultType="long">
SELECT
t4.*
FROM
course_content t
LEFT JOIN content_vod_mapping t2 ON t.id = t2.content_id
LEFT JOIN vod_dict t3 ON t2.vod_id = t3.id
LEFT JOIN paper_dict t4 ON t.course_id = t4.course_id
AND t4.vod_id = t3.id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t3.delete_date IS NULL
AND t4.delete_date IS NULL
AND t.course_id = #{courseId}
ORDER BY
t2.order_no DESC,
t3.id DESC
</select>
</mapper>