【8.0.3】【system】更新日志的按字段排序

pull/60/head
fengshuonan 2023-11-14 15:08:02 +08:00
parent 670afcacfd
commit 48cb4eebf3
3 changed files with 36 additions and 19 deletions

View File

@ -196,8 +196,12 @@ public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLo
queryWrapper.ge(StrUtil.isNotBlank(sysLoginLogRequest.getBeginTime()), SysLoginLog::getCreateTime, beginDate); queryWrapper.ge(StrUtil.isNotBlank(sysLoginLogRequest.getBeginTime()), SysLoginLog::getCreateTime, beginDate);
queryWrapper.le(StrUtil.isNotBlank(sysLoginLogRequest.getEndTime()), SysLoginLog::getCreateTime, endDate); queryWrapper.le(StrUtil.isNotBlank(sysLoginLogRequest.getEndTime()), SysLoginLog::getCreateTime, endDate);
// 根据创建时间降序排列 // 根据请求参数的顺序排列
queryWrapper.orderByDesc(SysLoginLog::getCreateTime); if (ObjectUtil.isNotEmpty(sysLoginLogRequest.getOrderBy()) && ObjectUtil.isNotEmpty(sysLoginLogRequest.getSortBy())) {
queryWrapper.last(sysLoginLogRequest.getOrderByLastSql());
} else {
queryWrapper.orderByDesc(SysLoginLog::getCreateTime);
}
return queryWrapper; return queryWrapper;
} }

View File

@ -122,8 +122,12 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
private LambdaQueryWrapper<SysLog> createWrapper(LogManagerRequest logManagerRequest) { private LambdaQueryWrapper<SysLog> createWrapper(LogManagerRequest logManagerRequest) {
LambdaQueryWrapper<SysLog> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysLog> queryWrapper = new LambdaQueryWrapper<>();
// 根据时间倒序排序 // 根据请求参数的顺序排列
queryWrapper.orderByDesc(SysLog::getCreateTime); if (ObjectUtil.isNotEmpty(logManagerRequest.getOrderBy()) && ObjectUtil.isNotEmpty(logManagerRequest.getSortBy())) {
queryWrapper.last(logManagerRequest.getOrderByLastSql());
} else {
queryWrapper.orderByDesc(SysLog::getCreateTime);
}
if (ObjectUtil.isEmpty(logManagerRequest)) { if (ObjectUtil.isEmpty(logManagerRequest)) {
return queryWrapper; return queryWrapper;

View File

@ -31,7 +31,8 @@ import java.util.List;
* @date 2023/07/21 19:02 * @date 2023/07/21 19:02
*/ */
@Service @Service
public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper, SysLogBusiness> implements SysLogBusinessService, BizLogServiceApi { public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper, SysLogBusiness> implements SysLogBusinessService,
BizLogServiceApi {
@Resource @Resource
private SysLogBusinessContentService sysLogBusinessContentService; private SysLogBusinessContentService sysLogBusinessContentService;
@ -118,16 +119,8 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
queryWrapper.in(SysLogBusiness::getLogTypeCode, logTypeCodeList); queryWrapper.in(SysLogBusiness::getLogTypeCode, logTypeCodeList);
} }
// 根据文本检索内容查询 // 填充搜索名称和排序
String searchText = sysLogBusinessRequest.getSearchText(); this.buildCommonWrapper(sysLogBusinessRequest, queryWrapper);
if (ObjectUtil.isNotEmpty(searchText)) {
queryWrapper.nested(wrap -> {
wrap.like(SysLogBusiness::getLogTitle, searchText).or().like(SysLogBusiness::getRequestUrl, searchText);
});
}
// 根据创建时间倒序排列
queryWrapper.orderByDesc(SysLogBusiness::getCreateTime);
Page<SysLogBusiness> sysRolePage = this.page(PageFactory.defaultPage(), queryWrapper); Page<SysLogBusiness> sysRolePage = this.page(PageFactory.defaultPage(), queryWrapper);
return PageResultFactory.createPageResult(sysRolePage); return PageResultFactory.createPageResult(sysRolePage);
@ -160,6 +153,19 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
String logTypeCode = sysLogBusinessRequest.getLogTypeCode(); String logTypeCode = sysLogBusinessRequest.getLogTypeCode();
queryWrapper.eq(ObjectUtil.isNotEmpty(logTypeCode), SysLogBusiness::getLogTypeCode, logTypeCode); queryWrapper.eq(ObjectUtil.isNotEmpty(logTypeCode), SysLogBusiness::getLogTypeCode, logTypeCode);
// 填充搜索名称和排序
this.buildCommonWrapper(sysLogBusinessRequest, queryWrapper);
return queryWrapper;
}
/**
*
*
* @author fengshuonan
* @since 2023/11/13 18:41
*/
private void buildCommonWrapper(SysLogBusinessRequest sysLogBusinessRequest, LambdaQueryWrapper<SysLogBusiness> queryWrapper) {
// 根据文本检索内容查询 // 根据文本检索内容查询
String searchText = sysLogBusinessRequest.getSearchText(); String searchText = sysLogBusinessRequest.getSearchText();
if (ObjectUtil.isNotEmpty(searchText)) { if (ObjectUtil.isNotEmpty(searchText)) {
@ -168,9 +174,12 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
}); });
} }
// 根据创建时间倒序排列 // 根据请求参数的顺序排列
queryWrapper.orderByDesc(SysLogBusiness::getCreateTime); if (ObjectUtil.isNotEmpty(sysLogBusinessRequest.getOrderBy()) && ObjectUtil.isNotEmpty(sysLogBusinessRequest.getSortBy())) {
queryWrapper.last(sysLogBusinessRequest.getOrderByLastSql());
return queryWrapper; } else {
queryWrapper.orderByDesc(SysLogBusiness::getCreateTime);
}
} }
} }