fix
Helius
2021-12-22 822b60fd6a7d73708b908123e6d5b976fb38264a
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
<?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="cc.mrbird.febs.video.mapper.VideoMasterInfoMapper">
 
    <select id="selectInPage" resultType="cc.mrbird.febs.video.entity.VideoMasterInfoEntity">
        select
            a.*,
            count(b.id) itemCnt,
            c.play_cnt,
            c.collect_cnt,
            c.star_cnt
        from video_master_info a, video_master_items b, video_master_data c
        where a.id=b.master_id and a.id=c.master_id
        <if test="record.title != null and record.title != ''">
            and a.title like concat('%', #{record.title}, '%')
        </if>
        <if test="record.isUp != null">
            and a.is_up = #{record.isUp}
        </if>
        <if test="record.isFree != null">
            and a.is_free = #{record.isFree}
        </if>
        group by a.id
    </select>
 
    <resultMap id="videoMasterInfoMap" type="cc.mrbird.febs.video.entity.VideoMasterInfoEntity">
        <id property="id" column="id" />
        <result property="cateIds" column="cate_ids" />
        <result property="code" column="code" />
        <result property="title" column="title" />
        <result property="isFree" column="is_free" />
        <result property="isUp" column="is_up" />
        <result property="intro" column="intro" />
        <result property="thumb" column="thumb" />
        <collection property="items" ofType="cc.mrbird.febs.video.entity.VideoMasterItemsEntity" >
            <id property="id" column="item_id" />
            <result property="name" column="name" />
            <result property="thumb" column="item_thumb" />
            <result property="sourceId" column="source_id" />
            <result property="sourceName" column="sourceName" />
            <result property="timeLength" column="item_time_length" />
            <result property="seq" column="seq" />
        </collection>
    </resultMap>
 
    <select id="selectEntityById" resultMap="videoMasterInfoMap">
        select
            a.*,
            b.id item_id,
            b.name,
            b.thumb item_thumb,
            b.source_id,
            b.time_length item_time_length,
            b.seq,
            c.name sourceName
        from video_master_info a, video_master_items b, video_master_source c
        where a.id=b.master_id and a.id=#{id} and b.source_id=c.id
    </select>
 
    <select id="selectVideoListInPage" resultType="cc.mrbird.febs.video.vo.VideoListVo">
        select
            a.*,
            count(b.id) itemCnt,
            (select c.time_length from video_master_source c where b.source_id=c.id limit 1) timeLength
        from video_master_info a
            inner join video_master_items b on a.id=b.master_id
            inner join video_master_data d on a.id=d.master_id
        <where>
                1=1
            <if test="record.isUp != null">
                and a.is_up = #{record.isUp}
            </if>
            <if test="record.isFree != null">
                and a.is_free = #{record.isFree}
            </if>
            <if test="record.query != null and record.query != ''">
                and title like concat('%', #{record.query}, '%')
            </if>
        </where>
        group by a.id
        order by d.play_cnt desc, a.created_time desc
    </select>
</mapper>