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
<?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.BrandClassMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.brand.BrandClass">
    <id column="bc_id" property="id" jdbcType="BIGINT"/>
    <result column="bc_name" property="name" jdbcType="VARCHAR"/>
    <result column="bc_state" property="state" jdbcType="INTEGER"/>
    <result column="bc_orderby" property="orderBy" jdbcType="INTEGER"/>
    <result column="bc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    
    <association column="bc_gclass_id" property="goodsClass" javaType="com.yeshi.fanli.entity.bus.clazz.GoodsClass">
        <id column="bc_gclass_id" property="id" jdbcType="BIGINT" />    
    </association>
    
  </resultMap>
  <sql id="Base_Column_List">bc_id,bc_name,bc_gclass_id,bc_state,bc_orderby,bc_create_time,bc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_brand_class where bc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_brand_class where bc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_class (bc_id,bc_name,bc_gclass_id,bc_state,bc_orderby,bc_create_time,bc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{goodsClass.id,jdbcType=BIGINT},#{state,jdbcType=INTEGER},#{orderBy,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.BrandClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_class
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">bc_id,</if>
      <if test="name != null">bc_name,</if>
      <if test="goodsClass != null">bc_gclass_id,</if>
      <if test="state != null">bc_state,</if>
      <if test="orderBy != null">bc_orderby,</if>
      <if test="createTime != null">bc_create_time,</if>
      <if test="updateTime != null">bc_update_time,</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="goodsClass != null">#{goodsClass.id,jdbcType=BIGINT},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="orderBy != null">#{orderBy,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.BrandClass">update yeshi_ec_brand_class set bc_name = #{name,jdbcType=VARCHAR},bc_gclass_id = #{goodsClass.id,jdbcType=BIGINT},bc_state = #{state,jdbcType=INTEGER},bc_orderby = #{orderBy,jdbcType=INTEGER},bc_create_time = #{createTime,jdbcType=TIMESTAMP},bc_update_time = #{updateTime,jdbcType=TIMESTAMP} where bc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.BrandClass">update yeshi_ec_brand_class
    <set>
      <if test="name != null">bc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="goodsClass != null">bc_gclass_id=#{goodsClass.id,jdbcType=BIGINT},</if>
      <if test="state != null">bc_state=#{state,jdbcType=INTEGER},</if>
      <if test="orderBy != null">bc_orderby=#{orderBy,jdbcType=INTEGER},</if>
      <if test="createTime != null">bc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">bc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where bc_id = #{id,jdbcType=BIGINT}
  </update>
  
  <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
        delete from yeshi_ec_brand_class WHERE bc_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
   </delete>
  
  <select id="listEffective" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_class 
    WHERE bc_state = 1
    ORDER BY bc_orderby
  </select>
  
  <select id="getMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(bc_orderby),0) FROM yeshi_ec_brand_class
  </select>
  
   <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_brand_class
        WHERE  1=1
        <if test="type == -1">
            AND bc_orderby <![CDATA[<]]> #{order}  
            ORDER BY bc_orderby desc
        </if>
        
        <if test="type == 1">
            AND bc_orderby <![CDATA[>]]> #{order}  
            ORDER BY bc_orderby 
        </if>
        LIMIT 1
   </select>
  
   <select id="listQuery" resultMap="BaseResultMap">
      SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_brand_class
      WHERE 1=1 
          <if test="key != null and key !='' ">
              AND bc_name LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND bc_state = #{state}
          </if>
      ORDER BY bc_orderby
      LIMIT ${start},${count}
  </select>
  
  <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(bc_id),0) FROM yeshi_ec_brand_class
      WHERE 1=1 
          <if test="key != null and key !='' ">
              AND bc_name LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND  bc_state =  #{state}
          </if>
  </select>
</mapper>