CouponActivityMapper.xml 5.04 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.coupon.dal.ICouponActivityDAO">
	<resultMap id="BaseResultMap" type="com.yoho.coupon.dal.model.CouponActivity">
		<id column="id" property="id" jdbcType="INTEGER" />
		<result column="activity_name" property="activityName"
			jdbcType="VARCHAR" />
		<result column="activity_title" property="activityTitle"
			jdbcType="VARCHAR" />
		<result column="activity_pic" property="activityPic" jdbcType="VARCHAR" />
		<result column="activity_bgcolor" property="activityBgcolor"
			jdbcType="VARCHAR" />
		<result column="activity_desc" property="activityDesc"
			jdbcType="VARCHAR" />
		<result column="coupon_pic" property="couponPic" jdbcType="VARCHAR" />
		<result column="share_img_url" property="shareImgUrl" jdbcType="VARCHAR" />
		<result column="share_title1" property="shareTitle1" jdbcType="VARCHAR" />
		<result column="share_title2" property="shareTitle2" jdbcType="VARCHAR" />
		<result column="status" property="status" jdbcType="TINYINT" />
		<result column="create_time" property="createTime" jdbcType="INTEGER" />
		<result column="coupon_event_code" property="couponEventCode" jdbcType="VARCHAR" />
		<result column="activity_code" property="activityCode" jdbcType="VARCHAR" />
		<result column="begin_time" property="beginTime" jdbcType="INTEGER" />
		<result column="end_time" property="endTime" jdbcType="INTEGER" />
		<result column="coupon_name" property="couponName" jdbcType="VARCHAR" />
	</resultMap>
	<sql id="Base_Column_List">
		id, activity_name, activity_title, activity_pic, activity_bgcolor,
		activity_desc,
		coupon_pic, share_img_url, share_title1, share_title2, status, create_time, coupon_event_code, activity_code, begin_time, end_time, coupon_name
	</sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
		parameterType="java.lang.Integer">
		select
		<include refid="Base_Column_List" />
		from coupon_activity
		where id = #{id,jdbcType=INTEGER}
	</select>
	
	<select id="selectByCode" resultMap="BaseResultMap">
		select
		<include refid="Base_Column_List" />
		from coupon_activity
		where activity_code = #{activityCode} and status=1 and begin_time&lt;=UNIX_TIMESTAMP() and end_time&gt;=UNIX_TIMESTAMP()
	</select>
	
	<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
		delete from coupon_activity
		where id = #{id,jdbcType=INTEGER}
	</delete>
	<insert id="insert" parameterType="com.yoho.coupon.dal.model.CouponActivity">
		insert into coupon_activity (id, activity_name, activity_title,
		activity_pic, activity_bgcolor, activity_desc,
		coupon_pic, share_img_url, share_title1,
		share_title2, status, create_time
		)
		values (#{id,jdbcType=INTEGER}, #{activityName,jdbcType=VARCHAR},
		#{activityTitle,jdbcType=VARCHAR},
		#{activityPic,jdbcType=VARCHAR}, #{activityBgcolor,jdbcType=VARCHAR},
		#{activityDesc,jdbcType=VARCHAR},
		#{couponPic,jdbcType=VARCHAR}, #{shareImgUrl,jdbcType=VARCHAR}, #{shareTitle1,jdbcType=VARCHAR},
		#{shareTitle2,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT},
		#{createTime,jdbcType=INTEGER}
		)
	</insert>

	<update id="updateByPrimaryKeySelective" parameterType="com.yoho.coupon.dal.model.CouponActivity">
		update coupon_activity
		<set>
			<if test="activityName != null">
				activity_name = #{activityName,jdbcType=VARCHAR},
			</if>
			<if test="activityTitle != null">
				activity_title = #{activityTitle,jdbcType=VARCHAR},
			</if>
			<if test="activityPic != null">
				activity_pic = #{activityPic,jdbcType=VARCHAR},
			</if>
			<if test="activityBgcolor != null">
				activity_bgcolor = #{activityBgcolor,jdbcType=VARCHAR},
			</if>
			<if test="activityDesc != null">
				activity_desc = #{activityDesc,jdbcType=VARCHAR},
			</if>
			<if test="couponPic != null">
				coupon_pic = #{couponPic,jdbcType=VARCHAR},
			</if>
			<if test="shareImgUrl != null">
				share_img_url = #{shareImgUrl,jdbcType=VARCHAR},
			</if>
			<if test="shareTitle1 != null">
				share_title1 = #{shareTitle1,jdbcType=VARCHAR},
			</if>
			<if test="shareTitle2 != null">
				share_title2 = #{shareTitle2,jdbcType=VARCHAR},
			</if>
			<if test="status != null">
				status = #{status,jdbcType=TINYINT},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=INTEGER},
			</if>
		</set>
		where id = #{id,jdbcType=INTEGER}
	</update>
	<update id="updateByPrimaryKey" parameterType="com.yoho.coupon.dal.model.CouponActivity">
		update coupon_activity
		set activity_name = #{activityName,jdbcType=VARCHAR},
		activity_title = #{activityTitle,jdbcType=VARCHAR},
		activity_pic = #{activityPic,jdbcType=VARCHAR},
		activity_bgcolor = #{activityBgcolor,jdbcType=VARCHAR},
		activity_desc = #{activityDesc,jdbcType=VARCHAR},
		coupon_pic = #{couponPic,jdbcType=VARCHAR},
		share_img_url = #{shareImgUrl,jdbcType=VARCHAR},
		share_title1 = #{shareTitle1,jdbcType=VARCHAR},
		share_title2 = #{shareTitle2,jdbcType=VARCHAR},
		status = #{status,jdbcType=TINYINT},
		create_time = #{createTime,jdbcType=INTEGER}
		where id = #{id,jdbcType=INTEGER}
	</update>
</mapper>