dev add field locale for get info for view doc
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-05-14 12:44:19 +07:00
parent 48cdca56a2
commit 5dc3bb7157
4 changed files with 10 additions and 8 deletions
@@ -119,7 +119,7 @@ public class DockViewService {
}
public DockViewStatsResponse getOpenLastHistory(int page, int size, String sortDirection, String sortBy,
List<String> fileIds) {
List<String> fileIds, String locale) {
if (sortDirection == null || sortDirection.isEmpty()) {
sortDirection = "desc";
}
@@ -148,8 +148,8 @@ public class DockViewService {
List<DockViewResponse> history = new ArrayList<>();
for (DockView dockView: dockViews) {
String country = geoCountryService.getCountryByIp(dockView.getViewerIp());
String city = geoCountryService.getCityByIp(dockView.getViewerIp());
String country = geoCountryService.getCountryByIp(dockView.getViewerIp(), locale);
String city = geoCountryService.getCityByIp(dockView.getViewerIp(), locale);
LocalDateTime createdAt = dockView.getCreatedAt();
String fileId = dockView.getFileId();
@@ -92,12 +92,12 @@ public class GeoCountryService {
}
}
public String getCityByIp(String ip) {
public String getCityByIp(String ip, String locale) {
try {
InetAddress ipAddress = InetAddress.getByName(ip);
CityResponse response = cityDbReader.city(ipAddress);
return response.getCity().getNames().getOrDefault("ru",
return response.getCity().getNames().getOrDefault(locale,
response.getCity().getName());
} catch (Exception e) {
log.error("Failed to get city for IP: {}", ip, e);
@@ -105,12 +105,12 @@ public class GeoCountryService {
}
}
public String getCountryByIp(String ip) {
public String getCountryByIp(String ip, String locale) {
try {
InetAddress ipAddress = InetAddress.getByName(ip);
CountryResponse response = countryDbReader.country(ipAddress);
return response.getCountry().getNames().getOrDefault("ru",
return response.getCountry().getNames().getOrDefault(locale,
response.getCountry().getName());
} catch (Exception e) {
log.error("Failed to get country for IP: {}", ip, e);