Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
ldp-docs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
doc
ldp-docs
Commits
4e1f12df
Commit
4e1f12df
authored
Oct 09, 2020
by
马超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 字典注解文档
parent
554d1720
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
6 deletions
+83
-6
LDP 框架自定义注解.md
开发文档/LDP 框架自定义注解.md
+83
-6
No files found.
开发文档/LDP 框架自定义注解.md
View file @
4e1f12df
...
@@ -653,15 +653,15 @@ public void exportExcelByAnnotation(OutputStream outputStream, ExcelOptions exce
...
@@ -653,15 +653,15 @@ public void exportExcelByAnnotation(OutputStream outputStream, ExcelOptions exce
## 七、模糊查询注解
## 七、模糊查询注解
###
6
.1. @HqlQueryFilter
###
7
.1. @HqlQueryFilter
依赖:common-biz-annotation
依赖:common-biz-annotation
####
6
.1.1 注解介绍
####
7
.1.1 注解介绍
**@HqlQueryFilter** 是一个字段注解,主要用于标识实体类字段作为列表过滤字段时,数据库查询的匹配方式。目前仅包含精确匹配(QueryFilterType.EQUAL)、模糊匹配(QueryFilterType.ELIKE)
**@HqlQueryFilter** 是一个字段注解,主要用于标识实体类字段作为列表过滤字段时,数据库查询的匹配方式。目前仅包含精确匹配(QueryFilterType.EQUAL)、模糊匹配(QueryFilterType.ELIKE)
####
6
.1.2 使用案例
####
7
.1.2 使用案例
在过滤字段上加上注解,以及匹配方式
在过滤字段上加上注解,以及匹配方式
...
@@ -674,15 +674,15 @@ public void exportExcelByAnnotation(OutputStream outputStream, ExcelOptions exce
...
@@ -674,15 +674,15 @@ public void exportExcelByAnnotation(OutputStream outputStream, ExcelOptions exce
private String name;
private String name;
```
```
###
6
.1. @HqlQueryFilterService
###
7
.1. @HqlQueryFilterService
依赖:common-biz-annotation
依赖:common-biz-annotation
####
6
.1.1 注解介绍
####
7
.1.1 注解介绍
**@HqlQueryFilterService** 是一个方法注解,根据实体类字段中的 **@HqlQueryFilter** 规则自动构建查询条件数组LinkedList<Condition>。
**@HqlQueryFilterService** 是一个方法注解,根据实体类字段中的 **@HqlQueryFilter** 规则自动构建查询条件数组LinkedList<Condition>。
####
6
.1.2 使用案例
####
7
.1.2 使用案例
当Rest层调用此方法时,Aop拦截会通过遍历参数Map,并从实体类中获取相应字段及注解,来构建Condition数组。
当Rest层调用此方法时,Aop拦截会通过遍历参数Map,并从实体类中获取相应字段及注解,来构建Condition数组。
...
@@ -694,7 +694,84 @@ public List<ExampleUserInfo> findListByLikeCondition(Map<String, Object> param,
...
@@ -694,7 +694,84 @@ public List<ExampleUserInfo> findListByLikeCondition(Map<String, Object> param,
}
}
```
```
## 八、字典对象属性填充注解
### 8.1. @DictProperties
依赖:common-biz-annotation
#### 8.1.1 注解介绍
**@DictProperties** 是一个类注解,通过属性`propertyPref`标识字典项key的前缀,配合工具类DictCommonDto使用,通过构建一个DTO获取相同字典类型下所有的字典value。
#### 8.1.2 使用案例
这里使用读取邮箱配置相关字典值来举例,邮箱服务器相关字典类型编码为**sys.email.code**,其余属性分别为
| 字典项编码 | 备注 |
| -------------- | -------------- |
| email.host | 邮件服务器地址 |
| email.port | 邮件服务器端口 |
| email.account | 发件方账号 |
| email.password | 发件方密码 |
| email.ssl | 是否使用ssl |
第一步,对应字典项编写一个DTO,加上注解 **@DictProperties** ,`propertyPref`指定字典项的前缀,属性名称为除开前缀后的部分,如果有多段名称,需要使用驼峰命名,例:字典项为email.prof.demo时,属性名为profDemo。
```
java
@Getter
@Setter
@DictProperties(propertyPref = "email")
public class EmailServerDTO {
private String host;
private String port;
private String account;
private String password;
private String ssl;
private String testEmail;
}
```
第二步,通过字典接口,使用字典类型编码获取字典项列表,并使用工具类对DTO对象进行赋值
```
java
//getEmailDictList方法通过sys.email.code获取所有字典项列表
List
<DictInfo2>
emailDictList = getEmailDictList();
EmailServerDTO serverDTO = new EmailServerDTO();
try {
//通过工具类将值赋值到Dto对象中
serverDTO = DictCommonDto.toDictDto(emailDictList, serverDTO);
} catch (Exception e) {
e.printStackTrace();
}
```
### 8.2. @DictAlias
依赖:common-biz-annotation
#### 8.2.1 注解介绍
**@DictAlias** 是一个字段注解,需要配合**@DictProperties** 使用,由于使用统一的前缀要求属性名称与字典项编码一一对应,使用@DictAlias注解的字段可以不与字典项编码保持一致。
#### 8.2.2 使用案例
第一步仍然是编写DTO类,类似下方案例,没有通用的前缀,所以通过@DictAlias注解指定对应的字典项。
```
java
@Setter
@Getter
@NoArgsConstructor
@DictProperties(propertyPref = "")
public class RootCodeDTO {
@DictAlias(name = "org.root.code")
private String orgRoot;
@DictAlias(name = "func.app.root.code")
private String funcRoot;
@DictAlias(name = "func.manage.root.code")
private String manageRoot;
}
```
第二步与8.1.2中的填充方式一致。
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment