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
<?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.MyCollectMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.MyCollectVO">
        <id column="id" property="id"/>
        <result column="user_id" property="userId" />
        <result column="collect_type" property="collectType" />
        <result column="ref_id" property="refId" />
    </resultMap>
 
 
 
 
 
 
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            LMC.user_id,
            LMC.collect_type,
            LMC.ref_id,
            LMC.id
        FROM
            lmk_my_collect LMC
        WHERE
            LMC.id = #{id} AND LMC.delete_flag = 0
    </select>
 
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            LMC.user_id,
            LMC.collect_type,
            LMC.ref_id,
            LMC.id
        FROM
            lmk_my_collect LMC
        WHERE
            LMC.delete_flag = 0
    </select>
 
    <select id="getCollectsByVideoIds" resultType="cn.lili.modules.lmk.domain.vo.SimpleMyCollectVO">
        SELECT
               id,
               ref_id as refId
        FROM
             lmk_my_collect
        WHERE
              user_id = #{userId}
          AND delete_flag = 0
          AND collect_type = 'video'
          AND ref_id IN <foreach collection="videoIds" open="(" item="videoId" close=")" separator=",">#{videoId}</foreach>
    </select>
 
    <select id="countNumGroupByType" parameterType="string" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO">
        SELECT
               ref_id as id,
               count(id) as countNum
        FROM
             lmk_my_collect
        WHERE
              collect_type = #{type} AND delete_flag = 0
        GROUP BY
            ref_id
    </select>
 
 
    <!-- 通用查询映射结果 -->
    <resultMap id="activityBaseResult" type="cn.lili.modules.lmk.domain.vo.ActivityVO">
        <result column="activity_name" property="activityName" />
        <result column="activity_type" property="activityType"/>
        <result column="report_start_time" property="reportStartTime" />
        <result column="report_end_time" property="reportEndTime" />
        <result column="start_time" property="startTime" />
 
        <result column="end_time" property="endTime" />
        <result column="status" property="status" />
        <result column="recommend" property="recommend" />
        <result column="cover" property="cover" />
        <result column="cover_type" property="coverType" />
        <result column="limit_user_num" property="limitUserNum" />
        <result column="activity_location" property="activityLocation" />
        <result column="activity_content" property="activityContent" />
    </resultMap>
    <select id="getActivityCollectPage" resultMap="activityBaseResult">
        SELECT
            LA.*
        FROM lmk_my_collect LMC
                 LEFT JOIN lmk_activity LA
                           ON LMC.ref_id = LA.id
        WHERE LMC.collect_type = 'activity' and LMC.user_id = #{userId}
    </select>
    <resultMap id="videoBaseResult" 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" />
    </resultMap>
 
    <select id="getVideoCollectPage" resultMap="videoBaseResult">
        SELECT
            LV.*,
            LM.nick_name as authorName
        FROM lmk_my_collect LMC
                 LEFT JOIN lmk_video LV
                           ON LMC.ref_id = LV.id
                 LEFT JOIN li_member LM ON LV.author_id = LM.id
        WHERE LMC.collect_type = 'video' and LMC.user_id = #{userId}
        and LV.delete_flag = 0 and LM.delete_flag= 0 and LMC.delete_flag =0
    </select>
 
    <resultMap id="storeBaseResult" type="cn.lili.modules.store.entity.vos.StoreBasicInfoVO">
        <id column="id" property="storeId"/>
        <result column="store_name" property="storeName"/>
        <result column="company_address_path" property="companyAddressPath"/>
        <result column="store_logo" property="storeLogo"/>
        <result column="store_desc" property="storeDesc"/>
    </resultMap>
 
    <select id="getStoreCollectPage" resultMap="storeBaseResult">
        SELECT
            LS.*
        FROM lmk_my_collect LMC
                 LEFT JOIN li_store LS
                           ON LMC.ref_id = LS.id
        WHERE LMC.collect_type = 'store' and LMC.user_id = #{userId}
         and  LS.delete_flag= 0 and LMC.delete_flag =0
    </select>
 
    <resultMap id="goodsBaseResult" type="cn.lili.modules.goods.entity.vos.GoodsVO">
        <id column="id" property="id"/>
        <result column="goods_name" property="goodsName"/>
        <result column="price" property="price"/>
        <result column="mobile_intro" property="mobileIntro"/>
        <result column="original" property="original"/>
    </resultMap>
 
    <select id="getGoodsCollectPage" resultMap="goodsBaseResult">
        SELECT
            LG.*
        FROM lmk_my_collect LMC
                 LEFT JOIN li_goods LG
                           ON LMC.ref_id = LG.id
        WHERE LMC.collect_type = 'goods' and LMC.user_id = #{userId}
          and  LG.delete_flag= 0 and LMC.delete_flag =0
    </select>
</mapper>