8 changed files with 294 additions and 0 deletions
-
11common/src/main/java/com/storeroom/annotaion/AnonymousAccess.java
-
23common/src/main/java/com/storeroom/annotaion/Limit.java
-
71common/src/main/java/com/storeroom/annotaion/Query.java
-
45common/src/main/java/com/storeroom/annotaion/rest/AnonymousDeleteMapping.java
-
45common/src/main/java/com/storeroom/annotaion/rest/AnonymousGetMapping.java
-
45common/src/main/java/com/storeroom/annotaion/rest/AnonymousPostMapping.java
-
45common/src/main/java/com/storeroom/annotaion/rest/AnonymousPutMapping.java
-
9common/src/main/java/com/storeroom/aspect/LimitType.java
@ -0,0 +1,11 @@ |
|||
package com.storeroom.annotaion; |
|||
|
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
@Inherited |
|||
@Documented |
|||
@Target({ElementType.METHOD,ElementType.ANNOTATION_TYPE}) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
public @interface AnonymousAccess { |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.storeroom.annotaion; |
|||
|
|||
import com.storeroom.aspect.LimitType; |
|||
|
|||
public @interface Limit { |
|||
//资源名称,用于描述资源接口功能 |
|||
String name() default ""; |
|||
|
|||
// 资源 key |
|||
String key() default ""; |
|||
|
|||
// key prefix |
|||
String prefix() default ""; |
|||
|
|||
// 时间的,单位秒 |
|||
int period(); |
|||
|
|||
// 限制访问次数 |
|||
int count(); |
|||
|
|||
// 限制类型 |
|||
LimitType limitType() default LimitType.CUSTOMER; |
|||
} |
@ -0,0 +1,71 @@ |
|||
package com.storeroom.annotaion; |
|||
|
|||
|
|||
import java.lang.annotation.ElementType; |
|||
import java.lang.annotation.Retention; |
|||
import java.lang.annotation.RetentionPolicy; |
|||
import java.lang.annotation.Target; |
|||
|
|||
@Target(ElementType.FIELD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
public @interface Query { |
|||
|
|||
//基本对象的属性名 |
|||
String propName() default ""; |
|||
|
|||
//查询方式 |
|||
Type type() default Type.EQUAL; |
|||
|
|||
/** |
|||
* 连接查询的属性名,如User类中的dept |
|||
*/ |
|||
String joinName() default ""; |
|||
|
|||
/** |
|||
* 默认左连接 |
|||
*/ |
|||
Join join() default Join.LEFT; |
|||
|
|||
/** |
|||
* 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username") |
|||
*/ |
|||
String blurry() default ""; |
|||
|
|||
enum Type { |
|||
// 相等 |
|||
EQUAL |
|||
// 大于等于 |
|||
, GREATER_THAN |
|||
// 小于等于 |
|||
, LESS_THAN |
|||
// 中模糊查询 |
|||
, INNER_LIKE |
|||
// 左模糊查询 |
|||
, LEFT_LIKE |
|||
// 右模糊查询 |
|||
, RIGHT_LIKE |
|||
// 小于 |
|||
, LESS_THAN_NQ |
|||
// 包含 |
|||
, IN |
|||
// 不包含 |
|||
, NOT_IN |
|||
// 不等于 |
|||
,NOT_EQUAL |
|||
// between |
|||
,BETWEEN |
|||
// 不为空 |
|||
,NOT_NULL |
|||
// 为空 |
|||
,IS_NULL |
|||
} |
|||
|
|||
/** |
|||
* @author |
|||
* 适用于简单连接查询,复杂的请自定义该注解,或者使用sql查询 |
|||
*/ |
|||
enum Join { |
|||
|
|||
LEFT, RIGHT, INNER |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.storeroom.annotaion.rest; |
|||
|
|||
|
|||
import com.storeroom.annotaion.AnonymousAccess; |
|||
import org.springframework.core.annotation.AliasFor; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
@AnonymousAccess |
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
@RequestMapping(method = RequestMethod.DELETE) |
|||
public @interface AnonymousDeleteMapping { |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String name() default ""; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] value() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] path() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] params() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] headers() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] consumes() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] produces() default {}; |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.storeroom.annotaion.rest; |
|||
|
|||
|
|||
import com.storeroom.annotaion.AnonymousAccess; |
|||
import org.springframework.core.annotation.AliasFor; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
@AnonymousAccess |
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
@RequestMapping(method = RequestMethod.GET) |
|||
public @interface AnonymousGetMapping { |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String name() default ""; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] value() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] path() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] params() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] headers() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] consumes() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] produces() default {}; |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.storeroom.annotaion.rest; |
|||
|
|||
|
|||
import com.storeroom.annotaion.AnonymousAccess; |
|||
import org.springframework.core.annotation.AliasFor; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
@AnonymousAccess |
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
@RequestMapping(method = RequestMethod.POST) |
|||
public @interface AnonymousPostMapping { |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String name() default ""; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] value() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] path() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] params() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] headers() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] consumes() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] produces() default {}; |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.storeroom.annotaion.rest; |
|||
|
|||
|
|||
import com.storeroom.annotaion.AnonymousAccess; |
|||
import org.springframework.core.annotation.AliasFor; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
|
|||
import java.lang.annotation.*; |
|||
|
|||
@AnonymousAccess |
|||
@Target(ElementType.METHOD) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
@RequestMapping(method = RequestMethod.PUT) |
|||
public @interface AnonymousPutMapping { |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String name() default ""; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] value() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] path() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] params() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] headers() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] consumes() default {}; |
|||
|
|||
|
|||
@AliasFor(annotation = RequestMapping.class) |
|||
String[] produces() default {}; |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.storeroom.aspect; |
|||
|
|||
public enum LimitType { |
|||
|
|||
// 默认 |
|||
CUSTOMER, |
|||
// by ip addr |
|||
IP |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue