<?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.po.IfRegPo">
	<typeAlias alias="ifRegPo"
		type="com.house365.beans.po.IfRegPo" />
	<resultMap id="ifReg"
		class="com.house365.beans.po.IfRegPo">
		<result property="id" column="id" />
		<result property="serviceCode" column="serviceCode" />
		<result property="serviceName" column="serviceName" />
		<result property="serviceReg" column="serviceReg" />
		<result property="serviceDesc" column="serviceDesc" />
		<result property="isLog" column="isLog" />
		<result property="isMonitor" column="isMonitor" />
		<result property="isControl" column="isControl" />
		<result property="version" column="version" />
		<result property="channl" column="channl" />
		<result property="remark" column="remark" />
	</resultMap>

	<!-- 用于select查询公用抽取的列 -->
	<sql id="ifReg.columns">
		<![CDATA[
        id, serviceCode, serviceName, serviceReg, serviceDesc, isLog, isMonitor, isControl, version, channl, remark
	    ]]>
	</sql>

	<!-- 新增记录 -->
	<insert id="save" parameterClass="ifRegPo">
		<![CDATA[
	        INSERT INTO if_reg (
	        	id,
	        	serviceCode,
	        	serviceName,
	        	serviceReg,
	        	serviceDesc,
	        	isLog,
	        	isMonitor,
	        	isControl,
	        	version,
	        	channl,
	        	remark
	        ) VALUES (
	        	#id#,
	        	#serviceCode#,
	        	#serviceName#,
	        	#serviceReg#,
	        	#serviceDesc#,
	        	#isLog#,
	        	#isMonitor#,
	        	#isControl#,
	        	#version#,
	        	#channl#,
	        	#remark#
	        )
	    ]]>
		<selectKey resultClass="java.lang.Integer" type="post"
			keyProperty="id">
			SELECT LAST_INSERT_ID()
		</selectKey>
	</insert>

	<!-- 通过ID修改 -->
	<update id="update" parameterClass="ifRegPo">
		<![CDATA[
	        UPDATE if_reg SET
		        serviceCode = #serviceCode#,
		        serviceName = #serviceName#,
		        serviceReg = #serviceReg#,
		        serviceDesc = #serviceDesc#,
		        isLog = #isLog#,
		        isMonitor = #isMonitor#,
		        isControl = #isControl#,
		        version = #version#,
		        channl = #channl#,
		        remark = #remark#
	        WHERE
		        id = #id#
	    ]]>
	</update>

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

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

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

	<!-- 用于分页查询抽取的公共的条件 -->
	<sql id="ifReg.queryPage">
		<dynamic prepend="WHERE">
			<!-- 默认不开启实体作为条件 -->
			<isNotNull property="searchFilters">
				<isNotEmpty prepend="AND" property="searchFilters.id">
					<![CDATA[
					id $searchFilters.id.operation$ #searchFilters.id.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.serviceCode">
					<![CDATA[
					serviceCode $searchFilters.serviceCode.operation$ #searchFilters.serviceCode.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.serviceName">
					<![CDATA[
					serviceName $searchFilters.serviceName.operation$ #searchFilters.serviceName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.serviceReg">
					<![CDATA[
					serviceReg $searchFilters.serviceReg.operation$ #searchFilters.serviceReg.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.serviceDesc">
					<![CDATA[
					serviceDesc $searchFilters.serviceDesc.operation$ #searchFilters.serviceDesc.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isLog">
					<![CDATA[
					isLog $searchFilters.isLog.operation$ #searchFilters.isLog.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isMonitor">
					<![CDATA[
					isMonitor $searchFilters.isMonitor.operation$ #searchFilters.isMonitor.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isControl">
					<![CDATA[
					isControl $searchFilters.isControl.operation$ #searchFilters.isControl.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.version">
					<![CDATA[
					version $searchFilters.version.operation$ #searchFilters.version.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.channl">
					<![CDATA[
					channl $searchFilters.channl.operation$ #searchFilters.channl.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 if_reg
		<include refid="ifReg.queryPage" />
	</select>

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

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

	<!-- 根据接口服务编码 接口服务名称 查询接口用户 -->
	<select id="getIfRegByServiceCodeAndServiceName" resultClass="ifRegPo">
		SELECT * from if_reg where serviceCode = #serviceCode# and serviceName = #serviceName#
	</select>
</sqlMap>
