Skip to content

Commit

Permalink
Rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
XyL1GaN4eG committed Jul 27, 2024
1 parent eb30095 commit 0d29640
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<UserDTO> getAllUsers() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

/**
* Получение погоды по названию города.
Expand All @@ -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) {
Expand Down
16 changes: 5 additions & 11 deletions tgBotService/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
token: ${TG_BOT_API_KEY}
14 changes: 7 additions & 7 deletions userService/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -24,7 +24,7 @@ server:
port: 8080

rabbitmq:
host: ${RABBITMQ_HOST}
port: ${RABBITMQ_PORT}
username: ${RABBITMQ_USERNAME}
password: ${RABBITMQ_PASSWORD}
host: localhost
port: 5672
username: guest
password: guest
15 changes: 8 additions & 7 deletions weatherApiService/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 0d29640

Please sign in to comment.