From 4627d2c2546ef368ae0bb4467793aaa0c3a8acde Mon Sep 17 00:00:00 2001 From: hy001 Date: Thu, 21 May 2026 10:57:41 +0800 Subject: [PATCH] fix: disable country dashboard queries by config --- .../adapter/app/user/DatavRestController.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java index 22bc97e4..f3529427 100644 --- a/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java +++ b/rc-service/rc-service-console/console-adapter/src/main/java/com/red/circle/console/adapter/app/user/DatavRestController.java @@ -16,10 +16,12 @@ import com.red.circle.other.inner.model.cmd.user.OnlineCountQryCmd; import com.red.circle.other.inner.model.dto.user.ActiveUserCountryCodeDTO; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -40,6 +42,9 @@ public class DatavRestController extends BaseController { private final CountryDashboardService countryDashboardService; private final CountryDashboardDailyMetricService countryDashboardDailyMetricService; private final CountryDashboardGameMetricService countryDashboardGameMetricService; + + @Value("${red-circle.country-dashboard.query-enabled:true}") + private boolean countryDashboardQueryEnabled; @GetMapping("/active/user-country-code") public List latestActiveUserCountryCode() { @@ -58,30 +63,45 @@ public class DatavRestController extends BaseController { @GetMapping("/country-dashboard") public CountryDashboardCO countryDashboard(CountryDashboardQryCmd cmd) { + if (!countryDashboardQueryEnabled) { + return emptyCountryDashboard(cmd); + } return countryDashboardService.query(cmd); } @GetMapping("/country-dashboard/recharge-details") public PageResult countryDashboardRechargeDetails( CountryDashboardRechargeDetailQryCmd cmd) { + if (!countryDashboardQueryEnabled) { + return PageResult.newPageResult(0); + } return countryDashboardService.pageRechargeDetails(cmd); } @GetMapping("/country-dashboard/game-metrics") public PageResult countryDashboardGameMetrics( CountryDashboardGameMetricQryCmd cmd) { + if (!countryDashboardQueryEnabled) { + return PageResult.newPageResult(0); + } return countryDashboardGameMetricService.pageGameMetrics(cmd); } @GetMapping("/country-dashboard/game-metrics/games") public PageResult countryDashboardGameMetricGames( CountryDashboardGameMetricQryCmd cmd) { + if (!countryDashboardQueryEnabled) { + return PageResult.newPageResult(0); + } return countryDashboardGameMetricService.pageGameSummaries(cmd); } @GetMapping("/country-dashboard/game-metrics/country-rank") public List countryDashboardGameMetricCountryRanks( CountryDashboardGameMetricQryCmd cmd) { + if (!countryDashboardQueryEnabled) { + return Collections.emptyList(); + } return countryDashboardGameMetricService.listGameCountryRanks(cmd); } @@ -91,6 +111,9 @@ public class DatavRestController extends BaseController { @RequestParam String endDate, @RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin, @RequestParam(value = "statTimezones", required = false) String statTimezones) { + if (!countryDashboardQueryEnabled) { + return disabledCountryDashboardBackfill(startDate, endDate, sysOrigin); + } LocalDate parsedStartDate = LocalDate.parse(startDate); LocalDate parsedEndDate = LocalDate.parse(endDate); List refreshedTimezones = countryDashboardDailyMetricService.refreshRange( @@ -109,6 +132,9 @@ public class DatavRestController extends BaseController { @RequestParam String endDate, @RequestParam(value = "sysOrigin", defaultValue = "LIKEI") String sysOrigin, @RequestParam(value = "statTimezones", required = false) String statTimezones) { + if (!countryDashboardQueryEnabled) { + return disabledCountryDashboardBackfill(startDate, endDate, sysOrigin); + } LocalDate parsedStartDate = LocalDate.parse(startDate); LocalDate parsedEndDate = LocalDate.parse(endDate); List refreshedTimezones = countryDashboardGameMetricService.refreshRange( @@ -121,4 +147,23 @@ public class DatavRestController extends BaseController { "statTimezones", refreshedTimezones); } + private CountryDashboardCO emptyCountryDashboard(CountryDashboardQryCmd cmd) { + return new CountryDashboardCO() + .setPeriodType(cmd.getPeriodType()) + .setStartDate(cmd.getStartDate()) + .setEndDate(cmd.getEndDate()) + .setStatTimezone(cmd.getStatTimezone()) + .setTotal(new com.red.circle.console.app.dto.clientobject.datav.CountryDashboardMetricCO()) + .setRecords(Collections.emptyList()); + } + + private Map disabledCountryDashboardBackfill(String startDate, String endDate, + String sysOrigin) { + return Map.of( + "status", "disabled", + "startDate", startDate, + "endDate", endDate, + "sysOrigin", sysOrigin); + } + }