You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.annotation ;
import java.lang.annotation.ElementType ;
import java.lang.annotation.Retention ;
import java.lang.annotation.RetentionPolicy ;
import java.lang.annotation.Target ;
/**
* 登录用户信息
*/
/**
* 自定义的注解类型 @LoginUser, 用于标记方法参数, 通常在Java的Web开发等场景下有特定用途,
* 一般可用于标识某个参数代表的是当前登录用户的相关信息,方便在方法中对登录用户的信息进行获取、处理以及基于用户权限等进行相关业务逻辑操作,
* 其作用范围通过 @Target 注解指定为只能用于方法参数( ElementType.PARAMETER) , 生命周期通过 @Retention 注解指定为在运行时( RetentionPolicy.RUNTIME) 有效,
* 这样在程序运行期间可以通过反射等机制来获取到该注解相关信息并进行相应处理。
*/
// @Target 注解用于指定该自定义注解可以应用的目标元素类型,这里指定为 ElementType.PARAMETER, 表示此注解只能用于方法参数上,
// 意味着它可以标记那些在方法中接收登录用户信息的参数,以便框架或者其他相关代码能识别并处理这些参数。
@Target ( ElementType . PARAMETER )
// @Retention 注解用于定义该注解的保留策略,即规定注解在什么阶段是可见可用的,这里设置为 RetentionPolicy.RUNTIME, 表示在运行时该注解信息仍然保留,
// 可以通过Java的反射机制在运行期间获取到该注解及其属性值等信息, 常用于根据注解来动态执行一些业务逻辑的场景。
@Retention ( RetentionPolicy . RUNTIME )
// 定义了一个名为 @LoginUser 的注解,此注解本身没有定义成员变量(属性),如果后续有需要,也可以添加属性来传递更多关于登录用户相关的配置信息等,比如用户角色、权限级别等相关限定信息。
public @interface LoginUser {
}