SpecialActivityMapper.xml 9.93 KB
<?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.yohobuy.platform.dal.event.SpecialActivityMapper">
  <resultMap id="BaseResultMap" type="com.yohobuy.platform.dal.event.model.SpecialActivity">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="sort" jdbcType="CHAR" property="sort" />
    <result column="title" jdbcType="VARCHAR" property="title" />
    <result column="plateform" jdbcType="CHAR" property="plateform" />
    <result column="promotion_name" jdbcType="VARCHAR" property="promotionName" />
    <result column="create_time" jdbcType="INTEGER" property="createTime" />
    <result column="start_time" jdbcType="INTEGER" property="startTime" />
    <result column="end_time" jdbcType="INTEGER" property="endTime" />
    <result column="logo_url" jdbcType="VARCHAR" property="logoUrl" />
    <result column="cover_url" jdbcType="VARCHAR" property="coverUrl" />
    <result column="web_url" jdbcType="VARCHAR" property="webUrl" />
    <result column="product_pool_id" jdbcType="INTEGER" property="productPoolId" />
    <result column="yh_channel" jdbcType="VARCHAR" property="yhChannel" />
    <result column="order_num" jdbcType="INTEGER" property="orderNum" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="web_cover_url" jdbcType="VARCHAR" property="webCoverUrl" />
    <result column="is_show" jdbcType="CHAR" property="isShow"/>
  </resultMap>
  <sql id="Base_Column_List">
		    
			id,
			sort,
			title,
			plateform,
			promotion_name,
			create_time,
			yh_channel,
			start_time,
			end_time,
			logo_url,
			cover_url,
			web_url,
			product_pool_id,
			order_num,
			web_cover_url,
			CASE
		WHEN start_time IS NULL
		AND end_time IS NULL THEN
			1
		WHEN start_time > UNIX_TIMESTAMP() THEN
			2
		WHEN start_time &lt; UNIX_TIMESTAMP()
		AND end_time > UNIX_TIMESTAMP() THEN
			3
		WHEN end_time &lt; UNIX_TIMESTAMP() THEN
			4
		END AS STATUS,
		is_show
  </sql>
   <sql id="where">
      where   1=1 
      <if test="plateform != null">
       and  plateform like '%${plateform}%'
      </if>
      <if test="sort != null">
       and  sort=#{sort,jdbcType=VARCHAR}
      </if>
     <if test="isShow != null">
       and  is_show=#{isShow,jdbcType=VARCHAR}
     </if>
      <if test="status !=null">
          <if test="status ==1">
          and  start_time is null  and end_time is null
         </if>
         <if test="status ==2 ">
          and  start_time > UNIX_TIMESTAMP()
         </if>
         <if test="status ==3">
          and  start_time &lt; UNIX_TIMESTAMP()  and  end_time >UNIX_TIMESTAMP() 
         </if>
         <if test="status ==4">
           and  end_time &lt; UNIX_TIMESTAMP() 
         </if>
      </if>
      <if test="startTime !=null">
          and start_time >=#{startTime}
      </if>
     <if test="endTime !=null">
       and end_time &lt;=#{endTime}
     </if>
     <if test="title !=null">
       and title like CONCAT('%',#{title},'%')
     </if>
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from special_activity
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="querySpecialActivityList" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from special_activity 
     <include refid="where"/>
     order by   order_num desc  ,create_time desc 
     limit #{offset,jdbcType=INTEGER},#{pageSize,jdbcType=INTEGER}
    
  </select>
  <select id="querySpecialActivityCount" resultType="long">
    select count(1)
    from special_activity 
    <include refid="where"/>
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from special_activity
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
    insert into special_activity (id, sort, title, 
      plateform, promotion_name, create_time, 
      start_time, end_time, logo_url, 
      cover_url, web_url, product_pool_id,order_num,web_cover_url
      )
    values (#{id,jdbcType=INTEGER}, #{sort,jdbcType=CHAR}, #{title,jdbcType=VARCHAR}, 
      #{plateform,jdbcType=CHAR}, #{promotionName,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}, 
      #{startTime,jdbcType=INTEGER}, #{endTime,jdbcType=INTEGER}, #{logoUrl,jdbcType=VARCHAR}, 
      #{coverUrl,jdbcType=VARCHAR}, #{webUrl,jdbcType=VARCHAR}, #{productPoolId,jdbcType=INTEGER}, #{orderNum,jdbcType=INTEGER},
      #{webCoverUrl,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
    insert into special_activity
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="sort != null">
        sort,
      </if>
      <if test="title != null">
        title,
      </if>
      <if test="plateform != null">
        plateform,
      </if>
      <if test="promotionName != null">
        promotion_name,
      </if>
        create_time,
      
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="logoUrl != null">
        logo_url,
      </if>
      <if test="coverUrl != null">
        cover_url,
      </if>
      <if test="webUrl != null">
        web_url,
      </if>
      <if test="productPoolId != null">
        product_pool_id,
      </if>
      <if test="orderNum != null">
        order_num,
      </if>
      <if test="yhChannel != null">
        yh_channel,
      </if>
      <if test="webCoverUrl != null">
        web_cover_url,
      </if>
      <if test="isShow != null">
        is_show,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=CHAR},
      </if>
      <if test="title != null">
        #{title,jdbcType=VARCHAR},
      </if>
      <if test="plateform != null">
        #{plateform,jdbcType=CHAR},
      </if>
      <if test="promotionName != null">
        #{promotionName,jdbcType=VARCHAR},
      </if>
     
        UNIX_TIMESTAMP(),
      
      <if test="startTime != null">
        #{startTime,jdbcType=INTEGER},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=INTEGER},
      </if>
      <if test="logoUrl != null">
        #{logoUrl,jdbcType=VARCHAR},
      </if>
      <if test="coverUrl != null">
        #{coverUrl,jdbcType=VARCHAR},
      </if>
      <if test="webUrl != null">
        #{webUrl,jdbcType=VARCHAR},
      </if>
      <if test="productPoolId != null">
        #{productPoolId,jdbcType=INTEGER},
      </if>
       <if test="orderNum != null">
        #{orderNum,jdbcType=INTEGER},
      </if>
       <if test="yhChannel != null">
         #{yhChannel,jdbcType=VARCHAR},
      </if>
      <if test="webCoverUrl != null">
        #{webCoverUrl,jdbcType=VARCHAR},
      </if>
      <if test="isShow != null">
        #{isShow,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
    update special_activity
    <set>
      <if test="sort != null">
        sort = #{sort,jdbcType=CHAR},
      </if>
      <if test="title != null">
        title = #{title,jdbcType=VARCHAR},
      </if>
      <if test="plateform != null">
        plateform = #{plateform,jdbcType=CHAR},
      </if>
      <if test="promotionName != null">
        promotion_name = #{promotionName,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=INTEGER},
      </if>
      <if test="endTime != null">
        end_time = #{endTime,jdbcType=INTEGER},
      </if>
      <if test="orderNum != null">
        order_num= #{orderNum,jdbcType=INTEGER},
      </if>
      <if test="logoUrl != null">
        logo_url = #{logoUrl,jdbcType=VARCHAR},
      </if>
      <if test="coverUrl != null">
        cover_url = #{coverUrl,jdbcType=VARCHAR},
      </if>
      <if test="webUrl != null">
        web_url = #{webUrl,jdbcType=VARCHAR},
      </if>
      <if test="productPoolId != null">
        product_pool_id = #{productPoolId,jdbcType=INTEGER},
      </if>
      <if test="yhChannel != null">
         yh_channel=#{yhChannel,jdbcType=VARCHAR},
      </if>
      <if test="webCoverUrl != null">
        web_cover_url=#{webCoverUrl,jdbcType=VARCHAR},
      </if>
      <if test="isShow != null">
        is_show=#{isShow,jdbcType=CHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yohobuy.platform.dal.event.model.SpecialActivity">
    update special_activity
    set sort = #{sort,jdbcType=CHAR},
      title = #{title,jdbcType=VARCHAR},
      plateform = #{plateform,jdbcType=CHAR},
      promotion_name = #{promotionName,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=INTEGER},
      start_time = #{startTime,jdbcType=INTEGER},
      end_time = #{endTime,jdbcType=INTEGER},
      logo_url = #{logoUrl,jdbcType=VARCHAR},
      cover_url = #{coverUrl,jdbcType=VARCHAR},
      order_num= #{orderNum,jdbcType=INTEGER},
      web_url = #{webUrl,jdbcType=VARCHAR},
      yh_channel = #{yhChannel,jdbcType=VARCHAR},
      product_pool_id = #{productPoolId,jdbcType=INTEGER},
      web_cover_url=#{webCoverUrl,jdbcType=VARCHAR},
      is_show=#{isShow,jdbcType=CHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="querySpecialActivityByIDs" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from special_activity
    where id in
    <foreach collection="ids" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </select>
  
</mapper>