一、shiro授权角色、权限
思路:
给用户授予角色 给用户授予权限 做法: 1、拿到账号 2、通过用户账号查询对应的能够看到的那些菜单 3、将这些权限交给shiro管理 授予角色做法: 1、拿到账号 2、通过用户账号查询对应的能够看到的那些角色 3、将这些权限交给shiro管理 mapper.xml Mapper.java Service.java
Mapper.xml
<!--添加通过账号查询用户信息-->
<select id="queryByName" resultType="com.dhm.model.ShiroUser" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from t_shiro_user
where username = #{userName}
</select>
<select id="getRolesByUserId" resultType="java.lang.String" parameterType="java.lang.Integer">
select r.roleid from t_shiro_user u,t_shiro_user_role ur,t_shiro_role r
where u.userid = ur.userid and ur.roleid = r.roleid
and u.userid = #{userid}
</select>
<select id="getPersByUserId" resultType="java.lang.String" parameterType="java.lang.Integer">
select p.permission from t_shiro_user u,t_shiro_user_role ur,t_shiro_role_permission rp,t_shiro_permission p
where u.userid = ur.userid and ur.roleid = rp.roleid and rp.perid = p.perid
and u.userid = #{userid}
</select>
ShiroUserMapper.java / Service层
public Set<String> getRolesByUs