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
<?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.BrandClassShopMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.brand.BrandClassShop">
    <id column="bcs_id" property="id" jdbcType="BIGINT"/>
    <result column="bcs_top" property="top" jdbcType="INTEGER"/>
    <result column="bcs_orderby" property="orderby" jdbcType="INTEGER"/>
    <result column="bcs_browse_num" property="browseNum" jdbcType="BIGINT"/>
    <result column="bcs_state" property="state" jdbcType="INTEGER"/>
    <result column="bcs_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bcs_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="bcs_cid" property="brandClass" javaType="com.yeshi.fanli.entity.brand.BrandClass">
        <id column="bcs_cid" property="id" jdbcType="BIGINT" />    
    </association>
     <association column="bcs_shop_id" property="shop" 
        resultMap="com.yeshi.fanli.dao.mybatis.taobao.TaoBaoShopMapper.BaseResultMap">
    </association>
  </resultMap>
  
  
  <resultMap id="BaseResultAllMap" type="com.yeshi.fanli.entity.brand.BrandClassShop">
    <id column="bcs_id" property="id" jdbcType="BIGINT"/>
    <result column="bcs_top" property="top" jdbcType="INTEGER"/>
    <result column="bcs_orderby" property="orderby" jdbcType="INTEGER"/>
    <result column="bcs_browse_num" property="browseNum" jdbcType="BIGINT"/>
    <result column="bcs_state" property="state" jdbcType="INTEGER"/>
    <result column="bcs_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bcs_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="bcs_cid" property="brandClass" 
           resultMap="com.yeshi.fanli.dao.mybatis.brand.BrandClassMapper.BaseResultMap">
    </association>
     <association column="bcs_shop_id" property="shop" 
         resultMap="com.yeshi.fanli.dao.mybatis.taobao.TaoBaoShopMapper.BaseResultMap">
    </association>
    
  </resultMap>
  
  <sql id="Base_Column_List">bcs_id,bcs_cid,bcs_shop_id,bcs_top,bcs_orderby,bcs_browse_num,bcs_state,bcs_create_time,bcs_update_time,bcs_shop_id AS tsi_id</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_brand_class_shop where bcs_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_brand_class_shop where bcs_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandClassShop" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_class_shop (bcs_id,bcs_cid,bcs_shop_id,bcs_top,bcs_orderby,bcs_browse_num,bcs_state,bcs_create_time,bcs_update_time) values (#{id,jdbcType=BIGINT},#{brandClass.id,jdbcType=BIGINT},#{shop.id,jdbcType=BIGINT},#{top,jdbcType=INTEGER},#{orderby,jdbcType=INTEGER},#{browseNum,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.BrandClassShop" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_class_shop
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">bcs_id,</if>
      <if test="brandClass != null">bcs_cid,</if>
      <if test="shop != null">bcs_shop_id,</if>
      <if test="top != null">bcs_top,</if>
      <if test="orderby != null">bcs_orderby,</if>
      <if test="browseNum != null">bcs_browse_num,</if>
      <if test="state != null">bcs_state,</if>
      <if test="createTime != null">bcs_create_time,</if>
      <if test="updateTime != null">bcs_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="shop != null">#{shop.id,jdbcType=BIGINT},</if>
      <if test="top != null">#{top,jdbcType=INTEGER},</if>
      <if test="orderby != null">#{orderby,jdbcType=INTEGER},</if>
      <if test="browseNum != null">#{browseNum,jdbcType=BIGINT},</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.BrandClassShop">update yeshi_ec_brand_class_shop set bcs_cid = #{brandClass.id,jdbcType=BIGINT},bcs_shop_id = #{shop.id,jdbcType=BIGINT},bcs_top = #{top,jdbcType=INTEGER},bcs_orderby = #{orderby,jdbcType=INTEGER},bcs_browse_num = #{browseNum,jdbcType=BIGINT},bcs_state = #{state,jdbcType=INTEGER},bcs_create_time = #{createTime,jdbcType=TIMESTAMP},bcs_update_time = #{updateTime,jdbcType=TIMESTAMP} where bcs_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.BrandClassShop">update yeshi_ec_brand_class_shop
    <set>
      <if test="brandClass != null">bcs_cid=#{brandClass.id,jdbcType=BIGINT},</if>
      <if test="shop != null">bcs_shop_id=#{shop.id,jdbcType=BIGINT},</if>
      <if test="top != null">bcs_top=#{top,jdbcType=INTEGER},</if>
      <if test="orderby != null">bcs_orderby=#{orderby,jdbcType=INTEGER},</if>
      <if test="browseNum != null">bcs_browse_num=#{browseNum,jdbcType=BIGINT},</if>
      <if test="state != null">bcs_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">bcs_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">bcs_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where bcs_id = #{id,jdbcType=BIGINT}
  </update>
  
  
   <delete id="deleteBatchByClassId" parameterType="java.util.List">
        delete from yeshi_ec_brand_class_shop WHERE bcs_cid in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
   </delete>
  
  <select id="listEffective" resultMap="BaseResultMap">
      SELECT * FROM  yeshi_ec_brand_class_shop b
    LEFT JOIN `yeshi_ec_taobao_shop_info` p ON b.`bcs_shop_id` = p.`tsi_id`
    WHERE b.bcs_state = 1
        <if test="cid != null and cid !=0 ">
            AND b.`bcs_cid` = #{cid}
        </if>
    ORDER BY b.`bcs_top`,bcs_orderby
  </select>
  
  <select id="countEffective" resultType="Long">
      SELECT IFNULL(COUNT(b.`bcs_cid`),0) FROM  yeshi_ec_brand_class_shop b
    LEFT JOIN `yeshi_ec_taobao_shop_info` p ON b.`bcs_shop_id` = p.`tsi_id`
    WHERE b.bcs_state = 1 
        <if test="cid != null and cid !=0 ">
            AND b.`bcs_cid` = #{cid}
        </if>
  </select>
  
   <select id="getExistByShopIds" parameterType="java.util.List" resultMap="BaseResultAllMap">
      SELECT * FROM  yeshi_ec_brand_class_shop cp
      LEFT JOIN `yeshi_ec_taobao_shop_info` p ON p.`tsi_id` = cp.`bcs_shop_id`
      LEFT JOIN `yeshi_ec_brand_class` c ON c.`bc_id` = cp.`bcs_cid`
    WHERE cp.bcs_shop_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
  </select>
  
   <select id="getByShopIdAndCid" resultMap="BaseResultAllMap">
      SELECT * FROM  yeshi_ec_brand_class_shop
    WHERE bcs_shop_id = #{shopId} AND bcs_cid = #{cid}
    limit 1
  </select>
  
   <select id="getByShopId" resultMap="BaseResultAllMap">
      SELECT * FROM  yeshi_ec_brand_class_shop
    WHERE bcs_shop_id = #{shopId}
    limit 1
  </select>
  
  <select id="getMaxOrder" resultType="Integer">
      SELECT IFNULL(COUNT(bcs_id),0) FROM  yeshi_ec_brand_class_shop
    WHERE bcs_cid = #{cid}
  </select>
  
  
   <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_brand_class_shop
        WHERE bcs_cid = #{cid}
        <if test="type == -1">
            AND bcs_orderby <![CDATA[<]]> #{order}  
            ORDER BY bcs_orderby desc
        </if>
        
        <if test="type == 1">
            AND bcs_orderby <![CDATA[>]]> #{order}  
            ORDER BY bcs_orderby 
        </if>
        LIMIT 1
   </select>
  
  <select id="listQuery" resultMap="BaseResultAllMap">
      SELECT * FROM `yeshi_ec_brand_class_shop` cp
    LEFT JOIN `yeshi_ec_taobao_shop_info` p ON p.`tsi_id` = cp.`bcs_shop_id`
    LEFT JOIN `yeshi_ec_brand_class` c ON c.`bc_id` = cp.`bcs_cid`
    WHERE 1=1
        <if test="key != null and key !='' ">
              AND p.`tsi_shop_name` LIKE '%${key}%' or p.`tsi_seller_nick` LIKE '%${key}%'
          </if>
          
          <if test="cid != null">
              AND cp.`bcs_cid` = #{cid}
          </if>
          
          <if test="state != null">
              AND cp.`bcs_state` = #{state}
          </if>
    ORDER BY cp.`bcs_top` DESC,cp.`bcs_orderby`
      LIMIT ${start},${count}
  </select>
  
  <select id="countQuery" resultType="java.lang.Long">
     SELECT IFNULL(COUNT(cp.bcs_id),0) FROM `yeshi_ec_brand_class_shop` cp
     LEFT JOIN `yeshi_ec_taobao_shop_info` p ON p.`tsi_id` = cp.`bcs_shop_id`
     WHERE 1=1
        <if test="key != null and key !='' ">
              AND p.`tsi_shop_name` LIKE '%${key}%' or p.`tsi_seller_nick` LIKE '%${key}%'
          </if>
          
          <if test="cid != null">
              AND cp.`bcs_cid` = #{cid}
          </if>
          
          <if test="state != null">
              AND cp.`bcs_state` = #{state}
          </if>
  </select>
  
  
</mapper>