Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@ def publish_content(self, request: RequestBlogPublish) -> Dict:
blog_service = self.factory.create_service(request.tag)

# 공통 인터페이스로 포스팅 실행
response_data = blog_service.post_content(
blog_service.post_content(
title=request.post_title,
content=request.post_content,
tags=request.post_tags,
)

# 올바른 응답 데이터를 직접 구성
response_data = {
"tag": request.tag,
"post_title": request.post_title,
"publish_success": True, # 포스팅 성공 가정
}

if not response_data:
raise CustomException(
f"{request.tag} 블로그 포스팅에 실패했습니다.", status_code=500
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package site.icebang.domain.workflow.runner.body;

import java.util.Map;
import java.util.Optional;

import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import lombok.RequiredArgsConstructor;

import site.icebang.domain.workflow.model.Task;

@Component
@RequiredArgsConstructor
public class BlogPublishBodyBuilder implements TaskBodyBuilder {

private final ObjectMapper objectMapper;
private static final String TASK_NAME = "블로그 발행 태스크";
private static final String RAG_SOURCE_TASK = "블로그 RAG 생성 태스크";

@Override
public boolean supports(String taskName) {
return TASK_NAME.equals(taskName);
}

@Override
public ObjectNode build(Task task, Map<String, JsonNode> workflowContext) {
ObjectNode body = objectMapper.createObjectNode();

// RAG에서 생성된 블로그 콘텐츠 가져오기
Optional.ofNullable(workflowContext.get(RAG_SOURCE_TASK))
.ifPresent(
ragResult -> {
JsonNode data = ragResult.path("data");

// 제목, 내용, 태그 설정
Optional.ofNullable(data.path("title"))
.filter(node -> !node.isMissingNode())
.ifPresent(titleNode -> body.set("post_title", titleNode));

Optional.ofNullable(data.path("content"))
.filter(node -> !node.isMissingNode())
.ifPresent(contentNode -> body.set("post_content", contentNode));

Optional.ofNullable(data.path("tags"))
.filter(node -> !node.isMissingNode())
.ifPresent(tagsNode -> body.set("post_tags", tagsNode));
});

body.put("tag", "tistory");
body.put("blog_id", "[email protected]");
body.put("blog_pw", "kdyn2641*");

return body;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package site.icebang.domain.workflow.runner.body;

import java.util.Map;
import java.util.Optional;

import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import lombok.RequiredArgsConstructor;

import site.icebang.domain.workflow.model.Task;

@Component
@RequiredArgsConstructor
public class BlogRagBodyBuilder implements TaskBodyBuilder {

private final ObjectMapper objectMapper;
private static final String TASK_NAME = "블로그 RAG 생성 태스크";
private static final String KEYWORD_SOURCE_TASK = "키워드 검색 태스크";
private static final String CRAWL_SOURCE_TASK = "상품 정보 크롤링 태스크";

@Override
public boolean supports(String taskName) {
return TASK_NAME.equals(taskName);
}

@Override
public ObjectNode build(Task task, Map<String, JsonNode> workflowContext) {
ObjectNode body = objectMapper.createObjectNode();

// 키워드 정보 가져오기
Optional.ofNullable(workflowContext.get(KEYWORD_SOURCE_TASK))
.map(node -> node.path("data").path("keyword"))
.ifPresent(keywordNode -> body.set("keyword", keywordNode));

// 크롤링된 상품 정보 가져오기
Optional.ofNullable(workflowContext.get(CRAWL_SOURCE_TASK))
.map(node -> node.path("data").path("product_detail"))
.ifPresent(productNode -> body.set("product_info", productNode));

// 기본 콘텐츠 설정
body.put("content_type", "review_blog");
body.put("target_length", 1000);

return body;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package site.icebang.domain.workflow.runner.body;

import java.util.Map;
import java.util.Optional;

import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import lombok.RequiredArgsConstructor;

import site.icebang.domain.workflow.model.Task;

@Component
@RequiredArgsConstructor
public class ProductCrawlBodyBuilder implements TaskBodyBuilder {

private final ObjectMapper objectMapper;
private static final String TASK_NAME = "상품 정보 크롤링 태스크";
private static final String SIMILARITY_SOURCE_TASK = "상품 유사도 분석 태스크";

@Override
public boolean supports(String taskName) {
return TASK_NAME.equals(taskName);
}

@Override
public ObjectNode build(Task task, Map<String, JsonNode> workflowContext) {
ObjectNode body = objectMapper.createObjectNode();

// 유사도 분석에서 선택된 상품의 URL 가져오기
Optional.ofNullable(workflowContext.get(SIMILARITY_SOURCE_TASK))
.map(node -> node.path("data").path("selected_product").path("url"))
.filter(urlNode -> !urlNode.isMissingNode() && !urlNode.asText().isEmpty())
.ifPresent(urlNode -> body.set("product_url", urlNode));

return body;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public ObjectNode build(Task task, Map<String, JsonNode> workflowContext) {

// 키워드 정보 가져오기
Optional.ofNullable(workflowContext.get(KEYWORD_SOURCE_TASK))
.map(node -> node.path("keyword"))
.map(node -> node.path("data").path("keyword"))
.ifPresent(keywordNode -> body.set("keyword", keywordNode));

// 상품 검색 결과 정보 가져오기
Optional.ofNullable(workflowContext.get(SEARCH_SOURCE_TASK))
.map(node -> node.path("search_results"))
.map(node -> node.path("data").path("search_results"))
.ifPresent(resultsNode -> body.set("search_results", resultsNode));

return body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public boolean supports(String taskName) {
@Override
public ObjectNode build(Task task, Map<String, JsonNode> workflowContext) {
JsonNode sourceResult = workflowContext.get(SOURCE_TASK_NAME);
String keyword = sourceResult != null ? sourceResult.path("keyword").asText("") : "";
String keyword =
sourceResult != null ? sourceResult.path("data").path("keyword").asText("") : "";
return objectMapper.createObjectNode().put("keyword", keyword);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package site.icebang.domain.workflow.runner.body;

import java.util.Map;
import java.util.Optional;

import org.springframework.stereotype.Component;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import lombok.RequiredArgsConstructor;

import site.icebang.domain.workflow.model.Task;

@Component
@RequiredArgsConstructor
public class ProductSimilarityBodyBuilder implements TaskBodyBuilder {

private final ObjectMapper objectMapper;
private static final String TASK_NAME = "상품 유사도 분석 태스크";
private static final String KEYWORD_SOURCE_TASK = "키워드 검색 태스크";
private static final String MATCH_SOURCE_TASK = "상품 매칭 태스크";
private static final String SEARCH_SOURCE_TASK = "상품 검색 태스크";

@Override
public boolean supports(String taskName) {
return TASK_NAME.equals(taskName);
}

@Override
public ObjectNode build(Task task, Map<String, JsonNode> workflowContext) {
ObjectNode body = objectMapper.createObjectNode();

// 키워드 정보 가져오기
Optional.ofNullable(workflowContext.get(KEYWORD_SOURCE_TASK))
.map(node -> node.path("data").path("keyword"))
.ifPresent(keywordNode -> body.set("keyword", keywordNode));

// 매칭된 상품 정보 가져오기
Optional.ofNullable(workflowContext.get(MATCH_SOURCE_TASK))
.map(node -> node.path("data").path("matched_products"))
.ifPresent(matchedNode -> body.set("matched_products", matchedNode));

// 상품 검색 결과 정보 가져오기
Optional.ofNullable(workflowContext.get(SEARCH_SOURCE_TASK))
.map(node -> node.path("data").path("search_results"))
.ifPresent(resultsNode -> body.set("search_results", resultsNode));

return body;
}
}
2 changes: 1 addition & 1 deletion apps/user-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ management:
# 외부 API 연동을 위한 설정 섹션
api:
fastapi:
url: ${FASTAPI_SERVER_HOST:-http://127.0.0.1:8000}
url: http://${FASTAPI_SERVER_HOST:127.0.0.1:8000}
timeout: 10000 # API 요청 타임아웃 (밀리초 단위)
Loading