目标
1、shiro授权角色、权限
2、Shiro的注解式开发
shiro的权限设计图:
授权
在ShiroUserMapper.xml中新增内容
<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 = #{uid}
</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 = #{uid}
</select>
Service层
package com.ly.service;
import com.ly.model.ShiroUser;
import java.util.Set;
/**
* @author 毅哥哥
* @site
* @company
* @create 2019-10-13 16:13
*/
public interface ShiroUserService {
/**
* 用于shiro认证
* @param uname
* @return
*/
public ShiroUser queryByName(String uname);
int insert(ShiroUser shiroUser);
Set<String> getRolesByUserId(Integer uid);
Set<String> getPersByUserId(Integer uid);
}
package com