xiangpei
2025-06-12 8bfcdc67288b607e333da334ec84abc58ff6dfc4
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<?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.VideoMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.VideoVO">
        <id column="id" property="id"/>
        <result column="author_id" property="authorId" />
        <result column="authorName" property="authorName" />
        <result column="cover_url" property="coverUrl" />
        <result column="video_file_key" property="videoFileKey" />
        <result column="video_fit" property="videoFit" />
        <result column="title" property="title" />
        <result column="goods_id" property="goodsId" />
        <result column="goods_view_num" property="goodsViewNum" />
        <result column="video_duration" property="videoDuration" />
        <result column="goods_order_num" property="goodsOrderNum" />
        <result column="recommend" property="recommend" />
        <result column="status" property="status" />
        <result column="play_num" property="playNum" />
        <result column="collect_num" property="collectNum" />
        <result column="comment_num" property="commentNum" />
        <result column="weight" property="weight" />
        <result column="audit_pass_time" property="auditPassTime" />
        <result column="update_time" property="updateTime" />
        <result column="video_content_type" property="videoContentType" />
        <result column="video_type" property="videoType" />
        <result column="video_imgs" property="videoImgs" />
    </resultMap>
 
    <!-- 微信推荐视频 -->
    <resultMap id="WxResultMap" type="cn.lili.modules.lmk.domain.vo.WxVideoVO">
        <id column="id" property="id"/>
        <result column="author_id" property="authorId" />
        <result column="authorName" property="authorName" />
        <result column="authorAvatar" property="authorAvatar" />
        <result column="cover_url" property="coverFileKey" />
        <result column="video_file_key" property="videoFileKey" />
        <result column="video_fit" property="videoFit" />
        <result column="title" property="title" />
        <result column="collect_num" property="collectNum" />
        <result column="comment_num" property="commentNum" />
        <result column="status" property="status" />
    </resultMap>
 
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.collect_num,
            LV.comment_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName
        FROM
            lmk_video LV
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.id = #{id} AND LV.delete_flag = 0
    </select>
 
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.collect_num,
            LV.comment_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName
        FROM
            lmk_video LV
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0
    </select>
 
 
    <select id="managerPage" resultMap="BaseResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.collect_num,
            LV.comment_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName
        FROM
            lmk_video LV
                LEFT JOIN li_member LM ON LV.author_id = LM.id
            <if test="query.tagList != null and query.tagList.size > 0">
                INNER JOIN (
                SELECT DISTINCT video_id
                FROM lmk_video_tag_ref
                WHERE video_tag_id IN
                <foreach collection="query.tagList" open="(" item="tagId" close=")" separator=",">#{tagId}</foreach>
                ) AS LVT ON LV.id = LVT.video_id
            </if>
        WHERE
            LV.delete_flag = 0 AND LV.video_type = #{query.videoType}
            <if test="query.title != null and query.title != ''">AND LV.title LIKE CONCAT('%', #{query.title}, '%')</if>
            <if test="query.authorId != null and query.authorId != ''">AND LV.author_id = #{query.authorId}</if>
            <if test="query.status != null and query.status != ''">AND LV.status = #{query.status}</if>
    </select>
 
 
    <select id="recommendVideo" resultMap="WxResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName,
            LM.face as authorAvatar
        FROM
            lmk_video LV
            LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0 AND LV.status = '1' AND LV.video_type = #{query.videoType}
    </select>
 
 
    <update id="updateCollectNumBatch">
        UPDATE lmk_video
        SET collect_num = CASE id
        <foreach collection="list" item="video">
            WHEN #{video.id} THEN #{video.countNum}
        </foreach>
        ELSE collect_num
        END
        WHERE id IN
        <foreach collection="list" item="video" open="(" separator="," close=")">
            #{video.id}
        </foreach>
    </update>
 
 
    <update id="updateCommentNumBatch">
        UPDATE lmk_video
        SET comment_num = CASE id
        <foreach collection="list" item="video">
            WHEN #{video.id} THEN #{video.countNum}
        </foreach>
        ELSE comment_num
        END
        WHERE id IN
        <foreach collection="list" item="video" open="(" separator="," close=")">
            #{video.id}
        </foreach>
    </update>
 
 
    <select id="getAuthorInfo" resultType="cn.lili.modules.lmk.domain.vo.VideoAccountVO">
        SELECT
               LM.id as userId,
               LM.nick_name as nickName,
               LM.face as avatar,
               LVA.motto,
               (SELECT COUNT(*) FROM lmk_my_subscribe WHERE subscribe_user_id = #{authorId} AND delete_flag = 0) as fansNum,
               (SELECT COUNT(*) FROM lmk_my_subscribe WHERE user_id = #{authorId} AND delete_flag = 0) as subNum,
               (SELECT CASE
                           WHEN id IS NOT NULL THEN 1
                           ELSE 0
                           END
               FROM lmk_my_subscribe WHERE user_id = #{currentUserId} AND subscribe_user_id = #{authorId} AND delete_flag = 0) as hasSub
        FROM
             li_member LM
                 LEFT JOIN lmk_video_account LVA ON LM.id = LVA.user_id
        WHERE
              LM.id = #{authorId} AND LM.delete_flag = 0
    </select>
 
    <select id="getVideoIdsByAuthor" parameterType="string" resultType="string">
        SELECT id FROM lmk_video WHERE author_id = #{authorId} AND delete_flag = 0 AND status = '1'
    </select>
 
    <select id="countAuthorVideoCollectNum" resultType="long">
        SELECT COUNT(*) FROM lmk_my_collect WHERE collect_type = 'video' AND delete_flag = 0 AND ref_id IN <foreach
            collection="videoIds" open="(" close=")" separator="," item="videoId">#{videoId}</foreach>
    </select>
 
    <select id="getAuthorVideoPage" resultMap="WxResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName,
            LM.face as authorAvatar
        FROM
            lmk_video LV
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LV.delete_flag = 0
            <if test="!query.authorSelf">
                AND LV.status = '1'
            </if>
            AND LV.author_id = #{query.authorId}
            AND LV.video_type = #{query.videoType}
        ORDER BY
            LV.collect_num DESC
    </select>
 
    <select id="getAuthorCollectVideoPage" resultMap="WxResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id,
            LM.nick_name as authorName,
            LM.face as authorAvatar
        FROM
            lmk_my_collect LMC
                INNER JOIN lmk_video LV ON LMC.ref_id = LV.id AND LV.delete_flag = 0 AND LV.status = '1'
                LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE
            LMC.delete_flag = 0 AND LMC.user_id = #{query.authorId} AND LMC.collect_type = 'video' AND LV.video_type = #{query.videoType}
        ORDER BY
            LMC.create_time DESC
    </select>
 
 
    <!-- 微信视频编辑详情 -->
    <resultMap id="WxEditResultMap" type="cn.lili.modules.lmk.domain.vo.WxEditVideoVO">
        <id column="id" property="id"/>
        <result column="cover_url" property="coverFileKey" />
        <result column="video_file_key" property="videoFileKey" />
        <result column="video_fit" property="videoFit" />
        <result column="title" property="title" />
        <result column="video_duration" property="videoDuration" />
        <result column="goods_id" property="goodsId" />
    </resultMap>
 
    <select id="wxDetail" resultMap="WxEditResultMap">
        SELECT
            LV.author_id,
            LV.cover_url,
            LV.video_fit,
            LV.video_duration,
            LV.video_file_key,
            LV.title,
            LV.goods_view_num,
            LV.goods_order_num,
            LV.recommend,
            LV.status,
            LV.play_num,
            LV.comment_num,
            LV.collect_num,
            LV.weight,
            LV.audit_pass_time,
            LV.update_time,
            LV.video_content_type,
            LV.video_type,
            LV.video_imgs,
            LV.id
        FROM
            lmk_video LV
        WHERE
            LV.delete_flag = 0 AND LV.id = #{id}
    </select>
 
</mapper>