<?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.ufo.dal.UserCouponMapper"> <resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.UserCoupon"> <result column="id" property="id" jdbcType="INTEGER" /> <result column="uid" property="uid" jdbcType="INTEGER" /> <result column="coupon_id" property="couponId" jdbcType="INTEGER" /> <result column="coupon_type" property="couponType" jdbcType="INTEGER" /> <result column="coupon_code" property="couponCode" jdbcType="VARCHAR" /> <result column="status" property="status" jdbcType="INTEGER" /> <result column="order_code" property="orderCode" jdbcType="BIGINT" /> <result column="use_time" property="useTime" jdbcType="INTEGER" /> <result column="start_time" property="startTime" jdbcType="INTEGER" /> <result column="end_time" property="endTime" jdbcType="INTEGER" /> <result column="create_time" property="createTime" jdbcType="INTEGER" /> <result column="coupon_token" property="couponToken" jdbcType="VARCHAR" /> </resultMap> <sql id="Base_Column_List"> id,uid,coupon_id,coupon_type,coupon_code,status,order_code,use_time,start_time,end_time,create_time,coupon_token </sql> <select id="selectByCondition" resultType="com.yoho.ufo.model.coupon.UserCoupon"> select <include refid="Base_Column_List"/> from user_coupon where 1=1 <if test="param.couponId != null"> and coupon_Id=#{param.couponId} </if> <if test="param.couponCode != null"> and coupon_code=#{param.couponCode} </if> <if test="param.uid != null"> and uid=#{param.uid} </if> <if test="param.status != null"> and status=#{param.status} </if> order by id desc <if test="param.size > 0"> limit #{param.start},#{param.size} </if> </select> <select id="selectTotalByCondition" resultType="java.lang.Integer"> select count(1) from user_coupon where 1=1 <if test="param.couponId != null"> and coupon_Id=#{param.couponId} </if> <if test="param.couponCode != null"> and coupon_code=#{param.couponCode} </if> <if test="param.uid != null"> and uid=#{param.uid} </if> <if test="param.status != null"> and status=#{param.status} </if> </select> </mapper>