<?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.ruoyi.system.mapper.SysPostMapper">

	<resultMap type="com.ruoyi.system.domain.SysPost" id="SysPostResult">
		<id     property="postId"        column="post_id"       />
		<result property="postCode"      column="post_code"     />
		<result property="postName"      column="post_name"     />
		<result property="postSort"      column="post_sort"     />
		<result property="status"        column="status"        />
		<result property="createBy"      column="create_by"     />
		<result property="createTime"    column="create_time"   />
		<result property="updateBy"      column="update_by"     />
		<result property="updateTime"    column="update_time"   />
		<result property="remark"        column="remark"        />
	</resultMap>

	<select id="selectPostListByUserId" resultType="java.lang.Long">
		SELECT p.post_id
        FROM sys_post p
		LEFT JOIN sys_user_post up ON up.post_id = p.post_id
		LEFT JOIN sys_user u ON u.user_id = up.user_id
	    WHERE p.del_flag = #{delFlag}
	    AND u.user_id = #{userId}
	</select>

	<select id="selectPostsByUserName" resultMap="SysPostResult">
		SELECT p.post_id, p.post_name, p.post_code
		FROM sys_post p
		LEFT JOIN sys_user_post up ON up.post_id = p.post_id
		LEFT JOIN sys_user u ON u.user_id = up.user_id
	    WHERE p.del_flag = #{delFlag}
		AND u.user_name = #{userName}
	</select>

</mapper>