<?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.vo.SysPostVO" id="SysPostResult">
		<id     property="id"        column="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>
	
	<sql id="selectPostVo">
        select id, post_code, post_name, post_sort, status, create_by, create_time, remark
		from sys_post
    </sql>
	
	<select id="selectPostsByUserId" parameterType="String" resultMap="SysPostResult">
		SELECT p.id, p.post_name, p.post_code
		FROM sys_user u
			 LEFT JOIN sys_user_post up ON u.id = up.user_id
			 LEFT JOIN sys_post p ON up.post_id = p.id
		WHERE up.user_id = #{userId}
	</select>

</mapper> 