This commit is contained in:
@@ -34,4 +34,6 @@ public class DocViewerRequest {
|
||||
@JsonProperty("action")
|
||||
private String action;
|
||||
|
||||
@JsonProperty("locale")
|
||||
private String locale;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class DockViewFileHandler implements RequestHandler {
|
||||
|
||||
DockViewStatsResponse openLastHistory = dockViewService.getOpenLastHistory(docViewerRequest.getPage(),
|
||||
docViewerRequest.getSize(), docViewerRequest.getSortDirection(), docViewerRequest.getSortBy(),
|
||||
fileIds);
|
||||
fileIds, docViewerRequest.getLocale());
|
||||
|
||||
return new BaseResponse(request.getMsgId(),
|
||||
MessageCode.SUCCESS.getCode(),
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user