1
0

fix: 修复缓存调用错误

This commit is contained in:
2025-10-15 15:14:10 +08:00
parent 8c4e3baacb
commit 42b402d4ef

View File

@@ -41,7 +41,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
this.dailyRepository = dailyRepository; this.dailyRepository = dailyRepository;
} }
@Cacheable(value = "long-cache", sync = true) @Cacheable(value = "findFinanceIndicator", cacheManager = "long-cache", sync = true)
public Optional<FinanceIndicator> findFinanceIndicator(Long stockId, Integer year) { public Optional<FinanceIndicator> findFinanceIndicator(Long stockId, Integer year) {
return financeIndicatorRepository.findOne( return financeIndicatorRepository.findOne(
QFinanceIndicator.financeIndicator.year.eq(year) QFinanceIndicator.financeIndicator.year.eq(year)
@@ -49,7 +49,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
); );
} }
@Cacheable(value = "long-cache", sync = true) @Cacheable(value = "findFinanceIndicatorRecent", cacheManager = "long-cache", sync = true)
public List<FinanceIndicator> findFinanceIndicatorRecent(Long stockId, int years) { public List<FinanceIndicator> findFinanceIndicatorRecent(Long stockId, int years) {
var current = LocalDate.now(); var current = LocalDate.now();
return financeIndicatorRepository.findAll( return financeIndicatorRepository.findAll(
@@ -59,7 +59,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
); );
} }
@Cacheable(value = "long-cache", sync = true) @Cacheable(value = "findDailyRecent", cacheManager = "long-cache", sync = true)
public List<Daily> findDailyRecent(Long stockId, int days) { public List<Daily> findDailyRecent(Long stockId, int days) {
var current = LocalDate.now(); var current = LocalDate.now();
return dailyRepository.findAll( return dailyRepository.findAll(
@@ -69,12 +69,12 @@ public class StockService extends SimpleServiceSupport<Stock> {
); );
} }
@Cacheable(value = "long-cache", sync = true) @Cacheable(value = "findDailyLatest", cacheManager = "long-cache", sync = true)
public Optional<Daily> findDailyLatest(Long stockId) { public Optional<Daily> findDailyLatest(Long stockId) {
return dailyRepository.findLatest(stockId); return dailyRepository.findLatest(stockId);
} }
@Cacheable(value = "long-cache", sync = true) @Cacheable(value = "findYearlyRecent", cacheManager = "long-cache", sync = true)
public List<Yearly> findYearlyRecent(Long stockId, int years) { public List<Yearly> findYearlyRecent(Long stockId, int years) {
var current = LocalDate.now().withMonth(1).withDayOfMonth(1); var current = LocalDate.now().withMonth(1).withDayOfMonth(1);
var start = current.minusYears(years).getYear(); var start = current.minusYears(years).getYear();
@@ -112,7 +112,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
.toList(); .toList();
} }
@Cacheable(value = "long-cache", sync = true) @Cacheable(value = "findMonthlyRecent", cacheManager = "long-cache", sync = true)
public List<Monthly> findMonthlyRecent(Long stockId, int months) { public List<Monthly> findMonthlyRecent(Long stockId, int months) {
var end = LocalDate.now().withDayOfMonth(1); var end = LocalDate.now().withDayOfMonth(1);
var start = end.minusMonths(months); var start = end.minusMonths(months);
@@ -162,7 +162,7 @@ public class StockService extends SimpleServiceSupport<Stock> {
.toList(); .toList();
} }
@Cacheable(value = "long-cache", sync = true) @Cacheable(value = "findWeeklyRecent", cacheManager = "long-cache", sync = true)
public List<Weekly> findWeeklyRecent(Long stockId, int weeks) { public List<Weekly> findWeeklyRecent(Long stockId, int weeks) {
var end = LocalDate.now().with(ChronoField.DAY_OF_WEEK, 1); var end = LocalDate.now().with(ChronoField.DAY_OF_WEEK, 1);
var start = end.minusWeeks(weeks); var start = end.minusWeeks(weeks);