admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
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
<?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.redpack.RedPackConfigMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackConfig">
    <id column="rpc_id" property="id" jdbcType="BIGINT"/>
    <result column="rpc_name" property="name" jdbcType="VARCHAR"/>
    <result column="rpc_key" property="key" jdbcType="VARCHAR"/>
    <result column="rpc_value" property="value" jdbcType="VARCHAR"/>
    <result column="rpc_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="rpc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="rpc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rpc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_config where rpc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_config (rpc_id,rpc_name,rpc_key,rpc_value,rpc_remark,rpc_start_time,rpc_create_time,rpc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{value,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rpc_id,</if>
      <if test="name != null">rpc_name,</if>
      <if test="key != null">rpc_key,</if>
      <if test="value != null">rpc_value,</if>
      <if test="remark != null">rpc_remark,</if>
      <if test="startTime != null">rpc_start_time,</if>
      <if test="createTime != null">rpc_create_time,</if>
      <if test="updateTime != null">rpc_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="key != null">#{key,jdbcType=VARCHAR},</if>
      <if test="value != null">#{value,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</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.redpack.RedPackConfig">update yeshi_ec_red_pack_config set rpc_name = #{name,jdbcType=VARCHAR},rpc_key = #{key,jdbcType=VARCHAR},rpc_value = #{value,jdbcType=VARCHAR},rpc_remark = #{remark,jdbcType=VARCHAR},rpc_start_time = #{startTime,jdbcType=TIMESTAMP},rpc_create_time = #{createTime,jdbcType=TIMESTAMP},rpc_update_time = #{updateTime,jdbcType=TIMESTAMP} where rpc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackConfig">update yeshi_ec_red_pack_config
    <set>
      <if test="name != null">rpc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="key != null">rpc_key=#{key,jdbcType=VARCHAR},</if>
      <if test="value != null">rpc_value=#{value,jdbcType=VARCHAR},</if>
      <if test="remark != null">rpc_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="startTime != null">rpc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">rpc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">rpc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where rpc_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="getByKey" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_red_pack_config t 
      WHERE t.`rpc_key` = #{key} and #{startTime} >= rpc_start_time 
      ORDER BY rpc_start_time DESC LIMIT 1
  </select>
  
  <select id="query" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_red_pack_config` t
    WHERE t.`rpc_name` LIKE '${key}%' OR t.`rpc_value` LIKE '${key}%'
    LIMIT #{start},#{count}
  </select>
  
  <select id="count" resultType="Long">
       SELECT IFNULL(COUNT(t.rpc_id),0) FROM yeshi_ec_red_pack_config t
     WHERE t.`rpc_name` LIKE '${key}%' OR t.`rpc_value` LIKE '${key}%'
  </select>
</mapper>