<?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.zcloud.mapper.dsno1.corp.CorpPlsInfoMapper">

	<!--表名 -->
	<sql id="tableName">
		BUS_CORP_PLS_INFO
	</sql>

	<!-- 字段 -->
	<sql id="Field">
		f.CORPINFO_ID,
		f.POST_URL,
		f.ACCOUNT,
		f.PASSWORD,
		f.TOKEN,
		f.EXPIRE_TIME,
	    f.TILES3D_URL,
		f.USE_URL

	</sql>

	<!-- 字段用于新增 -->
	<sql id="Field2">
		CORPINFO_ID,
		POST_URL,
		ACCOUNT,
		PASSWORD,
		TOKEN,
		EXPIRE_TIME,
	    TILES3D_URL,
		USE_URL,
		ENTERPRISE_CODE,
		DEPT_ID
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{CORPINFO_ID},
		#{POST_URL},
		#{ACCOUNT},
		#{PASSWORD},
		#{TOKEN},
		#{EXPIRE_TIME},
		#{TILES3D_URL},
		#{USE_URL},
		#{ENTERPRISE_CODE},
		#{DEPT_ID}
	</sql>

	<!-- 新增-->
	<insert id="save" parameterType="pd">
		insert into
	<include refid="tableName"></include>
		(
	<include refid="Field2"></include>
		) values (
	<include refid="FieldValue"></include>
		)
	</insert>

	<!-- 删除-->
	<delete id="delete" parameterType="pd">
		delete from
		<include refid="tableName"></include>
		where
			CORPINFO_ID = #{CORPINFO_ID}
	</delete>

	<!-- 修改 -->
	<update id="edit" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
			CORPINFO_ID = #{CORPINFO_ID},
			POST_URL = #{POST_URL},
			ACCOUNT = #{ACCOUNT},
			PASSWORD = #{PASSWORD},
		    TILES3D_URL = #{TILES3D_URL},
		    USE_URL = #{USE_URL},
		    ENTERPRISE_CODE = #{ENTERPRISE_CODE},
		    DEPT_ID = #{DEPT_ID}
		where
		CORPINFO_ID = #{CORPINFO_ID}
	</update>

	<!-- 通过ID获取数据 -->
	<select id="findById" parameterType="pd" resultType="pd">
		select
		f.*
		from
		<include refid="tableName"></include> f
		where
			f.CORPINFO_ID = #{CORPINFO_ID}
	</select>

	<select id="getDeptIdandempId" parameterType="pd" resultType="pd">
		SELECT
			i.enterpriseId,
			o.deptId
		FROM
			bus_corp_info i
				LEFT JOIN oa_department o ON i.CORPINFO_ID = o.CORPINFO_ID
		WHERE
			i.CORPINFO_ID = #{CORPINFO_ID}
		  AND o.DEPARTMENT_ID = #{DEPARTMENT_ID}
	</select>
</mapper>
