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
<?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.GoodsSubClassMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.clazz.GoodsSubClass">
    <id column="sub_id" property="id" jdbcType="BIGINT"/>
    <result column="sub_name" property="name" jdbcType="VARCHAR"/>
    <result column="sub_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="sub_weight" property="weight" jdbcType="INTEGER"/>
    <result column="sub_level" property="level" jdbcType="INTEGER"/>
    <result column="sub_state" property="state" jdbcType="INTEGER"/>
    <result column="sub_key" property="key" jdbcType="VARCHAR"/>
    <result column="sub_search_json" property="searchJson" jdbcType="VARCHAR"/>
    <result column="sub_ios_click" property="iosClick" jdbcType="BIGINT"/>
    <result column="sub_android_click" property="androidClick" jdbcType="BIGINT"/>
    <result column="sub_createtime" property="createtime" jdbcType="TIMESTAMP"/>
    <result column="sub_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
    
    <association property="rootClass" column="sub_root_id" 
        select="com.yeshi.fanli.dao.mybatis.GoodsClassMapper.selectByPrimaryKey"> 
    </association>
    
    <association property="parent" column="sub_pid" 
        select="com.yeshi.fanli.dao.mybatis.GoodsSubClassMapper.selectByPrimaryKey"> 
    </association>
    
  </resultMap>
  <sql id="Base_Column_List">sub_id,sub_name,sub_picture,sub_weight,sub_root_id,sub_pid,sub_level,sub_state,sub_key,sub_search_json,sub_ios_click,sub_android_click,sub_createtime,sub_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_sub_class where sub_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_sub_class where sub_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_sub_class (sub_id,sub_name,sub_picture,sub_weight,sub_root_id,sub_pid,sub_level,sub_state,sub_key,sub_search_json,sub_ios_click,sub_android_click,sub_createtime,sub_updatetime) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{weight,jdbcType=INTEGER},#{rootClass.id,jdbcType=BIGINT},#{parent.id,jdbcType=BIGINT},#{level,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{key,jdbcType=VARCHAR},#{searchJson,jdbcType=VARCHAR},#{iosClick,jdbcType=BIGINT},#{androidClick,jdbcType=BIGINT},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_sub_class
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">sub_id,</if>
      <if test="name != null">sub_name,</if>
      <if test="picture != null">sub_picture,</if>
      <if test="weight != null">sub_weight,</if>
      <if test="rootClass != null">sub_root_id,</if>
      <if test="parent != null">sub_pid,</if>
      <if test="level != null">sub_level,</if>
      <if test="state != null">sub_state,</if>
      <if test="key != null">sub_key,</if>
      <if test="searchJson != null">sub_search_json,</if>
      <if test="iosClick != null">sub_ios_click,</if>
      <if test="androidClick != null">sub_android_click,</if>
      <if test="createtime != null">sub_createtime,</if>
      <if test="updatetime != null">sub_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="weight != null">#{weight,jdbcType=INTEGER},</if>
      <if test="rootClass != null">#{rootClass.id,jdbcType=BIGINT},</if>
      <if test="parent != null">#{parent.id,jdbcType=BIGINT},</if>
      <if test="level != null">#{level,jdbcType=INTEGER},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="key != null">#{key,jdbcType=VARCHAR},</if>
      <if test="searchJson != null">#{searchJson,jdbcType=VARCHAR},</if>
      <if test="iosClick != null">#{iosClick,jdbcType=BIGINT},</if>
      <if test="androidClick != null">#{androidClick,jdbcType=BIGINT},</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.bus.clazz.GoodsSubClass">update yeshi_ec_sub_class set sub_name = #{name,jdbcType=VARCHAR},sub_picture = #{picture,jdbcType=VARCHAR},sub_weight = #{weight,jdbcType=INTEGER},sub_root_id = #{rootClass.id,jdbcType=BIGINT},sub_pid = #{parent.id,jdbcType=BIGINT},sub_level = #{level,jdbcType=INTEGER},sub_state = #{state,jdbcType=INTEGER}, sub_key = #{key,jdbcType=VARCHAR},sub_search_json = #{searchJson,jdbcType=VARCHAR},sub_ios_click = #{iosClick,jdbcType=BIGINT},sub_android_click = #{androidClick,jdbcType=BIGINT},sub_createtime = #{createtime,jdbcType=TIMESTAMP},sub_updatetime = #{updatetime,jdbcType=TIMESTAMP} where sub_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClass">update yeshi_ec_sub_class
    <set>
      <if test="name != null">sub_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">sub_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="weight != null">sub_weight=#{weight,jdbcType=INTEGER},</if>
      <if test="rootClass != null">sub_root_id=#{rootClass.id,jdbcType=BIGINT},</if>
      <if test="parent != null">sub_pid=#{parent.id,jdbcType=BIGINT},</if>
      <if test="level != null">sub_level=#{level,jdbcType=INTEGER},</if>
      <if test="level != null">sub_state=#{state,jdbcType=INTEGER},</if>
      <if test="key != null">sub_key=#{key,jdbcType=VARCHAR},</if>
      <if test="searchJson != null">sub_search_json=#{searchJson,jdbcType=VARCHAR},</if>
      <if test="iosClick != null">sub_ios_click=#{iosClick,jdbcType=BIGINT},</if>
      <if test="androidClick != null">sub_android_click=#{androidClick,jdbcType=BIGINT},</if>
      <if test="createtime != null">sub_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">sub_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
    </set> where sub_id = #{id,jdbcType=BIGINT}
  </update>
  
   <select id="queryByRootId" resultMap="BaseResultMap">
      <!-- 条件二级类别 -->
    SELECT  <include refid="Base_Column_List" />  FROM yeshi_ec_sub_class 
        WHERE sub_root_id = #{rootId} 
        <if test="state != null">
            and sub_state = #{state}
        </if>
        
        ORDER BY sub_weight,sub_updatetime
   </select>
   
   <select id="queryByPid" resultMap="BaseResultMap">
      <!-- 条件二级类别 -->
    SELECT  <include refid="Base_Column_List" />  FROM yeshi_ec_sub_class 
        WHERE sub_pid = #{pid}
        <if test="state != null">
            and sub_state = #{state}
        </if>
        ORDER BY sub_weight,sub_updatetime
   </select>
   
    <select id="queryByRootIdAndWeight" resultMap="BaseResultMap">
        SELECT  <include refid="Base_Column_List" />  FROM yeshi_ec_sub_class 
        WHERE  sub_root_id = ${rootId} 
        <if test="type == -1">
            <![CDATA[and sub_weight < #{weight} ]]>  
            order by sub_weight desc
        </if>
        
        <if test="type == 1">
            <![CDATA[and sub_weight > #{weight} ]]>  
            order by sub_weight 
        </if>
        
   </select>
   
    <select id="queryByPidAndWeight" resultMap="BaseResultMap">
          SELECT  <include refid="Base_Column_List" />  FROM yeshi_ec_sub_class 
        WHERE sub_pid = ${pid} 
 
        <if test="type == -1">
            <![CDATA[and sub_weight < #{weight} ]]>  
            order by sub_weight desc
        </if>
        
        <if test="type == 1">
            <![CDATA[and sub_weight > #{weight} ]]>  
            order by sub_weight 
        </if>
   </select>
  
   <select id="countByRootId" resultType="java.lang.Integer">
      <!-- 条件二级类别 -->
    SELECT  count(sub_id)  FROM yeshi_ec_sub_class 
        WHERE sub_root_id = ${rootId} ORDER BY sub_weight 
   </select>
   
   <select id="countByPid" resultType="java.lang.Integer">
      <!-- 条件二级类别 -->
    SELECT  count(sub_id)  FROM yeshi_ec_sub_class 
        WHERE sub_pid = ${pid} ORDER BY sub_weight 
   </select>
   
   
    <select id="getMaxWeightByRootId" resultType="java.lang.Integer">
      <!-- 条件二级类别 -->
        SELECT IFNULL(MAX(c.`sub_weight`),0) FROM `yeshi_ec_sub_class` c WHERE c.`sub_root_id` = ${rootId}
   </select>
   
   <select id="getMaxWeightByPid" resultType="java.lang.Integer">
      <!-- 条件二级类别 -->
        SELECT IFNULL(MAX(c.`sub_weight`),0) FROM `yeshi_ec_sub_class` c WHERE c.`sub_root_id` = ${rootId}
   </select>
  
</mapper>