CutDownPriceActivityMapper.xml 5.02 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.yoho.activity.dal.CutDownPriceActivityMapper">
  <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceActivity">
    <id column="activity_id" jdbcType="INTEGER" property="activityId" />
    <result column="activity_name" property="activityName" jdbcType="VARCHAR"  />
    <result column="status" property="status" jdbcType="INTEGER"  />
    <result column="begin_time" property="beginTime" jdbcType="INTEGER"  />
    <result column="end_time" property="endTime" jdbcType="INTEGER"  />
    <result column="create_time" property="createTime" jdbcType="INTEGER"  />
    <result column="update_time" property="updateTime" jdbcType="INTEGER"  />
    <result column="jump_url" property="jumpUrl" jdbcType="VARCHAR"  />
    <result column="banner_url" property="banner" jdbcType="VARCHAR"  />
  </resultMap>

  <sql id="Base_Column_List" >
    activity_id, activity_name, status, begin_time, end_time, create_time, update_time, jump_url, banner_url
  </sql>

  <select id="selectEffectCutPriceActivity" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from cutdown_price_activity
    where 1=1 and status=1
    and begin_time &lt;= UNIX_TIMESTAMP()
    and end_time &gt;= UNIX_TIMESTAMP()
    order by begin_time
  </select>

  <select id="selectCutDownPriceActivity" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from cutdown_price_activity
    where activity_id = #{activityId,jdbcType=INTEGER}
  </select>

  <select id="selectCutDownPriceActivityList" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" /> FROM cutdown_price_activity
    where activity_id in
    <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
      #{item}
    </foreach>
  </select>

  <insert id="updateCutDownPriceActivity">
    INSERT INTO cutdown_price_activity
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="params.activityId != null and params.activityId != ''">
        activity_id,
      </if>
      <if test="params.activityName != null and params.activityName != ''">
        activity_name,
      </if>
      <if test="params.beginTime != null and params.beginTime != ''">
        begin_time,
      </if>
      <if test="params.endTime != null and params.endTime != ''">
        end_time,
      </if>
      <if test="params.createTime != null and params.createTime != ''">
        create_time,
      </if>
      <if test="params.updateTime != null and params.updateTime != ''">
        update_time,
      </if>
      <if test="params.banner != null and params.banner != ''">
        banner_url,
      </if>
      <if test="params.jumpUrl != null and params.jumpUrl != ''">
        jump_url,
      </if>
      <if test="params.status != null and params.status != ''">
        status,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="params.activityId != null and params.activityId != ''">
        #{params.activityId},
      </if>
      <if test="params.activityName != null and params.activityName != ''">
        #{params.activityName,jdbcType=VARCHAR},
      </if>
      <if test="params.beginTime != null and params.beginTime != ''">
        #{params.beginTime,jdbcType=INTEGER},
      </if>
      <if test="params.endTime != null and params.endTime != ''">
        #{params.endTime,jdbcType=INTEGER},
      </if>
      <if test="params.createTime != null and params.createTime != ''">
        #{params.createTime,jdbcType=INTEGER},
      </if>
      <if test="params.updateTime != null and params.updateTime != ''">
        #{params.updateTime,jdbcType=INTEGER},
      </if>
      <if test="params.banner != null and params.banner != ''">
        #{params.banner,jdbcType=VARCHAR},
      </if>
      <if test="params.jumpUrl != null and params.jumpUrl != ''">
        #{params.jumpUrl,jdbcType=VARCHAR},
      </if>
      <if test="params.status != null and params.status != ''">
        #{params.status},
      </if>
    </trim>
    ON DUPLICATE KEY UPDATE
    <trim suffixOverrides=",">
      <if test="params.activityName != null and params.activityName != ''">
        activity_name = VALUES(activity_name),
      </if>
      <if test="params.updateTime != null and params.updateTime != ''">
        update_time = VALUES(update_time),
      </if>
      <if test="params.beginTime != null and params.beginTime != ''">
        begin_time = VALUES(begin_time),
      </if>
      <if test="params.endTime != null and params.endTime != ''">
        end_time = VALUES(end_time),
      </if>
      <if test="params.status != null and params.status != ''">
        status = VALUES(status),
      </if>
      <if test="params.banner != null and params.banner != ''">
        banner_url = VALUES(banner_url),
      </if>
      <if test="params.jumpUrl != null and params.jumpUrl != ''">
        jump_url = VALUES(jump_url),
      </if>
    </trim>
  </insert>
</mapper>