@@ -12,8 +12,8 @@ import org.springframework.web.client.RestClient;
|
||||
public class AppConfig {
|
||||
|
||||
@Bean
|
||||
public RestClient restClient() {
|
||||
return RestClient.create();
|
||||
public RestClient.Builder restClientBuilder() {
|
||||
return RestClient.builder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@@ -5,14 +5,6 @@ import dev.mars3142.fhq.timezone_service.timezone.domain.entities.response.Ipify
|
||||
import dev.mars3142.fhq.timezone_service.timezone.domain.entities.response.TimeApiTimezoneZoneResponse;
|
||||
import dev.mars3142.fhq.timezone_service.timezone.domain.entities.response.WorldTimeApiIpResponse;
|
||||
import dev.mars3142.fhq.timezone_service.timezone.service.TimeZoneService;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import lombok.val;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -20,13 +12,24 @@ import org.springframework.http.HttpStatusCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class TimeZoneServiceImpl implements TimeZoneService {
|
||||
|
||||
private final RestClient restClient;
|
||||
|
||||
public TimeZoneServiceImpl(RestClient.Builder restClientBuilder) {
|
||||
restClient = restClientBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExternalIp(String ip) {
|
||||
var result = ip;
|
||||
|
@@ -36,7 +36,7 @@ public class TimeZoneController {
|
||||
}
|
||||
|
||||
@GetMapping("{area}/{location}")
|
||||
public TimeZoneResponse getTimeZone(@PathVariable String area, @PathVariable String location) {
|
||||
public TimeZoneResponse getTimeZoneForLocation(@PathVariable String area, @PathVariable String location) {
|
||||
val timezone = area + "/" + location;
|
||||
val timezoneInfo = timeZoneService.getTimeZoneInfo(timezone);
|
||||
val abbreviation = Objects.requireNonNullElse(timezoneInfo.dstInterval(), new TimeApiTimezoneZoneResponse.Interval(null)).dstName();
|
||||
|
Reference in New Issue
Block a user