diff --git a/tgBotService/src/main/java/weatherproject/tgbotservice/clients/UserServiceClient.java b/tgBotService/src/main/java/weatherproject/tgbotservice/clients/UserServiceClient.java index fb8569e..e8c7b88 100644 --- a/tgBotService/src/main/java/weatherproject/tgbotservice/clients/UserServiceClient.java +++ b/tgBotService/src/main/java/weatherproject/tgbotservice/clients/UserServiceClient.java @@ -2,7 +2,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClientException; @@ -22,9 +21,9 @@ public class UserServiceClient { private final String baseUrl; @Autowired - public UserServiceClient(RestTemplate restTemplate, @Value("${user-service.base-url}") String baseUrl) { + public UserServiceClient(RestTemplate restTemplate) { this.restTemplate = restTemplate; - this.baseUrl = baseUrl; + this.baseUrl = "http://localhost:8080/users"; } public List getAllUsers() { diff --git a/tgBotService/src/main/java/weatherproject/tgbotservice/clients/WeatherServiceClient.java b/tgBotService/src/main/java/weatherproject/tgbotservice/clients/WeatherServiceClient.java index 93ecf62..a4ea770 100644 --- a/tgBotService/src/main/java/weatherproject/tgbotservice/clients/WeatherServiceClient.java +++ b/tgBotService/src/main/java/weatherproject/tgbotservice/clients/WeatherServiceClient.java @@ -1,25 +1,23 @@ package weatherproject.tgbotservice.clients; +import lombok.Getter; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import weatherproject.tgbotservice.dto.WeatherDTO; @Service +@RequiredArgsConstructor @Slf4j public class WeatherServiceClient { private final RestTemplate restTemplate; - private final String baseUrl; - - @Autowired - public WeatherServiceClient(RestTemplate restTemplate, @Value("${weather-service.base-url}") String baseUrl) { - this.restTemplate = restTemplate; - this.baseUrl = baseUrl; - } + private final GoogleTranslateClient translateClient; + // URL для обращения к Weather API Service + @Getter + private final String baseUrl = "http://localhost:8081/weather"; /** * Получение погоды по названию города. @@ -28,7 +26,7 @@ public WeatherServiceClient(RestTemplate restTemplate, @Value("${weather-service * @return Массив объектов погоды */ public WeatherDTO getWeatherByCity(String city) { - String url = baseUrl + "/city/" + city; + String url = getBaseUrl() + "/city/" + city; try { return restTemplate.getForObject(url, WeatherDTO.class); } catch (RestClientException e) { diff --git a/tgBotService/src/main/resources/application.yml b/tgBotService/src/main/resources/application.yml index 7bbba89..d2a9b9d 100644 --- a/tgBotService/src/main/resources/application.yml +++ b/tgBotService/src/main/resources/application.yml @@ -8,17 +8,11 @@ server: port: 8082 rabbitmq: - host: ${RABBITMQ_HOST} - port: ${RABBITMQ_PORT} - username: ${RABBITMQ_USERNAME} - password: ${RABBITMQ_PASSWORD} + host: localhost + port: 5672 + username: guest + password: guest bot: name: "XyL1GaN4eG_weatherBot" - token: ${TG_BOT_API_KEY} - -user-service: - base-url: ${USER_SERVICE_BASE_URL} - -weather-service: - base-url: ${WEATHER_SERVICE_BASE_URL} \ No newline at end of file + token: ${TG_BOT_API_KEY} \ No newline at end of file diff --git a/userService/src/main/resources/application.yml b/userService/src/main/resources/application.yml index cfb8a27..e0220d2 100644 --- a/userService/src/main/resources/application.yml +++ b/userService/src/main/resources/application.yml @@ -2,9 +2,9 @@ spring: application: name: userService datasource: - url: ${DB_URL} - username: ${DB_USERNAME} - password: ${DB_PASSWORD} + url: jdbc:postgresql://localhost:5432/weatherproject + username: username + password: password hikari: allow-pool-suspension: true # Enable Hikari pool suspension for JVM checkpoint restore jpa: @@ -24,7 +24,7 @@ server: port: 8080 rabbitmq: - host: ${RABBITMQ_HOST} - port: ${RABBITMQ_PORT} - username: ${RABBITMQ_USERNAME} - password: ${RABBITMQ_PASSWORD} \ No newline at end of file + host: localhost + port: 5672 + username: guest + password: guest diff --git a/weatherApiService/src/main/resources/application.yml b/weatherApiService/src/main/resources/application.yml index 5bbf9ee..74e91dc 100644 --- a/weatherApiService/src/main/resources/application.yml +++ b/weatherApiService/src/main/resources/application.yml @@ -2,9 +2,9 @@ spring: application: name: weatherApiService datasource: - url: ${DB_URL} - username: ${DB_USERNAME} - password: ${DB_PASSWORD} + url: jdbc:postgresql://localhost:5432/weatherproject + username: username + password: password hikari: allow-pool-suspension: true # Enable Hikari pool suspension for JVM checkpoint restore jpa: @@ -24,10 +24,11 @@ server: port: 8081 rabbitmq: - host: ${RABBITMQ_HOST} - port: ${RABBITMQ_PORT} - username: ${RABBITMQ_USERNAME} - password: ${RABBITMQ_PASSWORD} + host: localhost + port: 5672 + username: guest + password: guest + weather: api: