quota-transfer-mapper.xml 1.43 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">

<!-- @author kongmingke -->
<mapper namespace="com.cjs.cms.dao.quota.QuotaTransferDao">

	<sql id="quota_transfer_field">
		id, otc_code, otc_name, user_id_in, user_id_out, quota, create_at, create_by
	</sql>

	<sql id="searchCondition">
	    where 1 = 1
		<if test="otcCode != null and otcCode != ''">
			and otc_code = #{otcCode}
		</if>

		<if test="userIdIn !=null and userIdIn !=''">
			and user_id_in = #{userIdIn}
		</if>
		
		<if test="userIdOut != null and userIdOut != ''">
			and user_id_out = #{userIdOut}
		</if>
		
		<if test="beginDate != null and endDate == null">
			and create_at >= #{beginDate}
		</if>
		<if test="endDate != null and beginDate == null">
			and DATE_ADD(#{endDate}, INTERVAL +1 day) >=
			create_at
		</if>
		
		<if test="endDate != null and beginDate != null">
			and create_at between #{beginDate} and
			DATE_ADD(#{endDate},INTERVAL +1 day)
		</if>
	</sql>

	<select id="search" parameterType="map" resultType="QuotaTransferInfo">
		select
		<include refid="quota_transfer_field"/>
		from quota_transfer
		<include refid="searchCondition" />
		order by id desc
		<include refid="common.pageLimit" />
	</select>

	<select id="searchTotal" parameterType="map" resultType="int">
		select count(1)
		from quota_transfer
		<include refid="searchCondition" />
	</select>
	
</mapper>