最新产品
This commit is contained in:
		
							
								
								
									
										22
									
								
								src/main/java/com/yj/earth/annotation/EncryptResponse.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/main/java/com/yj/earth/annotation/EncryptResponse.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
package com.yj.earth.annotation;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 返回结果加密注解
 | 
			
		||||
 */
 | 
			
		||||
@Target({ElementType.METHOD})
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
@Documented
 | 
			
		||||
public @interface EncryptResponse {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 加密密钥的配置键
 | 
			
		||||
     */
 | 
			
		||||
    String keyProperty() default "encrypt.aes.key";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 加密算法模式
 | 
			
		||||
     */
 | 
			
		||||
    String algorithm() default "AES/CBC/PKCS5Padding";
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										34
									
								
								src/main/java/com/yj/earth/annotation/ExcludeField.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/main/java/com/yj/earth/annotation/ExcludeField.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
package com.yj.earth.annotation;
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.core.JsonGenerator;
 | 
			
		||||
import com.fasterxml.jackson.databind.SerializerProvider;
 | 
			
		||||
import com.fasterxml.jackson.databind.ser.PropertyWriter;
 | 
			
		||||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.ElementType;
 | 
			
		||||
import java.lang.annotation.Retention;
 | 
			
		||||
import java.lang.annotation.RetentionPolicy;
 | 
			
		||||
import java.lang.annotation.Target;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 用于标记需要在JSON序列化时排除的字段
 | 
			
		||||
 */
 | 
			
		||||
@Target(ElementType.FIELD)
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
public @interface ExcludeField {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Jackson 序列化过滤器、用于过滤被 @ExcludeField 注解标记的字段
 | 
			
		||||
     */
 | 
			
		||||
    class Filter extends SimpleBeanPropertyFilter {
 | 
			
		||||
        @Override
 | 
			
		||||
        public void serializeAsField(Object pojo, JsonGenerator jsonGenerator, SerializerProvider provider, PropertyWriter writer) throws Exception {
 | 
			
		||||
            // 检查字段是否有 @ExcludeField 注解、如果有则不序列化该字段
 | 
			
		||||
            if (writer.getAnnotation(ExcludeField.class) != null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            // 没有注解的字段正常序列化
 | 
			
		||||
            super.serializeAsField(pojo, jsonGenerator, provider, writer);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								src/main/java/com/yj/earth/annotation/RoleAccess.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/main/java/com/yj/earth/annotation/RoleAccess.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
package com.yj.earth.annotation;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 角色访问控制注解
 | 
			
		||||
 */
 | 
			
		||||
@Target({ElementType.METHOD})
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
@Documented
 | 
			
		||||
public @interface RoleAccess {
 | 
			
		||||
    /**
 | 
			
		||||
     * 允许访问的角色名称数组
 | 
			
		||||
     */
 | 
			
		||||
    String[] roleNames();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								src/main/java/com/yj/earth/annotation/SourceType.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/main/java/com/yj/earth/annotation/SourceType.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
package com.yj.earth.annotation;
 | 
			
		||||
 | 
			
		||||
import java.lang.annotation.*;
 | 
			
		||||
 | 
			
		||||
@Target(ElementType.TYPE)
 | 
			
		||||
@Retention(RetentionPolicy.RUNTIME)
 | 
			
		||||
public @interface SourceType {
 | 
			
		||||
    String value();
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user