Appearance
字段拦截
此功能可完成字段修改,列如:加密、解密、掩码、一对一、一对多、多对多等功能,涉及一个注解类和一个接口类。
java
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Processor {
Class<? extends ActionProcessor> value();
}| 属性 | 描述 |
|---|---|
| value | 字段拦截处理类 |
java
/**
* 此接口继承自LoopAction,具备查询结果遍历功能
*/
public interface ActionProcessor extends LoopAction {
/**
* 提供额外信息参数,加强版loopAction
*
* @param field 注解修饰的对象属性
* @param paramMap 注解的内容
* @param configuration 工厂配置
*/
void init(Field field, Map<String, Object> paramMap, Configuration configuration);
}| 参数属性 | 描述 |
|---|---|
| field | 注解修饰的对象属性 |
| paramMap | 注解的内容 |
| configuration | 全局配置 |
一对一,一对多,多对多
java
@Processor(FetchActionProcessor.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Fetch {
/**
* 自定义sql满足复杂开发
*
* @return
*/
String sql();
}| 属性 | 描述 |
|---|---|
| sql | 需要执行的sql,执行结果值填充到注解修饰的字段里 |
另外也提供容易的fetch
java
@Processor(EasyFetchActionProcessor.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface EasyFetch {
/**
* 查询的目标表,为空则根据字段属性类型取表名
*
* @return
*/
String table() default "";
/**
* 目标条件字段
*
* @return
*/
String column();
/**
* 需要查询的目标字段,为空则根据字段属性类型决定查询字段
*
* @return
*/
String[] columns() default {};
/**
* 当前对象属性名,取该值和目标条件字段作为查询条件
*
* @return
*/
String field();
}