mirror of https://gitee.com/stylefeng/roses
【8.1.9】【log】完善业务日志的查询条件,增加http方式、ip、用户、时间段范围查询
parent
0bd9ee250a
commit
b5b0052aae
|
@ -149,9 +149,36 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
|
|||
private LambdaQueryWrapper<SysLogBusiness> createWrapper(SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
LambdaQueryWrapper<SysLogBusiness> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 根据日志类型编码查询
|
||||
// 1. 根据日志类型编码查询
|
||||
String logTypeCode = sysLogBusinessRequest.getLogTypeCode();
|
||||
queryWrapper.eq(ObjectUtil.isNotEmpty(logTypeCode), SysLogBusiness::getLogTypeCode, logTypeCode);
|
||||
if (StrUtil.isNotBlank(logTypeCode)) {
|
||||
queryWrapper.eq(SysLogBusiness::getLogTypeCode, logTypeCode);
|
||||
}
|
||||
|
||||
// 2. 根据HTTP方法查询
|
||||
String httpMethod = sysLogBusinessRequest.getHttpMethod();
|
||||
if (StrUtil.isNotBlank(httpMethod)) {
|
||||
queryWrapper.eq(SysLogBusiness::getHttpMethod, httpMethod);
|
||||
}
|
||||
|
||||
// 3. 根据客户端IP检索
|
||||
String clientIp = sysLogBusinessRequest.getClientIp();
|
||||
if (StrUtil.isNotBlank(clientIp)) {
|
||||
queryWrapper.likeRight(SysLogBusiness::getClientIp, clientIp);
|
||||
}
|
||||
|
||||
// 4. 根据操作用户检索
|
||||
Long userId = sysLogBusinessRequest.getUserId();
|
||||
if (ObjectUtil.isNotEmpty(userId)) {
|
||||
queryWrapper.eq(SysLogBusiness::getUserId, userId);
|
||||
}
|
||||
|
||||
// 5. 根据日志的时间段进行检索
|
||||
String searchBeginTime = sysLogBusinessRequest.getSearchBeginTime();
|
||||
String searchEndTime = sysLogBusinessRequest.getSearchEndTime();
|
||||
if (StrUtil.isNotBlank(searchBeginTime) && StrUtil.isNotBlank(searchEndTime)) {
|
||||
queryWrapper.between(SysLogBusiness::getCreateTime, searchBeginTime, searchEndTime);
|
||||
}
|
||||
|
||||
// 填充搜索名称和排序
|
||||
this.buildCommonWrapper(sysLogBusinessRequest, queryWrapper);
|
||||
|
@ -174,7 +201,7 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
|
|||
});
|
||||
}
|
||||
|
||||
// 根据请求参数的顺序排列
|
||||
// 根据请求参数的顺序排列,或者根据创建时间倒序排列
|
||||
if (ObjectUtil.isNotEmpty(sysLogBusinessRequest.getOrderBy()) && ObjectUtil.isNotEmpty(sysLogBusinessRequest.getSortBy())) {
|
||||
queryWrapper.last(sysLogBusinessRequest.getOrderByLastSql());
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue