admin
2020-05-19 744594ef1a2f530fc3e86ea9dc48b62247f79420
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
<?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_picture_second" property="pictureSecond"
            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" />
        <result column="sub_sex" property="sex" jdbcType="INTEGER" />
        <result column="sub_month" property="month" jdbcType="VARCHAR" />
        <association property="rootClass" column="sub_root_id"
            select="com.yeshi.fanli.dao.mybatis.GoodsClassMapper.selectByPrimaryKey" />
        <association property="parent" column="sub_pid"
            select="com.yeshi.fanli.dao.mybatis.GoodsSubClassMapper.selectByPrimaryKey" />
 
    </resultMap>
    <resultMap id="SimpleResultMap"
        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_picture_second" property="pictureSecond"
            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" />
        <result column="sub_sex" property="sex" jdbcType="INTEGER" />
        <result column="sub_month" property="month" jdbcType="VARCHAR" />
        <association property="rootClass" column="sub_root_id"
            javaType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
            <id column="sub_root_id" property="id" jdbcType="BIGINT" />
        </association>
        <association property="parent" column="sub_pid"
            javaType="com.yeshi.fanli.entity.bus.clazz.GoodsSubClass">
            <id column="sub_pid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <sql id="Base_Column_List">sub_id,sub_name,sub_picture,sub_picture_second,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,sub_sex,sub_month
    </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_picture_second,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,sub_sex,sub_month)
        values
        (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{pictureSecond,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},#{sex,jdbcType=INTEGER},#{month,jdbcType=VARCHAR})
    </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="pictureSecond != null">sub_picture_second,</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>
            <if test="sex != null">sub_sex,</if>
            <if test="month != null">sub_month,</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="pictureSecond != null">#{pictureSecond,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>
            <if test="sex != null">#{sex,jdbcType=INTEGER},</if>
            <if test="month != null">#{month,jdbcType=VARCHAR}</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_picture_second =
        #{pictureSecond,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} ,sub_sex =#{sex,jdbcType=INTEGER}
        ,sub_month =#{month,jdbcType=VARCHAR} 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="pictureSecond != null">sub_picture_second=#{pictureSecond,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="state != 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>
            <if test="sex !=null">sub_sex =#{sex,jdbcType=INTEGER},</if>
            <if test="month !=null">sub_month =#{month,jdbcType=VARCHAR},</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 
        LEFT JOIN `yeshi_ec_sub_class_label_map` m ON m.`sclm_sub_class_id`=sub_id LEFT JOIN `yeshi_ec_sub_class_label`  l ON l.`scl_id`=m.`sclm_label_id`
        WHERE sub_root_id = #{rootId} 
        <if test="month != null">
         AND (
          (sub_month is null)
          or
          FIND_IN_SET(#{month},sub_month)
          )
        </if>
        <if test="state != null">AND sub_state = #{state}</if>
        ORDER BY l.`scl_order_by`,m.`sclm_order_by`
    </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}
    </select>
    <select id="countByPid" resultType="java.lang.Integer">
        <!-- 条件二级类别 -->
        SELECT count(sub_id) FROM yeshi_ec_sub_class WHERE sub_pid = ${pid}
    </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>
    <select id="queryByListCid" resultMap="SimpleResultMap">
        SELECT * FROM yeshi_ec_sub_class WHERE sub_state = 1 AND sub_root_id
        in
        <foreach collection="list" index="index" item="item"
            separator="," open="(" close=")">${item}</foreach>
        ORDER BY sub_weight
    </select>
</mapper>