admin
2019-07-30 573c491b4a1ba60e12a5678a01c1546c0077c1ee
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
<?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.push.PushInfoMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.push.PushInfo">
    <id column="pi_id" property="id" jdbcType="BIGINT"/>
    <result column="pi_title" property="title" jdbcType="VARCHAR"/>
    <result column="pi_content" property="content" jdbcType="VARCHAR"/>
    <result column="pi_uids" property="uids" jdbcType="VARCHAR"/>
    <result column="pi_json_data" property="jsonData" jdbcType="VARCHAR"/>
    <result column="pi_control_time" property="controlTime" jdbcType="TIMESTAMP"/>
    <result column="pi_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="pi_state" property="state" jdbcType="INTEGER"/>
    <result column="pi_push_time" property="pushTime" jdbcType="TIMESTAMP"/>
    <result column="pi_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="pi_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <result column="pi_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.PushTypeEnumHandler" />
  </resultMap>
  
  <sql id="Base_Column_List">pi_id,pi_title,pi_content,pi_uids,pi_json_data,pi_type,pi_control_time,pi_remark,pi_state,pi_push_time,pi_create_time,pi_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_push_info where pi_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_push_info where pi_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.push.PushInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_info (pi_id,pi_title,pi_content,pi_uids,pi_json_data,pi_type,pi_control_time,pi_remark,pi_state,pi_push_time,pi_create_time,pi_update_time) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{uids,jdbcType=VARCHAR},#{jsonData,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{controlTime,jdbcType=TIMESTAMP},#{remark,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{pushTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.push.PushInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_push_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">pi_id,</if>
      <if test="title != null">pi_title,</if>
      <if test="content != null">pi_content,</if>
      <if test="uids != null">pi_uids,</if>
      <if test="jsonData != null">pi_json_data,</if>
      <if test="type != null">pi_type,</if>
      <if test="controlTime != null">pi_control_time,</if>
      <if test="remark != null">pi_remark,</if>
      <if test="state != null">pi_state,</if>
      <if test="pushTime != null">pi_push_time,</if>
      <if test="createTime != null">pi_create_time,</if>
      <if test="updateTime != null">pi_update_time,</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="content != null">#{content,jdbcType=VARCHAR},</if>
      <if test="uids != null">#{uids,jdbcType=VARCHAR},</if>
      <if test="jsonData != null">#{jsonData,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="controlTime != null">#{controlTime,jdbcType=TIMESTAMP},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="pushTime != null">#{pushTime,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.push.PushInfo">update yeshi_ec_push_info set pi_title = #{title,jdbcType=VARCHAR},pi_content = #{content,jdbcType=VARCHAR},pi_uids = #{uids,jdbcType=VARCHAR},pi_json_data = #{jsonData,jdbcType=VARCHAR},pi_type = #{type,jdbcType=VARCHAR},pi_control_time = #{controlTime,jdbcType=TIMESTAMP},pi_remark = #{remark,jdbcType=VARCHAR},pi_state = #{state,jdbcType=INTEGER},pi_push_time = #{pushTime,jdbcType=TIMESTAMP},pi_create_time = #{createTime,jdbcType=TIMESTAMP},pi_update_time = #{updateTime,jdbcType=TIMESTAMP} where pi_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.push.PushInfo">update yeshi_ec_push_info
    <set>
      <if test="title != null">pi_title=#{title,jdbcType=VARCHAR},</if>
      <if test="content != null">pi_content=#{content,jdbcType=VARCHAR},</if>
      <if test="uids != null">pi_uids=#{uids,jdbcType=VARCHAR},</if>
      <if test="jsonData != null">pi_json_data=#{jsonData,jdbcType=VARCHAR},</if>
      <if test="type != null">pi_type=#{type,jdbcType=VARCHAR},</if>
      <if test="controlTime != null">pi_control_time=#{controlTime,jdbcType=TIMESTAMP},</if>
      <if test="remark != null">pi_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="state != null">pi_state=#{state,jdbcType=INTEGER},</if>
      <if test="pushTime != null">pi_push_time=#{pushTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">pi_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">pi_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where pi_id = #{id,jdbcType=BIGINT}
  </update>
  
   <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
        delete from yeshi_ec_push_info where pi_push_time is null AND pi_id in
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
   </delete>
  
  <select id="listQuery" resultMap="BaseResultMap">
      SELECT p.*,IF(`pi_control_time` IS NOT NULL,pi_control_time,`pi_create_time`) AS orderyTime FROM  yeshi_ec_push_info p
    WHERE pi_type = #{type}
        <if test="key != null and key !='' ">
            <if test="keyType == 1">AND pi_title like '%#{key}%'</if>
            <if test="keyType == 2">AND pi_content like '%#{key}%'</if>
            <if test="keyType == 3">AND pi_uids like '%#{key}%'</if>
        </if>
        <if  test="state != null">
            AND pi_state = #{state}
        </if>
      ORDER BY orderyTime DESC
      LIMIT ${start},${count}
  </select>
  
  <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(pi_id),0) FROM  yeshi_ec_push_info
    WHERE pi_type = #{type}
        <if test="key != null and key !='' ">
            <if test="keyType == 1">AND pi_title like '%#{key}%'</if>
            <if test="keyType == 2">AND pi_content like '%#{key}%'</if>
            <if test="keyType == 3">AND pi_uids like '%#{key}%'</if>
        </if>
        <if test="state != null">
            AND pi_state = #{state}
        </if>
  </select>  
  
  <select id="listTask" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_ec_push_info` p
    WHERE p.`pi_state` = 0 AND p.`pi_control_time` IS NOT NULL 
          AND p.`pi_control_time` <![CDATA[<=]]> NOW()
  </select>
</mapper>