Skip to content

Commit 51dc34f

Browse files
authored
Merge pull request #68 from 5-mo/feat/#65-patch-schedule
[FIX] nlp 호출 경로 환경변수로 등록
2 parents 0bbed94 + 562d78d commit 51dc34f

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/dev_deploy.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ jobs:
3838
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
3939
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ohmo:latest
4040
41-
# 네트워크 생성
42-
sudo docker network create oh-mo-backend_app-network || true
43-
4441
# Stop and remove old container
4542
sudo docker stop ohmo || true
4643
sudo docker rm ohmo || true
@@ -49,9 +46,10 @@ jobs:
4946
sudo docker run -d \
5047
--name ohmo \
5148
-p 8080:8080 \
52-
--network oh-mo-backend_app-network \
49+
--network ohmo-network \
5350
-e DATABASE_URL=${{ secrets.DATABASE_URL }} \
5451
-e DATABASE_USERNAME=${{ secrets.DATABASE_USERNAME }} \
5552
-e DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }} \
5653
-e JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} \
54+
-e NLP_API_URL=${{ secrets.NLP_API_URL }} \
5755
${{ secrets.DOCKER_USERNAME }}/ohmo:latest

src/main/java/com/example/ohmobackend/service/scheduleService/ScheduleCommandServiceImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.example.ohmobackend.web.dto.scheduleDto.ScheduleResponseDto;
1616
import com.example.ohmobackend.web.dto.todoDto.TodoResponseDto;
1717
import lombok.RequiredArgsConstructor;
18+
import org.springframework.beans.factory.annotation.Value;
1819
import org.springframework.http.HttpEntity;
1920
import org.springframework.http.HttpHeaders;
2021
import org.springframework.http.MediaType;
@@ -39,11 +40,14 @@
3940
@Transactional
4041
public class ScheduleCommandServiceImpl implements ScheduleCommandService {
4142

43+
@Value("${nlp.api-url}")
44+
private String nlpApiUrl;
4245
final private MemberCategoryRepository memberCategoryRepository;
4346
final private ScheduleRepository scheduleRepository;
4447
final private TodoRepository todoRepository;
4548
final private RoutineRepository routineRepository;
4649

50+
4751
@Override
4852
public List<RoutineResponseDto.RoutineDto> addRoutine(
4953
ScheduleRequestDto.AddRequestDto requestDto,
@@ -275,8 +279,7 @@ private Map<String, Object> callNlpApi(String text) {
275279
headers.setContentType(MediaType.TEXT_PLAIN);
276280
HttpEntity<String> entity = new HttpEntity<>(text, headers);
277281

278-
String apiUrl = "http://localhost:8000/nlp/extract-text";
279-
ResponseEntity<Map> response = restTemplate.postForEntity(apiUrl, entity, Map.class);
282+
ResponseEntity<Map> response = restTemplate.postForEntity(nlpApiUrl + "/nlp/extract-text", entity, Map.class);
280283

281284
if (!response.getStatusCode().is2xxSuccessful() || response.getBody() == null) {
282285
throw new ScheduleHandler(ErrorStatus.NLP_PARSE_FAILED);
@@ -286,4 +289,5 @@ private Map<String, Object> callNlpApi(String text) {
286289
}
287290

288291

292+
289293
}

src/main/resources/application.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ spring:
2222
default_batch_fetch_size: 1000${}
2323

2424
jwt:
25-
secret: ${JWT_SECRET_KEY}
25+
secret: ${JWT_SECRET_KEY}
26+
27+
nlp:
28+
api-url: ${NLP_API_URL:http://localhost:8000}

0 commit comments

Comments
 (0)