admin
2020-04-13 dd5b15229cb15459fa7c31ccea77dac28cbfafbd
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
<?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.brand.BrandInfoMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.brand.BrandInfo">
    <id column="bf_id" property="id" jdbcType="BIGINT"/>
    <result column="bf_name" property="name" jdbcType="VARCHAR"/>
    <result column="bf_icon" property="icon" jdbcType="VARCHAR"/>
    <result column="bf_shop_key" property="shopKey" jdbcType="VARCHAR"/>
    <result column="bf_search_key" property="searchKey" jdbcType="VARCHAR"/>
    <result column="bf_shop_key_jd" property="shopKeyJD" jdbcType="VARCHAR"/>
    <result column="bf_search_key_jd" property="searchKeyJD" jdbcType="VARCHAR"/>
    <result column="bf_shop_key_pdd" property="shopKeyPDD" jdbcType="VARCHAR"/>
    <result column="bf_search_key_pdd" property="searchKeyPDD" jdbcType="VARCHAR"/>
    <result column="bf_goods_total" property="goodsTotal" jdbcType="INTEGER"/>
    <result column="bf_shop_total" property="shopTotal" jdbcType="INTEGER"/>
    <result column="bf_weight" property="weight" jdbcType="DOUBLE"/>
    <result column="bf_order" property="order" jdbcType="INTEGER"/>
    <result column="bf_state" property="state" jdbcType="INTEGER"/>
    <result column="bf_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bf_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="bf_cid" property="brandClass" javaType="com.yeshi.fanli.entity.brand.BrandClass">
        <id column="bf_cid" property="id" jdbcType="BIGINT" />    
    </association>
  </resultMap>
  
   <resultMap id="ResultVOMap" type="com.yeshi.fanli.vo.brand.BrandInfoVO">
    <id column="bf_id" property="id" jdbcType="BIGINT"/>
    <result column="bf_name" property="name" jdbcType="VARCHAR"/>
    <result column="bf_icon" property="icon" jdbcType="VARCHAR"/>
    <result column="bf_shop_key" property="shopKey" jdbcType="VARCHAR"/>
    <result column="bf_search_key" property="searchKey" jdbcType="VARCHAR"/>
    <result column="bf_shop_key_jd" property="shopKeyJD" jdbcType="VARCHAR"/>
    <result column="bf_search_key_jd" property="searchKeyJD" jdbcType="VARCHAR"/>
    <result column="bf_shop_key_pdd" property="shopKeyPDD" jdbcType="VARCHAR"/>
    <result column="bf_search_key_pdd" property="searchKeyPDD" jdbcType="VARCHAR"/>
    <result column="bf_goods_total" property="goodsTotal" jdbcType="INTEGER"/>
    <result column="bf_shop_total" property="shopTotal" jdbcType="INTEGER"/>
    <result column="bf_weight" property="weight" jdbcType="DOUBLE"/>
    <result column="bf_order" property="order" jdbcType="INTEGER"/>
    <result column="bf_state" property="state" jdbcType="INTEGER"/>
    <result column="bf_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bf_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    
    <association column="bf_cid" property="brandClass" javaType="com.yeshi.fanli.entity.brand.BrandClass">
        <id column="bf_cid" property="id" jdbcType="BIGINT" />    
    </association>
  </resultMap>
  
  <sql id="Base_Column_List">bf_id,bf_cid,bf_name,bf_icon,bf_shop_key,bf_search_key,bf_shop_key_jd,bf_search_key_jd,bf_shop_key_pdd,bf_search_key_pdd,bf_goods_total,bf_shop_total,bf_weight,bf_order,bf_state,bf_create_time,bf_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_brand_info where bf_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_brand_info where bf_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_info (bf_id,bf_cid,bf_name,bf_icon,bf_shop_key,bf_search_key,bf_shop_key_jd,bf_search_key_jd,bf_shop_key_pdd,bf_search_key_pdd,bf_goods_total,bf_shop_total,bf_weight,bf_order,bf_state,bf_create_time,bf_update_time) values (#{id,jdbcType=BIGINT},#{brandClass.id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{shopKey,jdbcType=VARCHAR},#{searchKey,jdbcType=VARCHAR},#{shopKeyJD,jdbcType=VARCHAR},#{searchKeyJD,jdbcType=VARCHAR},#{shopKeyPDD,jdbcType=VARCHAR},#{searchKeyPDD,jdbcType=VARCHAR},#{goodsTotal,jdbcType=INTEGER},#{shopTotal,jdbcType=INTEGER},#{weight,jdbcType=DOUBLE},#{order,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.BrandInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">bf_id,</if>
      <if test="brandClass != null">bf_cid,</if>
      <if test="name != null">bf_name,</if>
      <if test="icon != null">bf_icon,</if>
      <if test="shopKey != null">bf_shop_key,</if>
      <if test="searchKey != null">bf_search_key,</if>
      <if test="shopKeyJD != null">bf_shop_key_jd,</if>
      <if test="searchKeyJD != null">bf_search_key_jd,</if>
      <if test="shopKeyPDD != null">bf_shop_key_pdd,</if>
      <if test="searchKeyPDD != null">bf_search_key_pdd,</if>
      <if test="goodsTotal != null">bf_goods_total,</if>
      <if test="shopTotal != null">bf_shop_total,</if>
      <if test="weight != null">bf_weight,</if>
      <if test="order != null">bf_order,</if>
      <if test="state != null">bf_state,</if>
      <if test="createTime != null">bf_create_time,</if>
      <if test="updateTime != null">bf_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="brandClass != null">#{brandClass.id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="icon != null">#{icon,jdbcType=VARCHAR},</if>
      <if test="shopKey != null">#{shopKey,jdbcType=VARCHAR},</if>
      <if test="searchKey != null">#{searchKey,jdbcType=VARCHAR},</if>
      <if test="shopKeyJD != null">#{shopKeyJD,jdbcType=VARCHAR},</if>
      <if test="searchKeyJD != null">#{searchKeyJD,jdbcType=VARCHAR},</if>
      <if test="shopKeyPDD != null">#{shopKeyPDD,jdbcType=VARCHAR},</if>
      <if test="searchKeyPDD != null">#{searchKeyPDD,jdbcType=VARCHAR},</if>
      <if test="goodsTotal != null">#{goodsTotal,jdbcType=INTEGER},</if>
      <if test="shopTotal != null">#{shopTotal,jdbcType=INTEGER},</if>
      <if test="weight != null">#{weight,jdbcType=DOUBLE},</if>
      <if test="order != null">#{order,jdbcType=INTEGER},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.brand.BrandInfo">update yeshi_ec_brand_info set bf_cid = #{brandClass.id,jdbcType=BIGINT},bf_name = #{name,jdbcType=VARCHAR},bf_icon = #{icon,jdbcType=VARCHAR},bf_shop_key = #{shopKey,jdbcType=VARCHAR},bf_search_key = #{searchKey,jdbcType=VARCHAR},bf_shop_key_jd = #{shopKeyJD,jdbcType=VARCHAR},bf_search_key_jd = #{searchKeyJD,jdbcType=VARCHAR},bf_shop_key_pdd = #{shopKeyPDD,jdbcType=VARCHAR},bf_search_key_pdd = #{searchKeyPDD,jdbcType=VARCHAR},bf_goods_total = #{goodsTotal,jdbcType=INTEGER},bf_shop_total = #{shopTotal,jdbcType=INTEGER},bf_weight = #{weight,jdbcType=DOUBLE},bf_order = #{order,jdbcType=INTEGER},bf_state = #{state,jdbcType=INTEGER},bf_create_time = #{createTime,jdbcType=TIMESTAMP},bf_update_time = #{updateTime,jdbcType=TIMESTAMP} where bf_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.BrandInfo">update yeshi_ec_brand_info
    <set>
      <if test="brandClass != null">bf_cid=#{brandClass.id,jdbcType=BIGINT},</if>
      <if test="name != null">bf_name=#{name,jdbcType=VARCHAR},</if>
      <if test="icon != null">bf_icon=#{icon,jdbcType=VARCHAR},</if>
      <if test="shopKey != null">bf_shop_key=#{shopKey,jdbcType=VARCHAR},</if>
      <if test="searchKey != null">bf_search_key=#{searchKey,jdbcType=VARCHAR},</if>
      <if test="shopKeyJD != null">bf_shop_key_jd=#{shopKeyJD,jdbcType=VARCHAR},</if>
      <if test="searchKeyJD != null">bf_search_key_jd=#{searchKeyJD,jdbcType=VARCHAR},</if>
      <if test="shopKeyPDD != null">bf_shop_key_pdd=#{shopKeyPDD,jdbcType=VARCHAR},</if>
      <if test="searchKeyPDD != null">bf_search_key_pdd=#{searchKeyPDD,jdbcType=VARCHAR},</if>
      <if test="goodsTotal != null">bf_goods_total=#{goodsTotal,jdbcType=INTEGER},</if>
      <if test="shopTotal != null">bf_shop_total=#{shopTotal,jdbcType=INTEGER},</if>
      <if test="weight != null">bf_weight=#{weight,jdbcType=DOUBLE},</if>
      <if test="order != null">bf_order=#{order,jdbcType=INTEGER},</if>
      <if test="state != null">bf_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">bf_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">bf_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where bf_id = #{id,jdbcType=BIGINT}
  </update>
  
   <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
    delete from yeshi_ec_brand_info WHERE bf_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
  </delete>
   
  <select id="listBrandInfoVO" resultMap="ResultVOMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1 AND d.bf_goods_total <![CDATA[>=]]> 3  AND d.bf_shop_total <![CDATA[>]]> 0
         <if test="cid != null">AND d.`bf_cid` = #{cid} </if>
    ORDER BY d.`bf_weight` DESC
    LIMIT ${start},${count}
  </select>
  
  <select id="countBrandInfo" resultType="Long">
      SELECT IFNULL(COUNT(d.`bf_id`),0) FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1 AND d.bf_goods_total <![CDATA[>=]]> 3  AND d.bf_shop_total <![CDATA[>]]> 0
         <if test="cid != null">AND d.`bf_cid` = #{cid} </if>
  </select>
  
  <select id="listValidByCidToApp" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1 AND d.`bf_cid` = #{cid}  AND d.bf_goods_total <![CDATA[>=]]>3
          AND d.bf_shop_total <![CDATA[>]]> 0
    ORDER BY d.`bf_order`
  </select>
  
  <select id="countValidByCid" resultType="Long">
      SELECT IFNULL(COUNT(d.`bf_id`),0) FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1  <if test="cid != null">AND d.`bf_cid` = #{cid} </if>
  </select>
  
  <select id="countValidByCidToApp" resultType="Long">
      SELECT IFNULL(COUNT(d.`bf_id`),0) FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1  <if test="cid != null">AND d.`bf_cid` = #{cid} </if>
          AND d.bf_goods_total <![CDATA[>=]]> 3  AND d.bf_shop_total <![CDATA[>]]> 0
  </select>
  
  <select id="listValidAll" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1  
        AND (TO_DAYS(d.`bf_update_time`)<![CDATA[<]]> TO_DAYS(NOW()) 
             OR HOUR(NOW()) - HOUR(d.`bf_update_time`) <![CDATA[>=]]> 2)
    ORDER BY d.`bf_update_time` 
    LIMIT ${start},${count}
  </select>
  
  
  <select id="listQuery" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info
      WHERE 1=1 
          <if test="keys != null">
              AND
              <foreach collection="keys" item="key" open="(" separator="OR" close=")">
                  bf_name LIKE '%${key}%'
              </foreach>
          </if>
          <if test="state != null">
               AND bf_state = #{state}
          </if>
          <if test="showState == 0">
               AND bf_goods_total <![CDATA[<]]> 3  AND bf_shop_total <![CDATA[<=]]> 0
          </if>
          <if test="showState == 1">
              AND bf_state = 1 AND bf_goods_total <![CDATA[>=]]> 3  AND bf_shop_total <![CDATA[>]]> 0
          </if>
          <if test="cid != null">
               AND bf_cid = #{cid}
          </if>
      ORDER BY bf_order
      LIMIT ${start},${count}
  </select>
  
  <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(bf_id),0) FROM yeshi_ec_brand_info
      WHERE 1=1 
          <if test="keys != null">
              AND
              <foreach collection="keys" item="key" open="(" separator="OR" close=")">
                  bf_name LIKE '%${key}%'
              </foreach>
          </if>
          <if test="state != null">
               AND bf_state = #{state}
          </if>
          <if test="showState == 0">
              AND bf_goods_total <![CDATA[<]]> 3  AND bf_shop_total <![CDATA[<=]]> 0
          </if>
          <if test="showState == 1">
              AND bf_state = 1 AND bf_goods_total <![CDATA[>=]]> 3  AND bf_shop_total <![CDATA[>]]> 0
          </if>
          <if test="cid != null">
               AND bf_cid = #{cid}
          </if>
  </select>
  
   <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_brand_info
        WHERE bf_cid = #{cid}
        <if test="type == -1">
            AND bf_order <![CDATA[<]]> #{order}  
            ORDER BY bf_order desc
        </if>
        
        <if test="type == 1">
            AND bf_order <![CDATA[>]]> #{order}  
            ORDER BY bf_order 
        </if>
        LIMIT 1
   </select>
   
   
  <select id="selectByUniqueName" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info
      WHERE bf_name = #{name} AND bf_cid = #{cid}
          <if test="id != null">
               AND bf_id <![CDATA[<>]]> #{id}
          </if>
      LIMIT 1
  </select>
  
  
  <select id="listByAlikeName" resultMap="ResultVOMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1 AND d.bf_goods_total <![CDATA[>=]]> 3  AND d.bf_shop_total <![CDATA[>]]> 0
          AND FIND_IN_SET(#{key},d.bf_name)
    ORDER BY d.`bf_update_time` DESC
  </select>
  
</mapper>