yujian
2019-03-27 cdcbed9af813b2a02cdc01eefa24db8bec6b51a9
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
<?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.GoodsClassMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
    <id column="id" property="id" jdbcType="BIGINT"/>
    <result column="name" property="name" jdbcType="VARCHAR"/>
    <result column="picture" property="picture" jdbcType="VARCHAR"/>
    <result column="url" property="url" jdbcType="VARCHAR"/>
    <result column="key" property="key" jdbcType="VARCHAR"/>
    <result column="search_param" property="searchParam" jdbcType="VARCHAR"/>
    <result column="orderby" property="orderby" jdbcType="INTEGER"/>
    <result column="createtime" property="createtime" jdbcType="BIGINT"/>
    <result column="ios_click" property="iosClick" jdbcType="BIGINT"/>
    <result column="android_click" property="androidClick" jdbcType="BIGINT"/>
  </resultMap>
  
   <sql id="Base_Column_List">id,`name`,picture,`key`,search_param,orderby,createtime,ios_click,android_click</sql>
  
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
          select * from yeshi_ec_class where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_class where id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_class (id,`name`,picture,url,`key`,search_param,orderby,createtime,ios_click,android_click) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{url,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{searchParam,jdbcType=VARCHAR},#{orderby,jdbcType=INTEGER},#{createtime,jdbcType=BIGINT},#{iosClick,jdbcType=BIGINT},#{androidClick,jdbcType=BIGINT})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_class
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">id,</if>
      <if test="name != null">`name`,</if>
      <if test="picture != null">picture,</if>
      <if test="url != null">url,</if>
      <if test="key != null">`key`,</if>
      <if test="searchParam != null">search_param,</if>
      <if test="orderby != null">orderby,</if>
      <if test="createtime != null">createtime,</if>
      <if test="iosClick != null">ios_click,</if>
      <if test="androidClick != null">android_click,</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="url != null">#{url,jdbcType=VARCHAR},</if>
      <if test="key != null">#{key,jdbcType=VARCHAR},</if>
      <if test="searchParam != null">#{searchParam,jdbcType=VARCHAR},</if>
      <if test="orderby != null">#{orderby,jdbcType=INTEGER},</if>
      <if test="createtime != null">#{createtime,jdbcType=BIGINT},</if>
      <if test="iosClick != null">#{iosClick,jdbcType=BIGINT},</if>
      <if test="androidClick != null">#{androidClick,jdbcType=BIGINT},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">update yeshi_ec_class set `name` = #{name,jdbcType=VARCHAR},picture = #{picture,jdbcType=VARCHAR},url = #{url,jdbcType=VARCHAR},`key` = #{key,jdbcType=VARCHAR},search_param = #{searchParam,jdbcType=VARCHAR},orderby = #{orderby,jdbcType=INTEGER},createtime = #{createtime,jdbcType=BIGINT},ios_click = #{iosClick,jdbcType=BIGINT},android_click = #{androidClick,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">update yeshi_ec_class
    <set>
      <if test="name != null">`name`=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="url != null">url=#{url,jdbcType=VARCHAR},</if>
      <if test="key != null">`key`=#{key,jdbcType=VARCHAR},</if>
      <if test="searchParam != null">search_param=#{searchParam,jdbcType=VARCHAR},</if>
      <if test="orderby != null">orderby=#{orderby,jdbcType=INTEGER},</if>
      <if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if>
      <if test="iosClick != null">ios_click=#{iosClick,jdbcType=BIGINT},</if>
      <if test="androidClick != null">android_click=#{androidClick,jdbcType=BIGINT},</if>
    </set> where id = #{id,jdbcType=BIGINT}
  </update>
  
  
    <select id="getKeysById" resultType="java.lang.String">
        SELECT ec.`key` FROM `yeshi_ec_class` ec WHERE ec.`id` = #{id};
    </select>
     
     <select id="listGoodsClassBySystemId" resultMap="BaseResultMap">
         SELECT c.id,c.name,c.picture,c.url FROM `yeshi_ec_class` c
        RIGHT JOIN `yeshi_ec_super_goodsclass` sp ON sp.`goodsclass_id` = c.`id`
        WHERE sp.`system_id` = #{systemId}
        ORDER BY c.`orderby`
     </select>
     
     <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_class fd 
        WHERE  1=1
        <if test="type == -1">
            AND fd.`orderby` <![CDATA[<]]> #{order}  
            ORDER BY fd.`orderby` desc
        </if>
        
        <if test="type == 1">
            AND fd.`orderby` <![CDATA[>]]> #{order}  
            ORDER BY fd.`orderby` 
        </if>
        LIMIT 1
   </select>
   
     
     <select id="getGoodsClassAll" resultMap="BaseResultMap">
         SELECT *  FROM yeshi_ec_class rs ORDER BY rs.`orderby`
     </select>
     
     <select id="listByName" resultMap="BaseResultMap">
         SELECT *  from yeshi_ec_class rs 
         WHERE rs.name like '%#{name}%'
         LIMIT ${start},${count}
     </select>
     
     <select id="countByName" resultType="java.lang.Integer">
         SELECT  IFNULL(COUNT(rs.id),0) FROM yeshi_ec_class rs 
         <if test="systemId != null">
            RIGHT JOIN yeshi_ec_super_goodsclass sp ON sp.`goodsclass_id` = rs.`id` 
        </if>
        WHERE rs.name LIKE '%#{name}%' 
            <if test="systemId != null">
                AND sp.`system_id` = #{systemId}
            </if>
     </select>
     
     <select id="getMaxOrder" resultType="java.lang.Integer">
         SELECT IFNULL(MAX(orderby),0) FROM `yeshi_ec_class`
     </select>
</mapper>