<?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.ygtx.system.mapper.SysDeptPostMapper">

	<resultMap type="SysDeptPost" id="SysDeptPostResult">
		<result property="deptId"     column="dept_id"      />
		<result property="postId"     column="post_id"      />
		<result property="isMain"     column="is_main"      />
	</resultMap>
	
	<delete id="deleteDeptPostByDeptId" parameterType="Long">
		delete from sys_dept_post where dept_id = #{deptId}
	</delete>
	
	<delete id="deleteDeptPost" parameterType="Long">
		delete from sys_dept_post where dept_id in
		<foreach collection="array" item="deptId" open="(" separator="," close=")">
			#{deptId}
		</foreach>
	</delete>
	
	<select id="selectCountDeptPostByPostId" resultType="Integer">
	    select count(1) from sys_dept_post where post_id = #{postId}
	</select>
	
	<insert id="batchDeptPost">
		insert into sys_dept_post(dept_id, post_id, is_main) values
		<foreach item="item" index="index" collection="list" separator=",">
			(#{item.deptId},#{item.postId},#{item.isMain})
		</foreach>
	</insert>
	
	<select id="selectPostListByDeptId" parameterType="Long" resultType="Long">
		select post_id from sys_dept_post where dept_id = #{deptId}
	</select>
	
	<select id="selectMainPostByDeptId" parameterType="Long" resultType="Long">
		select post_id from sys_dept_post where dept_id = #{deptId} and is_main = '1'
	</select>
	
	<select id="selectVicePostListByDeptId" parameterType="Long" resultType="Long">
		select post_id from sys_dept_post where dept_id = #{deptId} and is_main = '0'
	</select>
	
</mapper>