Просмотр исходного кода

fix: 日统计查询 startDate/endDate 为 null 时 NPE

MyBatis-Plus eq/ge/le 的参数在传参前即求值,format(null) 抛 NPE。
改为三元表达式在 null 时跳过 format。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 1 день назад
Родитель
Сommit
491399da13

+ 2 - 2
car-wash-service/src/main/java/com/kym/service/impl/DailyStatServiceImpl.java

@@ -56,9 +56,9 @@ public class DailyStatServiceImpl extends MyBaseServiceImpl<DailyStatMapper, Dai
                 .eq(CommUtil.isNotEmptyAndNull(params.getStationId()),
                         DailyStat::getStationId, params.getStationId())
                 .ge(params.getStartDate() != null,
-                        DailyStat::getStatDate, params.getStartDate().format(DateTimeFormatter.ISO_LOCAL_DATE))
+                        DailyStat::getStatDate, params.getStartDate() != null ? params.getStartDate().format(DateTimeFormatter.ISO_LOCAL_DATE) : null)
                 .le(params.getEndDate() != null,
-                        DailyStat::getStatDate, params.getEndDate().format(DateTimeFormatter.ISO_LOCAL_DATE))
+                        DailyStat::getStatDate, params.getEndDate() != null ? params.getEndDate().format(DateTimeFormatter.ISO_LOCAL_DATE) : null)
                 .orderByDesc(DailyStat::getStatDate);
 
         var page = PageHelper.startPage(params.getPageNum(), params.getPageSize());