yujian
2019-01-22 88b54772dbcf5ecab1e2316e4e4626ac901b8908
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
<?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.help.HelpCenterMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.help.HelpCenter">
    <id column="h_id" property="id" jdbcType="BIGINT"/>
    <result column="h_title" property="title" jdbcType="VARCHAR"/>
    <result column="h_weight" property="weight" jdbcType="INTEGER"/>
    <result column="h_createtime" property="createtime" jdbcType="TIMESTAMP"/>
    <result column="h_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
  </resultMap>
  
  <sql id="Base_Column_List">h_id,h_title,h_weight,h_createtime,h_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}</delete>
  
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_center (h_id,h_title,h_weight,h_createtime,h_updatetime) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{weight,jdbcType=INTEGER},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
 
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_center
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">h_id,</if>
      <if test="title != null">h_title,</if>
      <if test="weight != null">h_weight,</if>
      <if test="createtime != null">h_createtime,</if>
      <if test="updatetime != null">h_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="weight != null">#{weight,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.bus.help.HelpCenter">update yeshi_ec_help_center set h_title = #{title,jdbcType=VARCHAR},h_weight = #{weight,jdbcType=INTEGER},h_createtime = #{createtime,jdbcType=TIMESTAMP},h_updatetime = #{updatetime,jdbcType=TIMESTAMP} where h_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update yeshi_ec_help_center
    <set>
      <if test="title != null">h_title=#{title,jdbcType=VARCHAR},</if>
      <if test="weight != null">h_weight=#{weight,jdbcType=INTEGER},</if>
      <if test="createtime != null">h_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">h_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
    </set> where h_id = #{id,jdbcType=BIGINT}
  </update>
  
   <select id="query" resultMap="BaseResultMap">
      <!-- 根据条件查询所有标签 -->
    SELECT  <include refid="Base_Column_List" />  FROM yeshi_ec_help_center    
        WHERE     <![CDATA[1>0]]>
       <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
       </if>
       
       <if test='orderMode == 1'>
            ORDER BY  h_weight  DESC 
       </if>
       
           <if test='orderMode == 2'>
            ORDER BY  h_weight 
       </if>
      
       <if test='orderMode == 3'>
            ORDER BY  h_createtime  DESC 
       </if>
       
        <if test='orderMode == 4'>
            ORDER BY h_createtime
       </if>
       
        <if test='orderMode == 5'>
            ORDER BY  h_updatetime  DESC 
       </if>
       
        <if test='orderMode == 6'>
            ORDER BY  h_updatetime 
       </if>
       
        LIMIT ${start},${count}
        
   </select>
 
   <select id="countQuery" resultType="java.lang.Long">
    SELECT  count(h_id)  FROM yeshi_ec_help_center    
        WHERE     <![CDATA[1>0]]>
       <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
       </if>
    </select>
    
     <select id="queryIdAndTitle" resultMap="BaseResultMap">
      <!-- 根据条件查询所有标签 -->
    SELECT  h_id, h_title FROM yeshi_ec_help_center    
        WHERE     <![CDATA[1>0]]>
       <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
       </if>
       
        ORDER BY  h_weight  DESC, h_createtime
 
        LIMIT ${start},${count}
   </select>
    
   <delete id="deleteBatchById" parameterType="int">
        <!-- 批量删除  -->
        delete from yeshi_ec_help_center where h_id in
        <foreach item="item" collection="idList" open="(" separator=","
            close=")">
            #{item}
        </foreach>
    </delete>
  
</mapper>