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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
| <?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="cn.lili.modules.lmk.mapper.VideoCommentMapper">
|
| <!-- 通用查询映射结果 -->
| <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.VideoCommentVO">
| <id column="id" property="id"/>
| <result column="video_id" property="videoId" />
| <result column="comment_content" property="commentContent" />
| <result column="reply_id" property="replyId" />
| <result column="reply_user_id" property="replyUserId" />
| <result column="reply_user_nickname" property="replyUserNickname" />
| <result column="reply_user_avatar" property="replyUserAvatar" />
| <result column="master_comment_id" property="masterCommentId" />
| <result column="status" property="status" />
| <result column="thumbs_up_num" property="thumbsUpNum" />
| <result column="user_id" property="userId" />
| <result column="user_nickname" property="userNickname" />
| <result column="user_avatar" property="userAvatar" />
| <result column="create_time" property="createTime" />
| <result column="replyTotalCount" property="replyTotalCount" />
| <result column="has_thumbs_up" property="hasThumbsUp" />
| </resultMap>
|
|
|
|
|
|
|
| <select id="getById" resultMap="BaseResultMap">
| SELECT
| LVC.video_id,
| LVC.comment_content,
| LVC.reply_id,
| LVC.reply_user_id,
| LVC.reply_user_nickname,
| LVC.master_comment_id,
| LVC.status,
| LVC.thumbs_up_num,
| LVC.id,
| LVC.user_id,
| LVC.user_nickname,
| LVC.user_avatar,
| LVC.create_time
| FROM
| lmk_video_comment LVC
| WHERE
| LVC.id = #{id} AND LVC.delete_flag = 0
| </select>
|
| <select id="getManagerPage" resultMap="BaseResultMap">
| SELECT
| LVC.video_id,
| LVC.comment_content,
| LVC.reply_id,
| LVC.reply_user_id,
| LVC.reply_user_nickname,
| LVC.master_comment_id,
| LVC.status,
| LVC.thumbs_up_num,
| LVC.id,
| LVC.user_id,
| LVC.user_nickname,
| LVC.user_avatar,
| LVC.create_time
| FROM
| lmk_video_comment LVC
| WHERE
| LVC.video_id = #{query.videoId} AND LVC.delete_flag = 0
| <if test="query.commentContent != null and query.commentContent !=''">
| AND LVC.comment_content like concat('%',#{query.commentContent},'%')
| </if>
| <if test="query.nickName != null and query.nickName !=''">
| AND LVC.user_nickname like concat('%',#{query.nickName},'%')
| </if>
| <if test="query.startTime != null">
| AND LVC.create_time >= #{query.startTime}
| </if>
| <if test="query.endTime != null">
| AND LVC.create_time <= #{query.endTime}
| </if>
| </select>
|
| <select id="getPage" resultMap="BaseResultMap">
| SELECT
| LVC.video_id,
| LVC.comment_content,
| LVC.reply_id,
| LVC.reply_user_id,
| LVC.reply_user_nickname,
| LVC.master_comment_id,
| LVC.status,
| LVC.thumbs_up_num,
| LVC.id,
| LVC.user_id,
| LVC.user_nickname,
| LVC.user_avatar,
| LVC.create_time
| FROM
| lmk_video_comment LVC
| WHERE
| LVC.delete_flag = 0
| </select>
|
|
| <select id="masterCommentPage" resultMap="BaseResultMap">
| SELECT
| LVC.video_id,
| LVC.comment_content,
| LVC.reply_id,
| LVC.reply_user_id,
| LVC.reply_user_nickname,
| LVC.reply_user_avatar,
| LVC.master_comment_id,
| LVC.status,
| LVC.thumbs_up_num,
| LVC.id,
| LVC.user_id,
| LVC.user_nickname,
| LVC.user_avatar,
| LVC.create_time,
| COUNT(replies.id) as replyTotalCount,
| CASE
| WHEN TUC.id IS NOT NULL THEN 1
| ELSE 0
| END AS has_thumbs_up
| FROM
| lmk_video_comment LVC
| LEFT JOIN lmk_video_comment replies ON replies.master_comment_id = LVC.id AND replies.status = 'normal' AND replies.delete_flag = 0
| LEFT JOIN lmk_thumbs_up_record TUC ON LVC.id = TUC.ref_id AND TUC.thumbs_up_type = 'video_comment' AND TUC.user_id = #{query.userId} AND TUC.delete_flag = 0
| WHERE
| LVC.master_comment_id IS NULL
| AND LVC.video_id = #{query.videoId}
| AND LVC.status = 'normal'
| AND LVC.delete_flag = 0
| GROUP BY
| LVC.id, LVC.video_id, LVC.comment_content, LVC.reply_id,
| LVC.reply_user_id, LVC.reply_user_nickname, LVC.master_comment_id,
| LVC.status, LVC.user_id, LVC.user_nickname, LVC.user_avatar, LVC.create_time
| ORDER BY
| LVC.create_time DESC
| </select>
|
| <select id="replyCommentPage" resultMap="BaseResultMap">
| SELECT
| LVC.video_id,
| LVC.comment_content,
| LVC.reply_id,
| LVC.reply_user_id,
| LVC.reply_user_nickname,
| LVC.reply_user_avatar,
| LVC.master_comment_id,
| LVC.status,
| LVC.thumbs_up_num,
| LVC.id,
| LVC.user_id,
| LVC.user_nickname,
| LVC.user_avatar,
| LVC.create_time,
| 0 as replyTotalCount,
| CASE
| WHEN TUC.id IS NOT NULL THEN 1
| ELSE 0
| END AS has_thumbs_up
| FROM
| lmk_video_comment LVC
| LEFT JOIN lmk_thumbs_up_record TUC ON LVC.id = TUC.ref_id AND TUC.thumbs_up_type = 'video_comment' AND TUC.user_id = #{query.userId} AND TUC.delete_flag = 0
| WHERE
| LVC.video_id = #{query.videoId}
| AND LVC.master_comment_id = #{query.masterCommentId}
| AND LVC.status = 'normal'
| AND LVC.delete_flag = 0
| ORDER BY
| LVC.create_time ASC
| </select>
|
| <select id="countNumGroupByVideo" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO">
| SELECT
| LV.id as id,
| COUNT(LVC.video_id) as countNum
| FROM
| lmk_video LV
| LEFT JOIN lmk_video_comment LVC ON LVC.video_id = LV.id AND LVC.delete_flag = 0 AND LVC.status = 'normal'
| WHERE
| LV.comment_num_job = 1 AND LV.delete_flag = 0 AND LV.status = '1'
| GROUP BY
| LVC.video_id
| </select>
|
|
| <update id="updateCommentThumbsUpNumBatch">
| UPDATE lmk_video_comment
| SET thumbs_up_num = CASE id
| <foreach collection="list" item="comment">
| WHEN #{comment.id} THEN #{comment.countNum}
| </foreach>
| ELSE thumbs_up_num
| END
| WHERE id IN
| <foreach collection="list" item="comment" open="(" separator="," close=")">
| #{comment.id}
| </foreach>
| </update>
|
| </mapper>
|
|