Administrator
2018-10-30 c0c91fbda1ba601c4c8cb6d12fd43dfbe02eea5d
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
<?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.UserRankingsMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserRankings">
    <id column="r_id" property="id" jdbcType="BIGINT"/>
    <result column="r_show_id" property="showId" jdbcType="VARCHAR"/>
    <result column="r_nick_name" property="nickName" jdbcType="VARCHAR"/>
    <result column="r_portrait" property="portrait" jdbcType="VARCHAR"/>
    <result column="r_trade_reward" property="tradeReward" jdbcType="DECIMAL"/>
    <result column="r_share_reward" property="shareReward" jdbcType="DECIMAL"/>
    <result column="r_trade_state" property="tradeState" jdbcType="INTEGER"/>
    <result column="r_share_state" property="shareState" jdbcType="INTEGER"/>
    <result column="r_trade_time" property="tradeTime" jdbcType="TIMESTAMP"/>
    <result column="r_share_time" property="shareTime" jdbcType="TIMESTAMP"/>
    <result column="r_createtime" property="createtime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">r_id,r_show_id,r_nick_name,r_portrait,r_trade_reward,r_share_reward,r_trade_state,r_share_state,r_trade_time,r_share_time,r_createtime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_rankings_record where r_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_rankings_record where r_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_rankings_record (r_id,r_show_id,r_nick_name,r_portrait,r_trade_reward,r_share_reward,r_trade_state,r_share_state,r_trade_time,r_share_time,r_createtime) values (#{id,jdbcType=BIGINT},#{showId,jdbcType=VARCHAR},#{nickName,jdbcType=VARCHAR},#{portrait,jdbcType=VARCHAR},#{tradeReward,jdbcType=DECIMAL},#{shareReward,jdbcType=DECIMAL},#{tradeState,jdbcType=INTEGER},#{shareState,jdbcType=INTEGER},#{tradeTime,jdbcType=TIMESTAMP},#{shareTime,jdbcType=TIMESTAMP},#{createtime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_rankings_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">r_id,</if>
      <if test="showId != null">r_show_id,</if>
      <if test="nickName != null">r_nick_name,</if>
      <if test="portrait != null">r_portrait,</if>
      <if test="tradeReward != null">r_trade_reward,</if>
      <if test="shareReward != null">r_share_reward,</if>
      <if test="tradeState != null">r_trade_state,</if>
      <if test="shareState != null">r_share_state,</if>
      <if test="tradeTime != null">r_trade_time,</if>
      <if test="shareTime != null">r_share_time,</if>
      <if test="createtime != null">r_createtime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="showId != null">#{showId,jdbcType=VARCHAR},</if>
      <if test="nickName != null">#{nickName,jdbcType=VARCHAR},</if>
      <if test="portrait != null">#{portrait,jdbcType=VARCHAR},</if>
      <if test="tradeReward != null">#{tradeReward,jdbcType=DECIMAL},</if>
      <if test="shareReward != null">#{shareReward,jdbcType=DECIMAL},</if>
      <if test="tradeState != null">#{tradeState,jdbcType=INTEGER},</if>
      <if test="shareState != null">#{shareState,jdbcType=INTEGER},</if>
      <if test="tradeTime != null">#{tradeTime,jdbcType=TIMESTAMP},</if>
      <if test="shareTime != null">#{shareTime,jdbcType=TIMESTAMP},</if>
      <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings">update yeshi_ec_rankings_record set r_show_id = #{showId,jdbcType=VARCHAR},r_nick_name = #{nickName,jdbcType=VARCHAR},r_portrait = #{portrait,jdbcType=VARCHAR},r_trade_reward = #{tradeReward,jdbcType=DECIMAL},r_share_reward = #{shareReward,jdbcType=DECIMAL},r_trade_state = #{tradeState,jdbcType=INTEGER},r_share_state = #{shareState,jdbcType=INTEGER},r_trade_time = #{tradeTime,jdbcType=TIMESTAMP},r_share_time = #{shareTime,jdbcType=TIMESTAMP},r_createtime = #{createtime,jdbcType=TIMESTAMP} where r_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserRankings">update yeshi_ec_rankings_record
    <set>
      <if test="showId != null">r_show_id=#{showId,jdbcType=VARCHAR},</if>
      <if test="nickName != null">r_nick_name=#{nickName,jdbcType=VARCHAR},</if>
      <if test="portrait != null">r_portrait=#{portrait,jdbcType=VARCHAR},</if>
      <if test="tradeReward != null">r_trade_reward=#{tradeReward,jdbcType=DECIMAL},</if>
      <if test="shareReward != null">r_share_reward=#{shareReward,jdbcType=DECIMAL},</if>
      <if test="tradeState != null">r_trade_state=#{tradeState,jdbcType=INTEGER},</if>
      <if test="shareState != null">r_share_state=#{shareState,jdbcType=INTEGER},</if>
      <if test="tradeTime != null">r_trade_time=#{tradeTime,jdbcType=TIMESTAMP},</if>
      <if test="shareTime != null">r_share_time=#{shareTime,jdbcType=TIMESTAMP},</if>
      <if test="createtime != null">r_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
    </set> where r_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="selectByNickName" resultMap="BaseResultMap">
    select
        <include refid="Base_Column_List"/>
    from yeshi_ec_rankings_record where r_nick_name = #{nickName,jdbcType=VARCHAR}
  </select>
  
   <select id="selectByShowId" resultMap="BaseResultMap">
    select
        <include refid="Base_Column_List"/>
    from yeshi_ec_rankings_record where r_show_id = #{showId,jdbcType=VARCHAR}
  </select>
  
   <update id="updateClearTradeState" > 
       update yeshi_ec_rankings_record
        <set>
              r_trade_reward = 0,
              r_trade_state = 0
        </set>
        WHERE  r_trade_state = 1
  </update>
  
   <select id="query" resultMap="BaseResultMap">
      <!-- 根据条件查询所有标签 -->
    SELECT  <include refid="Base_Column_List" />  FROM  yeshi_ec_rankings_record    
            WHERE     <![CDATA[1>0]]>
           <if test='key != null and key != ""'>
                  AND (r_show_id like '%#{key}%' OR r_nick_name like '%#{key}%') 
           </if>
           
           <if test='tradeState != null and  tradeState == 1'>
                  AND  r_trade_state = #{tradeState}
           </if>
            
           <if test='shareState != null and shareState == 1'>
                  AND  r_share_state = #{shareState}
           </if>
           
            <if test='tradeState != null and  tradeState == 0'>
                  AND  (r_trade_state = #{tradeState} or r_trade_state is null)
           </if>
            
           <if test='shareState != null and shareState == 0'>
                  AND  (r_share_state = #{shareState} or r_share_state is null)
           </if>
           
           ORDER BY
           
              <if test='sort==1'>
              r_trade_reward,
              </if>
              <if test='sort==2'>
               r_trade_reward desc,
              </if>
              <if test ='sort==3'>
               r_share_reward,
              </if>
              <if test='sort==4'>
               r_share_reward desc,
              </if>
              <if test='sort==5'>
               r_trade_time,
              </if>
              <if test='sort==6'>
               r_trade_time desc,
              </if>
              <if test='sort==7'>
               r_share_time,
              </if>
              <if test='sort==8'>
              r_share_time desc,
              </if>
                r_createtime LIMIT ${start},${count}
   </select>
  
   <select id="queryCount" resultType="java.lang.Long">
      <!-- 根据条件查询所有标签 -->
    SELECT count(r_id)  FROM  yeshi_ec_rankings_record    
            WHERE     <![CDATA[1>0]]>
           <if test='key != null and key != ""'>
                  AND (r_show_id like '%#{key}%' OR r_nick_name like '%#{key}%') 
           </if>
          <if test='tradeState != null and  tradeState == 1'>
                  AND  r_trade_state = #{tradeState}
           </if>
            
           <if test='shareState != null and shareState == 1'>
                  AND  r_share_state = #{shareState}
           </if>
           
            <if test='tradeState != null and  tradeState == 0'>
                  AND  (r_trade_state = #{tradeState} or r_trade_state is null)
           </if>
            
           <if test='shareState != null and shareState == 0'>
                  AND  (r_share_state = #{shareState} or r_share_state is null)
           </if>
   </select>
   
     <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
          insert into yeshi_ec_rankings_record
         (<include refid="Base_Column_List" />)
        values
          
          <foreach collection="list" item="item" separator=",">
              (
                 #{item.id,jdbcType=BIGINT},
                 #{item.showId,jdbcType=VARCHAR},
                 #{item.nickName,jdbcType=VARCHAR},
                 #{item.portrait,jdbcType=VARCHAR},
                 #{item.tradeReward,jdbcType=DECIMAL},
                 #{item.shareReward,jdbcType=DECIMAL},
                 #{item.tradeState,jdbcType=INTEGER},
                 #{item.shareState,jdbcType=INTEGER},
                 #{item.tradeTime,jdbcType=TIMESTAMP},
                 #{item.shareTime,jdbcType=TIMESTAMP},
                 #{item.createtime,jdbcType=TIMESTAMP}
             )
           
          </foreach>
  </insert>
  
  <update id="updateBatchSelective" parameterType="java.util.List">
      
        update yeshi_ec_rankings_record
            <trim prefix="set" suffixOverrides=",">
                    <trim prefix="r_show_id =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                                <if test="item.showId !=null">
                             when r_id=#{item.id} then #{item.showId}
                                </if>
                        </foreach>
                    </trim>
            
                    <trim prefix="r_nick_name =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                                <if test="item.nickName !=null">
                             when r_id=#{item.id} then #{item.nickName}
                                </if>
                        </foreach>
                    </trim>
                    
                    <trim prefix="r_portrait =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                                <if test="item.portrait !=null">
                             when r_id=#{item.id} then #{item.portrait}
                                </if>
                        </foreach>
                    </trim>
                    
                    <trim prefix="r_trade_reward =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                             <if test="item.tradeReward !=null">
                             when r_id=#{item.id} then #{item.tradeReward}
                                </if>
                        </foreach>
                    </trim>
                    
                    <trim prefix="r_share_reward =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                                <if test="item.shareReward !=null">
                             when r_id=#{item.id} then #{item.shareReward}
                            </if>
                        </foreach>
                    </trim>
                    
                    
                    <trim prefix="r_trade_state =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                             <if test="item.tradeState !=null">
                             when r_id=#{item.id} then #{item.tradeState}
                            </if>
                        </foreach>
                    </trim>
                    
                    <trim prefix="r_share_state =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                                  <if test="item.shareState !=null">
                             when r_id=#{item.id} then #{item.shareState}
                                </if>
                        </foreach>
                    </trim>
                    <trim prefix="r_trade_time =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                                <if test="item.tradeTime !=null">
                             when r_id=#{item.id} then #{item.tradeTime}
                                </if>
                        </foreach>
                    </trim>
                    <trim prefix="r_share_time =case" suffix="end,">
                        <foreach collection="list" item="item" index="index">
                                <if test="item.shareTime !=null">
                             when r_id=#{item.id} then #{item.shareTime}
                                </if>
                        </foreach>
                    </trim>
                    
              </trim>
        where r_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
     </update>
  
  
       <select id="queryAll" resultMap="BaseResultMap">
      <!-- 根据条件查询所有标签 -->
        SELECT  <include refid="Base_Column_List" />  FROM  yeshi_ec_rankings_record    
   </select>
   
    <select id="listQueryByIds" resultMap="BaseResultMap" parameterType="java.util.List">
        SELECT  <include refid="Base_Column_List" />  FROM  yeshi_ec_rankings_record    
         where r_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item,jdbcType=BIGINT}
        </foreach>
   </select>
   
  
</mapper>