LivePlaybackHistoryMapper.xml
3.07 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
<?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.LivePlaybackHistoryMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.subsidy.model.LivePlaybackHistoryDO">
<id column="id" property="id" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<result column="delete_date" property="deleteDate" />
<result column="live_vod_id" property="liveVodId" />
<result column="member_id" property="memberId" />
<result column="play_length" property="playLength" />
<result column="start_time" property="startTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
create_date,
update_date,
delete_date,
id, live_vod_id, member_id, play_length, start_time
</sql>
<select id="livePlaybacks" resultType="com.subsidy.vo.live.PlaybacksVO">
SELECT
t.id,
t.user_name,
t.telephone,
t2.play_length
FROM
(
SELECT
distinct
t2.id,
t2.user_name,
t2.telephone
FROM
class_member_mapping t
LEFT JOIN member t2 ON t.member_id = t2.id
LEFT JOIN live_classes t3 ON t.class_id = t3.class_id
WHERE
t.delete_date IS NULL
AND t2.delete_date IS NULL
AND t3.delete_date IS NULL
<if test="classId != null and classId != ''">
AND t.class_id = #{classId}
</if>
<if test="liveId != null and liveId != ''">
AND t3.live_id = #{liveId}
</if>
<if test="userName != null and userName != ''">
AND t2.user_name LIKE concat( '%', #{userName}, '%' )
</if>
)t
LEFT JOIN (
SELECT
t.live_id,
t.member_id,
sum( t.play_length ) AS play_length
FROM
live_playback_history t
WHERE
t.delete_date IS NULL
<if test="liveId != null and liveId != ''">
AND t.live_id = #{liveId}
</if>
GROUP BY
t.live_id,
t.member_id
) t2 ON t.id = t2.member_id
</select>
<select id="memberPlayback" parameterType="long" resultType="integer">
SELECT
count(
DISTINCT ( t.member_id ))
FROM
live_playback_history t
left join class_member_mapping t2 on t.member_id = t2.member_id
WHERE
t.live_id = #{liveId}
and t2.class_id = #{classId}
and t.delete_date is null
and t2.delete_date IS NULL
GROUP BY
t.live_id
</select>
</mapper>