ProductAuth.xml 2.25 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.dili.titan.dao.ProductAuthDao">

	<!-- product_auth 所有查询列 -->
	<sql id="QUERY_COLUMN_LIST">
		<![CDATA[id,pid,auth_id AS authId,auth_url AS authUrl,status,auth_end_time AS authEndTime,ctime,utime]]>
	</sql>

	<!-- product_auth 查询列来源表-->
	<sql id="QUERY_FROM_TABLE"><![CDATA[FROM product_auth]]></sql>
	
	<!-- 全部条件(更多功能可以通过queryData扩展实现)  -->
	<sql id="QUERY_WHERE_CLAUSE">
		<where>
			<if test="id != null and id != ''"><![CDATA[AND id = #{id}]]></if>
			<if test="pid != null and pid != ''"><![CDATA[AND pid = #{pid}]]></if>
			<if test="authId != null and authId != ''"><![CDATA[AND auth_id = #{authId}]]></if>
			<if test="authUrl != null and authUrl != ''"><![CDATA[AND auth_url = #{authUrl}]]></if>
			<if test="status != null and status != ''"><![CDATA[AND status = #{status}]]></if>
			<if test="authEndTime != null and authEndTime != ''"><![CDATA[AND auth_end_time = #{authEndTime}]]></if>
			<if test="ctime != null and ctime != ''"><![CDATA[AND ctime = #{ctime}]]></if>
			<if test="utime != null and utime != ''"><![CDATA[AND utime = #{utime}]]></if>
			<![CDATA[AND status != -1]]>
		</where>
	</sql>
	
	<!-- 智能排序与分页 -->
	<sql id="QUERY_ORDER_LIMIT_CONDTION">
		<if test="orderField != null and orderField != '' and orderFieldType != null and orderFieldType != ''"><![CDATA[ORDER BY ${orderField} ${orderFieldType}]]></if>
		<if test="startIndex != null and startIndex &gt;= 0 and pageSize != null and pageSize &gt; 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
	</sql>

	
	<!-- 定时使过期数据失效 -->
	<update id="setAuthDataInvalid" parameterType="java.util.List">
		UPDATE product_auth a set a.status=2  where a.id in
		<foreach collection="list" item="item" open="(" separator="," close=")">
			#{item.id}
		</foreach>		
	</update>
	
		<!-- 查询将要失效的认证数据 -->
	<select id="selectInvalidAuthData" resultType="productAuth">
		<![CDATA[select ]]>
		<include refid="QUERY_COLUMN_LIST"/>
		<![CDATA[from product_auth a  where NOW() >= date_add(a.auth_end_time, interval 1 day) and a.status = 1]]>
	</select>
	
</mapper>