权限拦截器
<p>在方法和类中添加以下注释
<code>@AuthAnno</code>
其中属性有几种:</p>
<pre><code class="language-java">/**
* 默认的认证类型:满足权限用户才可以访问。<br>
* <strong style="color:red">一般作用于类上</strong>,代表该类适合访问的身份(所有人、登录用户、超级管理员)
* @return
*/
public AuthType type() default AuthType.Auth;
/**
* 资源标识,用于和权限关键字结果组成某个权限。<br>
* <strong style="color:red">一般作用于类上</strong>,
* @return
*/
public String res() default "";
/**
* 菜单标识,用于回显选中菜单<br>
* <strong style="color:red">一般作用于类上</strong>,
* @return
*/
public String menu() default "";
/**
* 默认登录地址<br>
* <strong style="color:red">一般作用于类上</strong>,基本不会变动
* @return
*/
public String loginUrl() default "/login";
/**
* <pre>
* 权限关键字,有此关键字权限,才可以进入该方法,否则抛出异常
* <strong style="color:red">一般作用于方法上</strong>,在判断权限的时候,会将 res() 上的值 和 auth() 值进行拼接组合成权限标识
* AuthAnno(auth="look")。
* <strong>注意:此注解的前提是类上面必须有注解了</strong>
* </pre>
* @return
*/
public String auth() default "look";</code></pre>
<p>其中在类上的注释主要是</p>
<pre><code class="language-java">// 其中type有三个:
//* anyone 任何人都可以访问
//* super 只有超级管理员可以访问
//* auth 满足权限的登录用户可以
// res 和 menu的解释在上面中已经说明
@AuthAnno(type=AuthType.Super,res="auth_sign")
public class AuthSignController extends BaseController {
...
}</code></pre>
<p>在方法上的注释主要是</p>
<pre><code class="language-java">// auth 的意思是必须要有此权限方可进入方法。
// 注意:此注解的前提是类上面必须有注解了
@AuthAnno(auth="look")
public void index() throws Exception{
...
}</code></pre>