<?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.iamberry.wechat.service.mapper.ReportMapper">
	<resultMap  id="BaseResultMap" type="Report" >
		<result    column="report_id"    property="reportId" />
		<result    column="report_coupon_number"    property="reportCouponNumber" />
		<result    column="report_coupon_use_number"    property="reportCouponUseNumber" />
		<result    column="report_registered_number"    property="reportRegisteredNumber" />
		<result    column="report_create_time"    property="reportCreateTime" />
		<result    column="report_update_time"    property="reportUpdateTime" />
	</resultMap>
	<sql  id="Base_List" >
		t.report_id,
		t.report_coupon_number,
		t.report_coupon_use_number,
		t.report_registered_number,
		t.report_create_time,
		t.report_update_time
	</sql>
	<select id="getReportList" resultMap="BaseResultMap" parameterType="Report" >
		select
		<include refid="Base_List" />
		from tb_iamberry_report t
		<where>
			<if test="reportId != null ">
				AND t.report_id = #{reportId}
			</if >
			<if test="reportCouponNumber != null ">
				AND t.report_coupon_number = #{reportCouponNumber}
			</if >
			<if test="reportCouponUseNumber != null ">
				AND t.report_coupon_use_number = #{reportCouponUseNumber}
			</if >
			<if test="reportRegisteredNumber != null ">
				AND t.report_registered_number = #{reportRegisteredNumber}
			</if >
		</where>
		ORDER BY t.report_id DESC
	</select>
	<select id="getReportById" resultMap="BaseResultMap" parameterType="Integer" >
		select
		<include refid="Base_List" />
		from tb_iamberry_report t
		where t.report_id= #{reportId}
	</select>
	<insert id="save" parameterType="Report" >
		insert into
		tb_iamberry_report
		(
		report_id,
		report_coupon_number,
		report_coupon_use_number,
		report_registered_number
		)
		values
		(
		#{reportId},
		#{reportCouponNumber},
		#{reportCouponUseNumber},
		#{reportRegisteredNumber}
		)
	</insert>
	<update id="update" parameterType="Report" >
		update
		tb_iamberry_report
		<set >
			<if test="reportId != null ">
				report_id = #{reportId},
			</if >
			<if test="reportCouponNumber != null ">
				report_coupon_number = #{reportCouponNumber},
			</if >
			<if test="reportCouponUseNumber != null ">
				report_coupon_use_number = #{reportCouponUseNumber},
			</if >
			<if test="reportRegisteredNumber != null ">
				report_registered_number = #{reportRegisteredNumber},
			</if >
		</set >
		where report_id= #{reportId}
	</update>
	<delete id="delete" parameterType="Integer" >
		delete FROM
		tb_iamberry_report
		where report_id=#{reportId}
	</delete>
</mapper>