SELECT
a.id,
a.userName,
a.realName,
c.departmentId,
d.`name` AS departmentName,
d.is_branch,
c.postId,
e.`name` AS postName
FROM
fine_user a
LEFT JOIN fine_user_role_middle b ON a.id = b.userId --用户角色的中间表
AND b.roleType = 1
LEFT JOIN fine_dep_role c ON c.id = b.roleId --部门职位的中间表
LEFT JOIN fine_department d ON d.id = c.departmentId --部门表
LEFT JOIN fine_post e ON e.id = c.postId --职位表
WHERE a.userName = '${fine_username}'
通过用户查询所在的部门和角色,职位信息表