|
@@ -59,14 +59,14 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
if (StringUtils.isNotEmpty(dto.getStartTime()) && StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
|
queryWrapper.apply("DATE_FORMAT(create_time, '%Y-%m') BETWEEN '" + dto.getStartTime() + "' AND '" + dto.getEndTime() + "'");
|
|
|
} else {
|
|
|
- //默认查询当月所有日志
|
|
|
+ //默认查询前30天数据
|
|
|
LocalDate today = LocalDate.now();
|
|
|
- LocalDate firstDayOfMonth = today.withDayOfMonth(1);
|
|
|
- LocalDate lastDayOfMonth = today.withDayOfMonth(today.lengthOfMonth()).plusDays(1);//加一天
|
|
|
+ LocalDate thirtyDaysAgo = today.minusDays(30);
|
|
|
+ LocalDate localDate = today.plusDays(1);
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- String firstDayOfMonthStr = firstDayOfMonth.format(formatter);
|
|
|
- String lastDayOfMonthStr = lastDayOfMonth.format(formatter);
|
|
|
- queryWrapper.between(LogHistoryInfo::getCreateTime, firstDayOfMonthStr, lastDayOfMonthStr);
|
|
|
+ String todayStr = localDate.format(formatter);
|
|
|
+ String thirtyDaysAgoStr = thirtyDaysAgo.format(formatter);
|
|
|
+ queryWrapper.between(LogHistoryInfo::getCreateTime, thirtyDaysAgoStr, todayStr);
|
|
|
}
|
|
|
queryWrapper.orderByDesc(true, LogHistoryInfo::getCreateTime);
|
|
|
List<LogHistoryInfo> logHistoryInfos = baseMapper.selectList(queryWrapper);
|