admin
2019-07-11 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?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.homemodule.FloatADMapper">
 
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.homemodule.FloatAD">
    <id column="fa_id" property="id" jdbcType="BIGINT"/>
    <result column="fa_name" property="name" jdbcType="VARCHAR"/>
    <result column="fa_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="fa_show_mode" property="showMode" jdbcType="VARCHAR"/>
    <result column="fa_params" property="params" jdbcType="VARCHAR"/>
    <result column="fa_jump_need_login" property="jumpNeedLogin" jdbcType="VARCHAR"/>
    <result column="fa_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="fa_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="fa_position" property="position" jdbcType="VARCHAR"/>
    <result column="fa_order" property="order" jdbcType="INTEGER"/>
    <result column="fa_type" property="type" jdbcType="INTEGER"/>
    <result column="fa_state" property="state" jdbcType="INTEGER"/>
    <result column="fa_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="fa_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  
    <association property="jumpDetail"  column="fa_jumpid" javaType="com.yeshi.fanli.entity.common.JumpDetailV2">
            <id column="fa_jumpid" property="id" jdbcType="BIGINT" />    
    </association>
    
  </resultMap>
  <sql id="Base_Column_List">fa_id,fa_name,fa_picture,fa_show_mode,fa_jumpid,fa_params,fa_jump_need_login,fa_start_time,fa_end_time,fa_position,fa_order,fa_type,fa_state,fa_create_time,fa_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_float_ad where fa_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_float_ad where fa_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.homemodule.FloatAD" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_float_ad (fa_id,fa_name,fa_picture,fa_show_mode,fa_jumpid,fa_params,fa_jump_need_login,fa_start_time,fa_end_time,fa_position,fa_order,fa_type,fa_state,fa_create_time,fa_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{showMode,jdbcType=VARCHAR},#{jumpDetail.id,jdbcType=BIGINT},#{params,jdbcType=VARCHAR},#{jumpNeedLogin,jdbcType=VARCHAR},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{position,jdbcType=VARCHAR},#{order,jdbcType=INTEGER},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.FloatAD" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_float_ad
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">fa_id,</if>
      <if test="name != null">fa_name,</if>
      <if test="picture != null">fa_picture,</if>
      <if test="showMode != null">fa_show_mode,</if>
      <if test="jumpDetail != null">fa_jumpid,</if>
      <if test="params != null">fa_params,</if>
      <if test="jumpNeedLogin != null">fa_jump_need_login,</if>
      <if test="startTime != null">fa_start_time,</if>
      <if test="endTime != null">fa_end_time,</if>
      <if test="position != null">fa_position,</if>
      <if test="order != null">fa_order,</if>
      <if test="type != null">fa_type,</if>
      <if test="state != null">fa_state,</if>
      <if test="createTime != null">fa_create_time,</if>
      <if test="updateTime != null">fa_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="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="showMode != null">#{showMode,jdbcType=VARCHAR},</if>
      <if test="jumpDetail != null">#{jumpDetail.id,jdbcType=BIGINT},</if>
      <if test="params != null">#{params,jdbcType=VARCHAR},</if>
      <if test="jumpNeedLogin != null">#{jumpNeedLogin,jdbcType=VARCHAR},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="position != null">#{position,jdbcType=VARCHAR},</if>
      <if test="order != null">#{order,jdbcType=INTEGER},</if>
      <if test="type != null">#{type,jdbcType=INTEGER},</if>
      <if test="state != null">#{state,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.homemodule.FloatAD">update yeshi_ec_float_ad set fa_name = #{name,jdbcType=VARCHAR},fa_picture = #{picture,jdbcType=VARCHAR},fa_show_mode = #{showMode,jdbcType=VARCHAR},fa_jumpid = #{jumpDetail.id,jdbcType=BIGINT},fa_params = #{params,jdbcType=VARCHAR},fa_jump_need_login = #{jumpNeedLogin,jdbcType=VARCHAR},fa_start_time = #{startTime,jdbcType=TIMESTAMP},fa_end_time = #{endTime,jdbcType=TIMESTAMP},fa_position = #{position,jdbcType=VARCHAR},fa_order = #{order,jdbcType=INTEGER},fa_type = #{type,jdbcType=INTEGER},fa_state = #{state,jdbcType=INTEGER},fa_create_time = #{createTime,jdbcType=TIMESTAMP},fa_update_time = #{updateTime,jdbcType=TIMESTAMP} where fa_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.homemodule.FloatAD">update yeshi_ec_float_ad
    <set>
      <if test="name != null">fa_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">fa_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="showMode != null">fa_show_mode=#{showMode,jdbcType=VARCHAR},</if>
      <if test="jumpDetail != null">fa_jumpid=#{jumpDetail.id,jdbcType=BIGINT},</if>
      <if test="params != null">fa_params=#{params,jdbcType=VARCHAR},</if>
      <if test="jumpNeedLogin != null">fa_jump_need_login=#{jumpNeedLogin,jdbcType=VARCHAR},</if>
      <if test="startTime != null">fa_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">fa_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="position != null">fa_position=#{position,jdbcType=VARCHAR},</if>
      <if test="order != null">fa_order=#{order,jdbcType=INTEGER},</if>
      <if test="type != null">fa_type=#{type,jdbcType=INTEGER},</if>
      <if test="state != null">fa_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">fa_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">fa_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where fa_id = #{id,jdbcType=BIGINT}
  </update>
  
  <delete id="deleteByPrimaryKeyList" parameterType="java.util.List">
    delete from yeshi_ec_float_ad 
    WHERE fa_id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item}</foreach>
  </delete> 
  
  
  <select id="listQuery" resultMap="BaseResultMap">
      SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_float_ad fd 
      WHERE 1=1 
          <if test="key != null and key !='' ">
              AND fd.`fa_name` LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND fd.`fa_state` =  #{state}
          </if>
      ORDER BY fd.`fa_position`,fd.`fa_order`
      LIMIT ${start},${count}
  </select>
  
  <select id="countQuery" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(fd.`fa_id`),0) FROM yeshi_ec_float_ad fd 
      WHERE 1=1 
          <if test="key != null and key !='' ">
              AND fd.`fa_name` LIKE '%${key}%'
          </if>
          <if test="state != null">
               AND fd.`fa_state` =  #{state}
          </if>
  </select>
  
   <select id="getMaxOrderByPosition" resultType="java.lang.Integer">
        SELECT IFNULL(MAX(fa_order),0) FROM yeshi_ec_float_ad
        WHERE fa_position = #{position}
  </select>
  
   <select id="getByAdjoinOrder" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_float_ad fd 
        WHERE  fd.`fa_position` = #{position}
        <if test="type == -1">
            AND fd.`fa_order` <![CDATA[<]]> #{order}  
            ORDER BY fd.`fa_order` desc
        </if>
        
        <if test="type == 1">
            AND fd.`fa_order` <![CDATA[>]]> #{order}  
            ORDER BY fd.`fa_order` 
        </if>
        LIMIT 1
   </select>
   
    <select id="countByPosition" resultType="java.lang.Integer">
         SELECT IFNULL(COUNT(fd.`fa_id`),0) FROM yeshi_ec_float_ad fd 
         WHERE fd.`fa_position` = #{position}
   </select>
  
   <select id="ListByPrimaryKey" parameterType="java.util.List" resultMap="BaseResultMap">
       SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_float_ad
       WHERE fa_id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item}</foreach>
   </select>
   
       <select id="getEffectiveFloatAD" resultMap="BaseResultMap">
           SELECT * FROM yeshi_ec_float_ad fd 
        WHERE fd.`fa_position` = #{position} AND fd.`fa_state` = 1
               AND IF(fd.`fa_start_time` IS NULL,TRUE,fd.`fa_start_time` <![CDATA[<=]]> NOW()) 
               AND IF(fd.`fa_end_time` IS NULL,TRUE,fd.`fa_end_time` <![CDATA[>=]]> NOW())
               <if test="type != null">
                   AND fa_type = #{type}
               </if>
        ORDER BY fd.`fa_order` 
        LIMIT 1
       </select>
</mapper>