From 7537f862e96bfbdcdc6f7ce44a9f406feba19948 Mon Sep 17 00:00:00 2001 From: yuhalog Date: Thu, 19 Jun 2025 09:53:12 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20python=20ai=20api=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EC=A3=BC=EC=86=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 4 +-- .../external/PythonAiPosterGenerator.java | 31 +++++++++++++++++-- .../src/main/resources/application.yml | 4 +++ .../member/src/main/resources/application.yml | 3 -- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/smarketing-java/ai-recommend/src/main/resources/application.yml b/smarketing-java/ai-recommend/src/main/resources/application.yml index 16fd541..3b84c68 100644 --- a/smarketing-java/ai-recommend/src/main/resources/application.yml +++ b/smarketing-java/ai-recommend/src/main/resources/application.yml @@ -26,10 +26,10 @@ spring: external: store-service: - base-url: ${STORE_SERVICE_URL:http://localhost:8082} + base-url: ${STORE_SERVICE_URL:http://smarketing.20.249.184.228.nip.io} timeout: ${STORE_SERVICE_TIMEOUT:5000} python-ai-service: - base-url: ${PYTHON_AI_SERVICE_URL:http://localhost:5001} + base-url: ${PYTHON_AI_SERVICE_URL:http://20.249.113.247:5001} api-key: ${PYTHON_AI_API_KEY:dummy-key} timeout: ${PYTHON_AI_TIMEOUT:30000} diff --git a/smarketing-java/marketing-content/src/main/java/com/won/smarketing/content/infrastructure/external/PythonAiPosterGenerator.java b/smarketing-java/marketing-content/src/main/java/com/won/smarketing/content/infrastructure/external/PythonAiPosterGenerator.java index 1220a5e..9227d85 100644 --- a/smarketing-java/marketing-content/src/main/java/com/won/smarketing/content/infrastructure/external/PythonAiPosterGenerator.java +++ b/smarketing-java/marketing-content/src/main/java/com/won/smarketing/content/infrastructure/external/PythonAiPosterGenerator.java @@ -1,5 +1,7 @@ package com.won.smarketing.content.infrastructure.external; +import com.won.smarketing.content.domain.model.store.MenuData; +import com.won.smarketing.content.domain.model.store.StoreData; import com.won.smarketing.content.domain.model.store.StoreWithMenuData; import com.won.smarketing.content.domain.service.AiPosterGenerator; // 도메인 인터페이스 import import com.won.smarketing.content.presentation.dto.PosterContentCreateRequest; @@ -12,7 +14,9 @@ import org.springframework.web.reactive.function.client.WebClient; import java.time.Duration; import java.time.format.DateTimeFormatter; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * Claude AI를 활용한 포스터 생성 구현체 @@ -47,12 +51,12 @@ public class PythonAiPosterGenerator implements AiPosterGenerator { // Python AI 서비스 호출 Map response = webClient .post() - .uri("http://localhost:5001" + "/api/ai/poster") + .uri(aiServiceBaseUrl + "/api/ai/poster") .header("Content-Type", "application/json") .bodyValue(requestBody) .retrieve() .bodyToMono(Map.class) - .timeout(Duration.ofSeconds(90)) // 포스터 생성은 시간이 오래 걸릴 수 있음 + .timeout(Duration.ofSeconds(90)) .block(); // 응답에서 content(이미지 URL) 추출 @@ -79,6 +83,29 @@ public class PythonAiPosterGenerator implements AiPosterGenerator { private Map buildRequestBody(PosterContentCreateRequest request, StoreWithMenuData storeWithMenuData) { Map requestBody = new HashMap<>(); +// TODO : 매장 정보 호출 후 request + +// StoreData storeData = storeWithMenuData.getStoreData(); +// List menuDataList = storeWithMenuData.getMenuDataList(); +// +// List> menuList = menuDataList.stream() +// .map(menu -> { +// Map menuMap = new HashMap<>(); +// menuMap.put("menu_id", menu.getMenuId()); +// menuMap.put("menu_name", menu.getMenuName()); +// menuMap.put("category", menu.getCategory()); +// menuMap.put("price", menu.getPrice()); +// menuMap.put("description", menu.getDescription()); +// return menuMap; +// }) +// .collect(Collectors.toList()); +// +// requestBody.put("store_name", storeData.getStoreName()); +// requestBody.put("business_type", storeData.getBusinessType()); +// requestBody.put("location", storeData.getLocation()); +// requestBody.put("seat_count", storeData.getSeatCount()); +// requestBody.put("menu_list", menuList); + // 기본 정보 requestBody.put("title", request.getTitle()); requestBody.put("category", request.getCategory()); diff --git a/smarketing-java/marketing-content/src/main/resources/application.yml b/smarketing-java/marketing-content/src/main/resources/application.yml index 64a7bac..bab1983 100644 --- a/smarketing-java/marketing-content/src/main/resources/application.yml +++ b/smarketing-java/marketing-content/src/main/resources/application.yml @@ -37,6 +37,10 @@ logging: external: ai-service: base-url: ${AI_SERVICE_BASE_URL:http://20.249.113.247:5001} + store-service: + base-url: ${STORE_SERVICE_URL:http://smarketing.20.249.184.228.nip.io} + timeout: ${STORE_SERVICE_TIMEOUT:5000} + azure: storage: account-name: ${AZURE_STORAGE_ACCOUNT_NAME:stdigitalgarage02} diff --git a/smarketing-java/member/src/main/resources/application.yml b/smarketing-java/member/src/main/resources/application.yml index 6812fc3..912bca3 100644 --- a/smarketing-java/member/src/main/resources/application.yml +++ b/smarketing-java/member/src/main/resources/application.yml @@ -54,8 +54,5 @@ info: name: ${APP_NAME:smarketing-member} version: "1.0.0-MVP" description: "AI 마케팅 서비스 MVP - member" -<<<<<<< HEAD -======= allowed-origins: ${ALLOWED_ORIGINS:http://localhost:3000} ->>>>>>> 2c1833ebe1d6be0746597e960dc5217605b2f867