<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper    
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"    
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">

<mapper namespace="com.platform.dao.GatherOracleDao">
	<resultMap type="com.platform.entities.GatherOracleInfo" id="getEntityBytext">
		<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
		<result property="port" column="service_port" javaType="int" jdbcType="INTEGER"/>
		<result property="ip" column="service_ip" javaType="string" jdbcType="VARCHAR"/>
		<result property="name" column="service_name" javaType="string" jdbcType="VARCHAR"/>
		<result property="user" column="service_user" javaType="string" jdbcType="VARCHAR"/>
		<result property="password" column="service_password" javaType="string" jdbcType="VARCHAR"/>
		<result property="databaseName" column="service_database" javaType="string" jdbcType="VARCHAR"/>
		<result property="tableName" column="service_table" javaType="string" jdbcType="VARCHAR"/>
		<result property="suffix" column="service_suffix" javaType="string" jdbcType="VARCHAR"/>
		<result property="status" column="service_status" javaType="string" jdbcType="VARCHAR"/>
		<result property="remove" column="remove" jdbcType="CHAR"/>
	</resultMap>
	<sql id="baseOracleInfo">
		id id, service_port port, service_ip ip, service_name name, service_user user, service_password password, service_database databaseName, service_table tableName, service_suffix suffix, service_status status
	</sql>

	<select id="selectAllOracle" resultType="com.platform.entities.GatherOracleInfo">
		SELECT
		<include refid="baseOracleInfo" />
		FROM services_info
		WHERE remove = "0"
	</select>
	
	<insert id="insertOracle" parameterType="com.platform.entities.GatherOracleInfo">
		INSERT INTO
		services_info(
		<trim suffixOverrides=",">
			<if test="port > 0">
				service_port,
			</if>
			<if test="ip != null and ip != ''">
				service_ip,
			</if>
			<if test="name != null and name != ''">
				service_name,
			</if>
			<if test="user != null and user != ''">
				service_user,
			</if>
			<if test="password != null and password != ''">
				service_password,
			</if>
			<if test="databaseName != null and databaseName != ''">
				service_database,
			</if>
			<if test="tableName != null and tableName != ''">
				service_table,
			</if>
			<if test="suffix != null and suffix != ''">
				service_suffix,
			</if>
			<if test="status != null and status != ''">
				service_status,
			</if>
		</trim>
		)
		VALUES(
		<trim suffixOverrides=",">
			<if test="port > 0">
				#{port},
			</if>
			<if test="ip != null and ip != ''">
				#{ip},
			</if>
			<if test="name != null and name != ''">
				#{name},
			</if>
			<if test="user != null and user != ''">
				#{user},
			</if>
			<if test="password != null and password != ''">
				#{password},
			</if>
			<if test="databaseName != null and databaseName != ''">
				#{databaseName},
			</if>
			<if test="tableName != null and tableName != ''">
				#{tableName},
			</if>
			<if test="suffix != null and suffix != ''">
				#{suffix},
			</if>
			<if test="status != null and status != ''">
				#{status},
			</if>
		</trim>
		)
	</insert>
	
	<delete id="deleteOracleById" parameterType="java.lang.Integer">
		DELETE FROM services_info 
		<where>
			id =#{id}
		</where>
	</delete>
	
	<update id="updateOracleById" parameterType="com.platform.entities.GatherOracleInfo">
		UPDATE
		services_info
		<set >
			<trim suffixOverrides=",">
				<if test="name != null and name != ''">
					service_name = #{name},
				</if>
				<if test="ip != null and ip != ''">
					service_ip = #{ip},
				</if>
				<if test="port > 0">
					service_port= #{port},
				</if>
				<if test="user != null and user != ''">
					service_user= #{user},
				</if>
				<if test="password != null and password != ''">
					service_password= #{password},
				</if>
				<if test="databaseName != null and databaseName != ''">
					service_database= #{databaseName},
				</if>
				<if test="tableName != null and tableName != ''">
					service_table= #{tableName},
				</if>
				<if test="suffix != null and suffix != ''">
					service_suffix= #{suffix},
				</if>
				<if test="status != null and status != ''">
					service_status= #{status},
				</if>
				<if test="remove != null and remove != ''">
					remove= #{remove},
				</if>
			</trim>
		</set>
		<where>
			id = #{id}
		</where>
	</update>
	
</mapper>