更新
continuous-integration/drone/push Build is failing Details

This commit is contained in:
clay 2023-03-30 13:53:30 +08:00
parent 956333d270
commit 16a2cf35d0
1 changed files with 148 additions and 15 deletions

View File

@ -60,32 +60,165 @@ List<OptionTree> optionTreeList = TreeUtil.build(deptList,OptionTree.class,(conf
- mapper其余字段关系映射
- exclude排除字段
## common-feign
openfeign进行基础的配置,比如让OpenFeign 使用 OkHttp 配置类,以及Ribbon做rpc的负载均衡
## common-dubbo
dubbo的基础依赖
## common-log
自定义操作日志模块,完成使用自定义注解实现操作日志的记录
```javascript
@ApiOperation("新增部门")
@PostMapping
@PreAuthorize("@ss.hasPermission('admin:dept:add')")
@Log(title = "新增部门",businessType = BusinessType.INSERT)
public Result<Void> add(@RequestBody @Validated Dept dept){
if (UserConstants.DEPT_DISABLE.equals(deptService.checkDeptNameUnique(dept))){
return Result.error("新增部门: "+ dept.getDeptName() +"'失败,部门名称以存在!");
}
deptService.saveDept(dept);
return Result.ok();
@ApiOperation("新增部门")
@PostMapping
@PreAuthorize("@ss.hasPermission('admin:dept:add')")
@Log(title = "新增部门",businessType = BusinessType.INSERT)
public Result<Void> add(@RequestBody @Validated Dept dept){
if (UserConstants.DEPT_DISABLE.equals(deptService.checkDeptNameUnique(dept))){
return Result.error("新增部门: "+ dept.getDeptName() +"'失败,部门名称以存在!");
}
deptService.saveDept(dept);
return Result.ok();
}
```
通过LogAspect实现当前注解的apo切面,切面中将操作的日志封装成一个操作日志对象,然后使用spring的事件发布机制发布这个日志操作对象,再使用OperationLogListener异步监听到发布的事件,再通过rpc远程调用到umps中的日志存储接口,将当前对象落地到数据库
`@Log`注解参数说明
|参数 | 类型 | 默认 | 描述|
| :-- | :-- | :-- | :-- |
| title | String | 空 | 日志记录名称 |
| businessType | BusinessType | OTHER | 功能,具体操作有 OTHER,INSERT,UPDATE,DELETE,GRANT,EXPORT,IMPORT,FORCE,GENCODE,CLEAN,BIND |
| operatorType | OperateType | MANAGE | 操作人类别 |
| isSaveRequestData | boole | 空 | 是否保存请求的参数 |
## common-mybatis
对mybatis的基本分页功能进行封装
为了更加方便的使用系统分页,我们对mybatis的pageHelper做了一些封装
### PageUtils类
```javascript
/**
* 分页工具类
*
* @author Clay
* @date 2022/10/30
*/
public class PageUtils extends PageHelper {
## common-oss
对接阿里云的oos分布式对象储存服务,
/**
* 设置请求分页
*/
public static void startPage() {
Page page = TableSupport.buildPageRequest();
Integer pageNum = page.getPageNum();
Integer pageSize = page.getPageSize();
String orderBy = SqlUtil.escapeOrderBySql(page.getOrderBy());
Boolean reasonable = page.getReasonable();
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
}
/**
* 开始的Size
*
* @param page
* @return
*/
public static Integer getStartSize(Page page) {
return (page.getPageNum() - 1) * page.getPageNum();
}
public static Integer getStartSize() {
Page page = TableSupport.buildPageRequest();
return (page.getPageNum() - 1) * page.getPageSize();
}
/**
* 获取到分页后的数据信息
*
* @param list
* @param <T>
* @return
*/
public static <T> TableDataInfo<T> getDataTable(List<T> list) {
if (null == list) {
return new TableDataInfo<>(new ArrayList<>(), 0);
}
TableDataInfo<T> tableDataInfo = new TableDataInfo<>();
tableDataInfo.setRows(list);
tableDataInfo.setTotal(getTotal(list));
return tableDataInfo;
}
/**
* 获取到分页的总数
*
* @param list
* @return
*/
public static Long getTotal(List<?> list) {
long total = new PageInfo<>(list).getTotal();
clearPage();
return total;
}
/**
* 转换为TableDataInfo对象
*
* @param list
* @param count
* @param <T>
* @return
*/
public static <T> TableDataInfo<T> convertDataTable(List<T> list, Long count) {
if (null == list) {
return new TableDataInfo<>(new ArrayList<>(), 0);
}
TableDataInfo<T> tableDataInfo = new TableDataInfo<>();
tableDataInfo.setRows(list);
tableDataInfo.setTotal(count);
return tableDataInfo;
}
/**
* 清理分页的线程变量
*/
public static void clearPage() {
PageHelper.clearPage();
}
}
```
### 分页操作
只需要在执行SQL的Mapper之前调用`PageUtils.startPage()`方法,然后调用SQL执行方法,再使用获取到的数组调用PageUtils.getDataTable(list)方法获取到封装好的返回结果对象即。
## common-file
在集群环境下文件不能够单独放置在某一个单一节点执行需要集中存储起来我们提供了阿里云的oss自建服务的minio以及轻量化的ftp三种模式
### 使用
1. 将依赖引入到对应的pom.xml中
2. 在yml文件中配置好信息
```yml
file:
store:
minio:
endpoint: endpoint
bucket: bucket
access-key: access-key
secret-key: secret-key@2023
aliyun:
endpoint: endpoint
#AccessId 和 AccessKey
access-key-id: access-key-id
secret-access-key: secret-access-key
#创建的Bucket
bucket: bucket
ftp:
address: address
port: port
username: username
password: password
encoding: UTF-8
# 静态资源路径
asset: asset
# 公共文件资源
pubfiles: pubfiles
# 需要保密的文件资源
prifiles: prifiles
```
## common-redis
使redis使用FastJson序列化,对RedisTemplate进行进一步的函数封装