ADD file via upload

main
pe9vkn3zc 5 months ago
parent 1955a1f35a
commit 81e1c1b9e0

@ -0,0 +1,61 @@
package com.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
*
* <p>Spring MVC
* Controller</p>
*
* <p><b></b>
* <ul>
* <li></li>
* <li>Controller</li>
* <li>Spring Security</li>
* </ul>
*
* <p><b>使</b>
* <pre>{@code
* @GetMapping("/orders")
* public ResponseEntity<List<Order>> getUserOrders(
* @LoginUser User user // 自动注入当前登录用户
* ) {
* return orderService.findByUser(user);
* }
* }</pre>
*
* @author YourName
* @version 1.0
* @since 2023-10-01
*/
@Target(ElementType.PARAMETER) // 限定注解仅能标注在方法参数上
@Retention(RetentionPolicy.RUNTIME) // 注解在运行时保留,可通过反射机制读取
public @interface LoginUser {
/**
* true
*
* <p>true(401)
* falsenull</p>
*
* @return
*/
boolean required() default true;
/**
*
*
* <p>访
* <ul>
* <li>UserType.REGULAR - </li>
* <li>UserType.ADMIN - </li>
* </ul>
* 403访</p>
*
* @return 访
*/
String[] allowedRoles() default {};
}
Loading…
Cancel
Save