修复同步无法刷新缓存的问题

This commit is contained in:
lulz1 2024-03-13 21:59:52 +08:00
parent cba5af2478
commit 41a87ab348
1 changed files with 10 additions and 6 deletions

View File

@ -2,7 +2,6 @@ package com.chint.infrastructure.repository;
import com.chint.application.dtos.OrderDetailQueryParam;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.infrastructure.cache.RouteCacheService;
@ -53,8 +52,14 @@ public class OrderDetailRepositoryImpl implements OrderDetailRepository {
@Override
public OrderDetail save(OrderDetail orderDetail) {
routeCacheService.invalidateRouteCache(orderDetail.getRouteId());
return orderDetailRepository.save(orderDetail);
if (orderDetail.getRouteId() != null) {
routeCacheService.invalidateRouteCache(orderDetail.getRouteId());
}
OrderDetail detail = orderDetailRepository.save(orderDetail);
if (detail.getRouteId() != null) {
routeCacheService.invalidateRouteCache(orderDetail.getRouteId());
}
return detail;
}
@Override
@ -63,9 +68,8 @@ public class OrderDetailRepositoryImpl implements OrderDetailRepository {
}
@Override
public List<OrderDetail> findByUpdateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd){
return orderDetailRepository.findByCreateTimeBetween(createTimeStart,createTimeEnd);
public List<OrderDetail> findByUpdateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd) {
return orderDetailRepository.findByCreateTimeBetween(createTimeStart, createTimeEnd);
}
}