admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
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
<?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.yeshi.fanli.dao.mybatis.activity.RecommendActivityMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.bus.activity.RecommendActivity">
        <id column="ar_id" property="id" jdbcType="BIGINT" />
        <result column="ar_title" property="title" jdbcType="VARCHAR" />
        <result column="ar_type" property="type" jdbcType="INTEGER" />
        <result column="ar_order_by" property="orderBy" jdbcType="INTEGER" />
        <result column="ar_share_count" property="shareCount" jdbcType="INTEGER" />
        <result column="ar_total_getmoney" property="totalGetMoney"
            jdbcType="VARCHAR" />
        <result column="ar_video_post_picture" property="videoPostPictire"
            jdbcType="VARCHAR" />
        <result column="ar_video_url" property="videoUrl" jdbcType="VARCHAR" />
        <result column="ar_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="ar_top" property="top" jdbcType="BOOLEAN" />
        <result column="ar_start_time" property="startTime" jdbcType="TIMESTAMP" />
        <result column="ar_end_time" property="endTime" jdbcType="TIMESTAMP" />
        <result column="ar_state" property="state" jdbcType="INTEGER" />
 
        <association property="activityUser" column="ar_activity_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.activity.ActivityUserMapper.BaseResultMap" />
 
        <association property="goodsList" column="ar_id"
            select="com.yeshi.fanli.dao.mybatis.activity.RecommendActivityTaoBaoGoodsMapper.selectByActivityId">
        </association>
        <association property="imageList" column="ar_id"
            select="com.yeshi.fanli.dao.mybatis.activity.RecommendActivityImgMapper.getImgByActivityId">
        </association>
 
        <association property="widthAndHeight" column="ar_id"
            select="com.yeshi.fanli.dao.mybatis.activity.RecommendActivityImgMapper.getImgWithAndHeightByActivityId">
        </association>
 
    </resultMap>
 
    <sql id="Base_Column_List">ar_id,ar_title,ar_type,ar_order_by,ar_activity_uid,ar_share_count,ar_total_getmoney,ar_video_post_picture,ar_video_url,ar_create_time,ar_top,ar_start_time,ar_end_time,ar_state
    </sql>
 
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select *,ar_activity_uid AS au_id from yeshi_ec_activity_recommend
        where ar_id = #{id,jdbcType=BIGINT}
    </select>
 
    <select id="getRecommendActivityList" resultMap="BaseResultMap">
        SELECT *,IF(ar_start_time IS NULL,ar_create_time,ar_start_time) AS
        orderbyTime FROM yeshi_ec_activity_recommend
        LEFT JOIN yeshi_ec_activity_user ON ar_activity_uid=au_id
        WHERE IF(ar_start_time IS NULL,TRUE, ar_start_time<![CDATA[<=]]>
        NOW())
        AND IF(ar_end_time IS NULL,TRUE, ar_end_time <![CDATA[>=]]>
        NOW())
        ORDER BY ar_top DESC,ar_order_by ASC,orderbyTime DESC
        LIMIT #{start},#{count}
    </select>
 
    <select id="getRecommendActivityEffectiveCount" resultType="java.lang.Long">
        SELECT count(ar_id) FROM yeshi_ec_activity_recommend
        WHERE IF(ar_start_time IS NULL,TRUE, ar_start_time<![CDATA[<=]]>
        NOW())
        AND IF(ar_end_time IS NULL,TRUE, ar_end_time <![CDATA[>=]]>
        NOW())
    </select>
 
 
    <select id="queryRecommendActivityList" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_activity_recommend t
        LEFT JOIN
        yeshi_ec_activity_user u ON t.ar_activity_uid=u.au_id
        WHERE 1=1
        <if test="title != null and title != '' ">
            AND t.ar_title LIKE '%${title}%'
        </if>
        ORDER BY t.ar_top DESC,t.ar_order_by ASC,t.ar_create_time DESC
        LIMIT ${start},${count}
    </select>
 
    <select id="getRecommendActivityCount" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(t.ar_id),0) FROM yeshi_ec_activity_recommend t
        WHERE 1=1
        <if test="title != null and title != '' ">
            AND t.ar_title LIKE '%${title}%'
        </if>
    </select>
 
 
    <select id="getRecommendActivityListByType" resultMap="BaseResultMap">
        select
        *
        from
        yeshi_ec_activity_recommend left join yeshi_ec_activity_user on
        ar_activity_uid=au_id where ar_type=#{type} order by ar_top
        desc,ar_order_by
        asc,ar_create_time desc limit ${start},${count}
    </select>
 
    <select id="getRecommendActivityCountByType" resultType="java.lang.Long"
        parameterType="java.lang.Integer">
        select
        count(ar_id)
        from yeshi_ec_activity_recommend where
        ar_type=#{type}
    </select>
 
    <delete id="batchDeleteByPrimaryKey" parameterType="int">
        <!-- 批量删除动态信息 -->
        delete from yeshi_ec_activity_recommend where ar_id in
        <foreach item="arids" collection="array" open="(" separator=","
            close=")">
            #{arids}
        </foreach>
    </delete>
 
 
    <select id="getNeedPublish" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_activity_recommend
        LEFT JOIN yeshi_ec_activity_user ON ar_activity_uid= au_id
        WHERE ar_state = 0 AND IF(ar_start_time IS NULL,TRUE, ar_start_time<![CDATA[<=]]>
        NOW())
        AND IF(ar_end_time IS NULL,TRUE, ar_end_time <![CDATA[>=]]>
        NOW())
    </select>
 
    <update id="addShareCount">
        update yeshi_ec_activity_recommend r set
        r.ar_share_count=ar_share_count+#{count} where ar_id=#{id}
    </update>
 
 
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_activity_recommend where ar_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert"
        parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_activity_recommend
        (ar_id,ar_title,ar_type,ar_order_by,ar_activity_uid,ar_share_count,ar_total_getmoney,ar_video_post_picture,ar_video_url,ar_create_time,ar_top,ar_start_time,ar_end_time,ar_state)
        values
        (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{activityUser.id,jdbcType=BIGINT},#{shareCount,jdbcType=INTEGER},#{totalGetMoney,jdbcType=VARCHAR},#{videoPostPictire,jdbcType=VARCHAR},#{videoUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{top,jdbcType=BOOLEAN},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective"
        parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_activity_recommend
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">ar_id,</if>
            <if test="title != null">ar_title,</if>
            <if test="type != null">ar_type,</if>
            <if test="orderBy != null">ar_order_by,</if>
            <if test="activityUser != null">ar_activity_uid,</if>
            <if test="shareCount != null">ar_share_count,</if>
            <if test="totalGetMoney != null">ar_total_getmoney,</if>
            <if test="videoPostPictire != null">ar_video_post_picture,</if>
            <if test="videoUrl != null">ar_video_url,</if>
            <if test="createTime != null">ar_create_time,</if>
            <if test="top != null">ar_top,</if>
            <if test="startTime != null">ar_start_time,</if>
            <if test="endTime != null">ar_end_time,</if>
            <if test="state != null">ar_state,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="orderBy != null">#{orderBy,jdbcType=INTEGER},</if>
            <if test="activityUser != null">#{activityUser.id,jdbcType=BIGINT},</if>
            <if test="shareCount != null">#{shareCount,jdbcType=INTEGER},</if>
            <if test="totalGetMoney != null">#{totalGetMoney,jdbcType=VARCHAR},</if>
            <if test="videoPostPictire != null">#{videoPostPictire,jdbcType=VARCHAR},</if>
            <if test="videoUrl != null">#{videoUrl,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="top != null">#{top,jdbcType=BOOLEAN},</if>
            <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
        parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity">update yeshi_ec_activity_recommend set ar_title =
        #{title,jdbcType=VARCHAR},ar_type =
        #{type,jdbcType=INTEGER},ar_order_by =
        #{orderBy,jdbcType=INTEGER},ar_activity_uid =
        #{activityUser.id,jdbcType=BIGINT},ar_share_count =
        #{shareCount,jdbcType=INTEGER},ar_total_getmoney =
        #{totalGetMoney,jdbcType=VARCHAR},ar_video_post_picture =
        #{videoPostPictire,jdbcType=VARCHAR},ar_video_url =
        #{videoUrl,jdbcType=VARCHAR},ar_create_time =
        #{createTime,jdbcType=TIMESTAMP},ar_top =
        #{top,jdbcType=BOOLEAN},ar_start_time =
        #{startTime,jdbcType=TIMESTAMP},ar_end_time =
        #{endTime,jdbcType=TIMESTAMP},ar_state = #{state,jdbcType=INTEGER}
        where ar_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective"
        parameterType="com.yeshi.fanli.entity.bus.activity.RecommendActivity">
        update yeshi_ec_activity_recommend
        <set>
            <if test="title != null">ar_title=#{title,jdbcType=VARCHAR},</if>
            <if test="type != null">ar_type=#{type,jdbcType=INTEGER},</if>
            <if test="orderBy != null">ar_order_by=#{orderBy,jdbcType=INTEGER},</if>
            <if test="activityUser != null">ar_activity_uid=#{activityUser.id,jdbcType=BIGINT},</if>
            <if test="shareCount != null">ar_share_count=#{shareCount,jdbcType=INTEGER},</if>
            <if test="totalGetMoney != null">ar_total_getmoney=#{totalGetMoney,jdbcType=VARCHAR},</if>
            <if test="videoPostPictire != null">ar_video_post_picture=#{videoPostPictire,jdbcType=VARCHAR},
            </if>
            <if test="videoUrl != null">ar_video_url=#{videoUrl,jdbcType=VARCHAR},</if>
            <if test="createTime != null">ar_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="top != null">ar_top=#{top,jdbcType=BOOLEAN},</if>
            <if test="startTime != null">ar_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
            <if test="state != null">ar_state=#{state,jdbcType=INTEGER},</if>
        </set>
        where ar_id = #{id,jdbcType=BIGINT}
    </update>
</mapper>