<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" 
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="com.house365.beans.entity.BaseAttachmentRemoteUrl">
	<typeAlias alias="baseAttachmentRemoteUrlEntity"
		type="com.house365.beans.entity.BaseAttachmentRemoteUrl" />
	<resultMap id="baseAttachmentRemoteUrl"
		class="com.house365.beans.entity.BaseAttachmentRemoteUrl">
		<result property="id" column="id" />
		<result property="remoteServerUrl" column="remoteServerUrl" />
		<result property="remark" column="remark" />
	</resultMap>

	<!-- 用于select查询公用抽取的列 -->
	<sql id="baseAttachmentRemoteUrl.columns">
	    <![CDATA[
        id, remoteServerUrl,remark
	    ]]>
	</sql>

	<!-- 新增记录 -->
	<insert id="save" parameterClass="baseAttachmentRemoteUrlEntity">
	    <![CDATA[
	        INSERT INTO base_attachment_remote_url (
	        	id, 
	        	remoteServerUrl, 
	        	remark
	        ) VALUES (
	        	#id#, 
	        	#remoteServerUrl#, 
	        	#remark#
	        )
	    ]]>
		<selectKey resultClass="java.lang.Integer" type="post"
			keyProperty="id">
			SELECT LAST_INSERT_ID()
		</selectKey>
	</insert>

	<!-- 新增记录 -->
	<insert id="insert" parameterClass="baseAttachmentRemoteUrlEntity">
	    <![CDATA[
	        INSERT INTO base_attachment_remote_url (
	        	id, 
	        	remoteServerUrl, 
	        	remark
	        ) VALUES (
	        	#id#, 
	        	#remoteServerUrl#, 
	        	#remark#
	        )
	    ]]>
		<selectKey resultClass="java.lang.Integer" type="post"
			keyProperty="id">
			SELECT LAST_INSERT_ID()
		</selectKey>
	</insert>

	<!-- 通过ID修改 -->
	<update id="update" parameterClass="baseAttachmentRemoteUrlEntity">
	    <![CDATA[
	        UPDATE base_attachment_remote_url SET
		        remoteServerUrl = #remoteServerUrl#, 
		        remark = #remark#
	        WHERE 
		        id = #id#
	    ]]>
	</update>

	<!-- 通过ID删除 -->
	<delete id="delete">
	    <![CDATA[
	        DELETE FROM base_attachment_remote_url WHERE
	        id = #id#
	    ]]>
	</delete>

	<!-- 通过ID列表批量删除 -->
	<delete id="deleteByIds" parameterClass="java.lang.String">
	    <![CDATA[
	        DELETE FROM base_attachment_remote_url WHERE
	        id IN ($ids$)
	    ]]>
	</delete>

	<!-- 通过ID查询 -->
	<select id="getById" resultMap="baseAttachmentRemoteUrl">
		SELECT
		<include refid="baseAttachmentRemoteUrl.columns" />
	    <![CDATA[
	        FROM base_attachment_remote_url 
	        WHERE 
		        id = #id#
	    ]]>
	</select>

	<!-- 用于分页查询抽取的公共的条件 -->
	<sql id="baseAttachmentRemoteUrl.queryPage">
		<dynamic prepend="WHERE">
		    <isNotNull property="entity">
				<isNotEmpty prepend="AND" property="entity.id">
		            <![CDATA[
					id = #entity.id#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.remoteServerUrl">
		            <![CDATA[
					remoteServerUrl = #entity.remoteServerUrl#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="entity.remark">
		            <![CDATA[
					remark = #entity.remark#
		            ]]>
				</isNotEmpty>
			</isNotNull>
		    <isNotNull property="searchFilters">
				<isNotEmpty prepend="AND" property="searchFilters.id">
		            <![CDATA[
					id $searchFilters.id.operation$ #searchFilters.id.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.remoteServerUrl">
		            <![CDATA[
					remoteServerUrl $searchFilters.remoteServerUrl.operation$ #searchFilters.remoteServerUrl.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.remark">
		            <![CDATA[
					remark $searchFilters.remark.operation$ #searchFilters.remark.value#
		            ]]>
				</isNotEmpty>
			</isNotNull>
		</dynamic>
		<dynamic prepend="ORDER BY">
			<isNotNull property="orderColumn">
		        <![CDATA[
				$orderColumn$
				]]>
				<isNotNull property="orderMode">
				$orderMode$
				</isNotNull>
			</isNotNull>
		</dynamic>
	</sql>

	<!-- 为分页查询符合条件的记录数 -->
	<select id="queryByPage_count" resultClass="int">
		SELECT count(*) FROM base_attachment_remote_url
		<include refid="baseAttachmentRemoteUrl.queryPage" />
	</select>

	<!-- 分页查询指定页记录 -->
	<select id="queryByPage" resultMap="baseAttachmentRemoteUrl">
		SELECT
		<include refid="baseAttachmentRemoteUrl.columns" />
	    <![CDATA[
	        FROM base_attachment_remote_url 
	    ]]>
		<include refid="baseAttachmentRemoteUrl.queryPage" />
		<![CDATA[
		    LIMIT #paging.startRecord#, #paging.pageSize#
        ]]>
	</select>

	<!-- 查询所有记录 -->
	<select id="queryAll" resultMap="baseAttachmentRemoteUrl">
		SELECT
		<include refid="baseAttachmentRemoteUrl.columns" />
	    <![CDATA[
		    FROM base_attachment_remote_url
	    ]]>
	</select>
</sqlMap>