mirror of
https://github.com/won-ktds/smarketing-backend.git
synced 2026-06-12 20:39:09 +00:00
Merge branch 'main' into marketing-contents
This commit is contained in:
+117
-137
@@ -104,13 +104,12 @@ public class MarketingTipService implements MarketingTipUseCase {
|
||||
log.debug("AI 팁 생성 완료: {}", aiGeneratedTip.substring(0, Math.min(50, aiGeneratedTip.length())));
|
||||
|
||||
String tipSummary = generateTipSummary(aiGeneratedTip);
|
||||
log.info("tipSummary : {}", tipSummary);
|
||||
|
||||
// 도메인 객체 생성 및 저장
|
||||
MarketingTip marketingTip = MarketingTip.builder()
|
||||
.storeId(storeWithMenuData.getStoreData().getStoreId())
|
||||
.tipContent(aiGeneratedTip)
|
||||
.tipSummary(tipSummary)
|
||||
.tipContent(aiGeneratedTip)
|
||||
.storeWithMenuData(storeWithMenuData)
|
||||
.createdAt(LocalDateTime.now())
|
||||
.build();
|
||||
@@ -142,113 +141,80 @@ public class MarketingTipService implements MarketingTipUseCase {
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 마케팅 팁 요약 생성 (핵심 마케팅 팁 섹션에서 첫 번째 문장 추출)
|
||||
*
|
||||
* @param fullContent AI로 생성된 전체 마케팅 팁 HTML 콘텐츠
|
||||
* @return 핵심 마케팅 팁의 첫 번째 문장
|
||||
*/
|
||||
private String generateTipSummary(String fullContent) {
|
||||
if (fullContent == null || fullContent.trim().isEmpty()) {
|
||||
return "마케팅 팁이 생성되었습니다.";
|
||||
}
|
||||
|
||||
try {
|
||||
// JSON 형식 처리: "```html\n..." 패턴
|
||||
String processedContent = preprocessContent(fullContent);
|
||||
// 1. "✨ 핵심 마케팅 팁" 섹션 추출
|
||||
String coreSection = extractCoreMarketingTipSection(fullContent);
|
||||
|
||||
// 1순위: HTML 블록 밖의 첫 번째 제목 추출
|
||||
String titleOutsideHtml = extractTitleOutsideHtml(processedContent);
|
||||
if (titleOutsideHtml != null && titleOutsideHtml.length() > 5) {
|
||||
return titleOutsideHtml;
|
||||
if (coreSection != null && !coreSection.trim().isEmpty()) {
|
||||
// 2. HTML 태그 제거
|
||||
String cleanText = removeHtmlTags(coreSection);
|
||||
|
||||
// 3. 첫 번째 의미있는 문장 추출
|
||||
String summary = extractFirstMeaningfulSentence(cleanText);
|
||||
|
||||
// 4. 길이 제한 (100자 이내)
|
||||
if (summary.length() > 100) {
|
||||
summary = summary.substring(0, 97) + "...";
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
// 2순위: <b> 태그 안의 첫 번째 내용 추출
|
||||
String boldContent = extractBoldContent(processedContent);
|
||||
if (boldContent != null && boldContent.length() > 5) {
|
||||
return boldContent;
|
||||
}
|
||||
|
||||
// 3순위: HTML 태그 제거 후 첫 번째 문장
|
||||
return extractFirstSentence(processedContent);
|
||||
// 핵심 팁 섹션을 찾지 못한 경우 fallback 처리
|
||||
return extractFallbackSummary(fullContent);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("마케팅 팁 요약 생성 중 오류", e);
|
||||
return "마케팅 팁이 생성되었습니다.";
|
||||
log.warn("마케팅 팁 요약 생성 중 오류 발생, 기본 메시지 반환: {}", e.getMessage());
|
||||
return "맞춤형 마케팅 팁이 생성되었습니다.";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON이나 특수 형식 전처리
|
||||
* "✨ 핵심 마케팅 팁" 섹션 추출
|
||||
*/
|
||||
private String preprocessContent(String content) {
|
||||
// 먼저 JSON 이스케이프 문자 정리
|
||||
if (content.contains("\\n")) {
|
||||
content = content.replaceAll("\\\\n", "\n");
|
||||
}
|
||||
private String extractCoreMarketingTipSection(String fullContent) {
|
||||
// 핵심 마케팅 팁 섹션 시작 패턴들
|
||||
String[] corePatterns = {
|
||||
"✨ 핵심 마케팅 팁",
|
||||
"<h3>✨ 핵심 마케팅 팁</h3>",
|
||||
"핵심 마케팅 팁"
|
||||
};
|
||||
|
||||
// JSON 구조에서 실제 HTML 내용만 추출
|
||||
if (content.contains("```html")) {
|
||||
content = content.replaceAll("```html", "")
|
||||
.replaceAll("```", "")
|
||||
.replaceAll("\"", "");
|
||||
}
|
||||
// 다음 섹션 시작 패턴들
|
||||
String[] nextSectionPatterns = {
|
||||
"🚀 실행 방법",
|
||||
"<h3>🚀 실행 방법</h3>",
|
||||
"💰 예상 비용",
|
||||
"<h3>💰 예상 비용"
|
||||
};
|
||||
|
||||
return content.trim();
|
||||
}
|
||||
for (String pattern : corePatterns) {
|
||||
int startIndex = fullContent.indexOf(pattern);
|
||||
if (startIndex != -1) {
|
||||
// 패턴 뒤부터 시작
|
||||
int contentStart = startIndex + pattern.length();
|
||||
|
||||
/**
|
||||
* HTML 블록 밖의 첫 번째 제목 라인 추출
|
||||
* ```html 이후 첫 번째 줄의 내용만 추출
|
||||
*/
|
||||
private String extractTitleOutsideHtml(String content) {
|
||||
// 먼저 이스케이프 문자 정리
|
||||
String processedContent = content.replaceAll("\\\\n", "\n");
|
||||
|
||||
// ```html 패턴 찾기 (이스케이프 처리 후)
|
||||
String[] htmlPatterns = {"```html\n", "```html\\n"};
|
||||
|
||||
for (String pattern : htmlPatterns) {
|
||||
int htmlStart = processedContent.indexOf(pattern);
|
||||
if (htmlStart != -1) {
|
||||
// 패턴 이후부터 시작
|
||||
int contentStart = htmlStart + pattern.length();
|
||||
|
||||
// 첫 번째 줄바꿈까지 또는 \n\n까지 찾기
|
||||
String remaining = processedContent.substring(contentStart);
|
||||
String[] lines = remaining.split("\n");
|
||||
|
||||
if (lines.length > 0) {
|
||||
String firstLine = lines[0].trim();
|
||||
|
||||
// 유효한 내용인지 확인
|
||||
if (firstLine.length() > 5 && !firstLine.contains("🎯") && !firstLine.contains("<")) {
|
||||
return cleanText(firstLine);
|
||||
// 다음 섹션까지의 내용 추출
|
||||
int endIndex = fullContent.length();
|
||||
for (String nextPattern : nextSectionPatterns) {
|
||||
int nextIndex = fullContent.indexOf(nextPattern, contentStart);
|
||||
if (nextIndex != -1 && nextIndex < endIndex) {
|
||||
endIndex = nextIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 기존 방식으로 fallback
|
||||
return extractFromLines(processedContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 줄별로 처리하는 기존 방식
|
||||
*/
|
||||
private String extractFromLines(String content) {
|
||||
String[] lines = content.split("\n");
|
||||
|
||||
for (String line : lines) {
|
||||
line = line.trim();
|
||||
|
||||
// 빈 줄이나 HTML 태그, 이모지로 시작하는 줄 건너뛰기
|
||||
if (line.isEmpty() ||
|
||||
line.contains("<") ||
|
||||
line.startsWith("🎯") ||
|
||||
line.startsWith("🔍") ||
|
||||
line.equals("```html") ||
|
||||
line.matches("^[\\p{So}\\p{Sk}\\s]+$")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 의미있는 제목 라인 발견
|
||||
if (line.length() > 5) {
|
||||
return cleanText(line);
|
||||
return fullContent.substring(contentStart, endIndex).trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,73 +222,87 @@ public class MarketingTipService implements MarketingTipUseCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* <b> 태그 안의 첫 번째 내용 추출
|
||||
* HTML 태그 제거
|
||||
*/
|
||||
private String extractBoldContent(String htmlContent) {
|
||||
int startIndex = htmlContent.indexOf("<b>");
|
||||
if (startIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
private String removeHtmlTags(String htmlText) {
|
||||
if (htmlText == null) return "";
|
||||
|
||||
int endIndex = htmlContent.indexOf("</b>", startIndex);
|
||||
if (endIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String content = htmlContent.substring(startIndex + 3, endIndex).trim();
|
||||
return cleanText(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 텍스트 정리
|
||||
*/
|
||||
private String cleanText(String text) {
|
||||
if (text == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return text.replaceAll(" ", " ")
|
||||
.replaceAll("\\s+", " ")
|
||||
return htmlText
|
||||
.replaceAll("<[^>]+>", "") // HTML 태그 제거
|
||||
.replaceAll(" ", " ") // HTML 엔티티 처리
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("\\s+", " ") // 연속된 공백을 하나로
|
||||
.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML 태그 제거 후 첫 번째 의미있는 문장 추출
|
||||
* 첫 번째 의미있는 문장 추출
|
||||
*/
|
||||
private String extractFirstSentence(String htmlContent) {
|
||||
// HTML 태그 모두 제거
|
||||
String cleanContent = htmlContent.replaceAll("<[^>]+>", "").trim();
|
||||
private String extractFirstMeaningfulSentence(String cleanText) {
|
||||
if (cleanText == null || cleanText.trim().isEmpty()) {
|
||||
return "마케팅 팁이 생성되었습니다.";
|
||||
}
|
||||
|
||||
// 줄별로 나누어서 첫 번째 의미있는 줄 찾기
|
||||
String[] lines = cleanContent.split("\\n");
|
||||
// 문장 분할 (마침표, 느낌표, 물음표 기준)
|
||||
String[] sentences = cleanText.split("[.!?]");
|
||||
|
||||
for (String line : lines) {
|
||||
line = line.trim();
|
||||
for (String sentence : sentences) {
|
||||
String trimmed = sentence.trim();
|
||||
|
||||
// 빈 줄이나 이모지만 있는 줄 건너뛰기
|
||||
if (line.isEmpty() || line.matches("^[\\p{So}\\p{Sk}\\s]+$")) {
|
||||
continue;
|
||||
}
|
||||
// 의미있는 문장인지 확인 (10자 이상, 특수문자만으로 구성되지 않음)
|
||||
if (trimmed.length() >= 10 &&
|
||||
!trimmed.matches("^[\\s\\p{Punct}]*$") && // 공백과 구두점만으로 구성되지 않음
|
||||
!isOnlyEmojisOrSymbols(trimmed)) { // 이모지나 기호만으로 구성되지 않음
|
||||
|
||||
// 최소 길이 체크하고 반환
|
||||
if (line.length() > 5) {
|
||||
// 50자 제한
|
||||
if (line.length() > 50) {
|
||||
return line.substring(0, 50).trim() + "...";
|
||||
// 문장 끝에 마침표 추가 (없는 경우)
|
||||
if (!trimmed.endsWith(".") && !trimmed.endsWith("!") && !trimmed.endsWith("?")) {
|
||||
trimmed += ".";
|
||||
}
|
||||
return line;
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
|
||||
// 모든 방법이 실패하면 기존 방식 사용
|
||||
String[] sentences = cleanContent.split("[.!?]");
|
||||
String firstSentence = sentences.length > 0 ? sentences[0].trim() : cleanContent;
|
||||
|
||||
if (firstSentence.length() > 50) {
|
||||
firstSentence = firstSentence.substring(0, 50).trim() + "...";
|
||||
// 의미있는 문장을 찾지 못한 경우 원본의 처음 50자 반환
|
||||
if (cleanText.length() > 50) {
|
||||
return cleanText.substring(0, 47) + "...";
|
||||
}
|
||||
|
||||
return firstSentence.isEmpty() ? "마케팅 팁이 생성되었습니다." : firstSentence;
|
||||
return cleanText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 이모지나 기호만으로 구성되었는지 확인
|
||||
*/
|
||||
private boolean isOnlyEmojisOrSymbols(String text) {
|
||||
// 한글, 영문, 숫자가 포함되어 있으면 의미있는 텍스트로 판단
|
||||
return !text.matches(".*[\\p{L}\\p{N}].*");
|
||||
}
|
||||
|
||||
/**
|
||||
* 핵심 팁 섹션을 찾지 못한 경우 대체 요약 생성
|
||||
*/
|
||||
private String extractFallbackSummary(String fullContent) {
|
||||
// HTML 태그 제거 후 첫 번째 의미있는 문장 찾기
|
||||
String cleanContent = removeHtmlTags(fullContent);
|
||||
|
||||
// 첫 번째 문단에서 의미있는 문장 추출
|
||||
String[] paragraphs = cleanContent.split("\\n\\n");
|
||||
|
||||
for (String paragraph : paragraphs) {
|
||||
String trimmed = paragraph.trim();
|
||||
if (trimmed.length() >= 20) { // 충분히 긴 문단
|
||||
String summary = extractFirstMeaningfulSentence(trimmed);
|
||||
if (summary.length() >= 10) {
|
||||
return summary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 모든 방법이 실패한 경우 기본 메시지
|
||||
return "개인화된 마케팅 팁이 생성되었습니다.";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,10 +43,18 @@ management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info,metrics
|
||||
include: health,info
|
||||
base-path: /actuator
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
info:
|
||||
enabled: true
|
||||
health:
|
||||
livenessState:
|
||||
enabled: true
|
||||
readinessState:
|
||||
enabled: true
|
||||
|
||||
logging:
|
||||
level:
|
||||
@@ -55,4 +63,11 @@ logging:
|
||||
jwt:
|
||||
secret: ${JWT_SECRET:mySecretKeyForJWTTokenGenerationAndValidation123456789}
|
||||
access-token-validity: ${JWT_ACCESS_VALIDITY:3600000}
|
||||
refresh-token-validity: ${JWT_REFRESH_VALIDITY:604800000}
|
||||
refresh-token-validity: ${JWT_REFRESH_VALIDITY:604800000}
|
||||
|
||||
|
||||
info:
|
||||
app:
|
||||
name: ${APP_NAME:smarketing-recommend}
|
||||
version: "1.0.0-MVP"
|
||||
description: "AI 마케팅 서비스 MVP - recommend"
|
||||
@@ -35,6 +35,7 @@ subprojects {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
|
||||
implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
|
||||
implementation 'io.jsonwebtoken:jjwt-impl:0.12.3'
|
||||
@@ -51,6 +52,7 @@ subprojects {
|
||||
implementation 'com.azure:azure-messaging-eventhubs:5.18.0'
|
||||
implementation 'com.azure:azure-messaging-eventhubs-checkpointstore-blob:1.19.0'
|
||||
implementation 'com.azure:azure-identity:1.11.4'
|
||||
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@ public class SecurityConfig {
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers("/api/auth/**", "/api/member/register", "/api/member/check-duplicate/**",
|
||||
"/api/member/validate-password", "/swagger-ui/**", "/v3/api-docs/**",
|
||||
"/swagger-resources/**", "/webjars/**").permitAll()
|
||||
"/api/member/validate-password", "/swagger-ui/**", "/v3/api-docs/**",
|
||||
"/swagger-resources/**", "/webjars/**", "/actuator/**", "/health/**", "/error").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
)
|
||||
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
|
||||
+27
-3
@@ -41,6 +41,23 @@ podTemplate(
|
||||
echo "Image Tag: ${imageTag}"
|
||||
}
|
||||
|
||||
stage("Check Changes") {
|
||||
script {
|
||||
def changes = sh(
|
||||
script: "git diff --name-only HEAD~1 HEAD",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
|
||||
if (!changes.contains("smarketing-java/")) {
|
||||
echo "No changes in smarketing-java, skipping build"
|
||||
currentBuild.result = 'SUCCESS'
|
||||
error("Stopping pipeline - no changes detected")
|
||||
}
|
||||
|
||||
echo "Changes detected in smarketing-java, proceeding with build"
|
||||
}
|
||||
}
|
||||
|
||||
stage("Setup AKS") {
|
||||
container('azure-cli') {
|
||||
withCredentials([azureServicePrincipal('azure-credentials')]) {
|
||||
@@ -49,8 +66,8 @@ podTemplate(
|
||||
az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID
|
||||
az account set --subscription 2513dd36-7978-48e3-9a7c-b221d4874f66
|
||||
|
||||
echo "=== AKS 인증정보 가져오기 ==="
|
||||
az aks get-credentials --resource-group rg-digitalgarage-01 --name aks-digitalgarage-01 --overwrite-existing
|
||||
echo "=== AKS 인증정보 가져오기 (rg-digitalgarage-02) ==="
|
||||
az aks get-credentials --resource-group rg-digitalgarage-02 --name aks-digitalgarage-02 --overwrite-existing
|
||||
|
||||
echo "=== 네임스페이스 생성 ==="
|
||||
kubectl create namespace ${namespace} --dry-run=client -o yaml | kubectl apply -f -
|
||||
@@ -66,6 +83,9 @@ podTemplate(
|
||||
echo "=== 클러스터 상태 확인 ==="
|
||||
kubectl get nodes
|
||||
kubectl get ns ${namespace}
|
||||
|
||||
echo "=== 현재 연결된 클러스터 확인 ==="
|
||||
kubectl config current-context
|
||||
"""
|
||||
}
|
||||
}
|
||||
@@ -99,7 +119,7 @@ podTemplate(
|
||||
timeout 30 sh -c 'until docker info; do sleep 1; done'
|
||||
"""
|
||||
|
||||
// 🔧 ACR Credential을 Jenkins에서 직접 사용
|
||||
// ACR Credential을 Jenkins에서 직접 사용
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: 'acr-credentials',
|
||||
usernameVariable: 'ACR_USERNAME',
|
||||
@@ -184,6 +204,10 @@ podTemplate(
|
||||
|
||||
container('azure-cli') {
|
||||
sh """
|
||||
echo "=== 현재 연결된 클러스터 재확인 ==="
|
||||
kubectl config current-context
|
||||
kubectl cluster-info | head -3
|
||||
|
||||
echo "=== PostgreSQL 서비스 확인 ==="
|
||||
kubectl get svc -n ${namespace} | grep postgresql || echo "PostgreSQL 서비스가 없습니다. 먼저 설치해주세요."
|
||||
|
||||
|
||||
@@ -8,6 +8,16 @@ data:
|
||||
ALLOWED_ORIGINS: ${allowed_origins}
|
||||
JPA_DDL_AUTO: update
|
||||
JPA_SHOW_SQL: 'true'
|
||||
# 🔧 강화된 Actuator 설정
|
||||
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: '*'
|
||||
MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS: always
|
||||
MANAGEMENT_ENDPOINT_HEALTH_ENABLED: 'true'
|
||||
MANAGEMENT_ENDPOINTS_WEB_BASE_PATH: /actuator
|
||||
MANAGEMENT_SERVER_PORT: '8080'
|
||||
# Spring Security 비활성화 (Actuator용)
|
||||
SPRING_AUTOCONFIGURE_EXCLUDE: org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
|
||||
# 또는 Management port를 main port와 동일하게
|
||||
MANAGEMENT_SERVER_PORT: ''
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
@@ -167,18 +177,29 @@ spec:
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 10
|
||||
# 🔧 개선된 Health Check 설정
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8081
|
||||
initialDelaySeconds: 60
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 120 # 2분으로 증가
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
path: /actuator/health/readiness
|
||||
port: 8081
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 5
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 60 # 1분으로 증가
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
@@ -236,14 +257,24 @@ spec:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8082
|
||||
initialDelaySeconds: 60
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
path: /actuator/health/readiness
|
||||
port: 8082
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 5
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
@@ -301,14 +332,24 @@ spec:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8083
|
||||
initialDelaySeconds: 60
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
path: /actuator/health/readiness
|
||||
port: 8083
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 5
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
@@ -366,14 +407,24 @@ spec:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
port: 8084
|
||||
initialDelaySeconds: 60
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /actuator/health
|
||||
path: /actuator/health/readiness
|
||||
port: 8084
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 5
|
||||
httpHeaders:
|
||||
- name: Accept
|
||||
value: application/json
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
|
||||
---
|
||||
# Services
|
||||
|
||||
+10
-20
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -32,25 +33,20 @@ public class PosterContentService implements PosterContentUseCase {
|
||||
|
||||
/**
|
||||
* 포스터 콘텐츠 생성
|
||||
*
|
||||
*
|
||||
* @param request 포스터 콘텐츠 생성 요청
|
||||
* @return 생성된 포스터 콘텐츠 정보
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public PosterContentCreateResponse generatePosterContent(PosterContentCreateRequest request) {
|
||||
// AI를 사용하여 포스터 생성
|
||||
|
||||
String generatedPoster = aiPosterGenerator.generatePoster(request);
|
||||
|
||||
// 다양한 사이즈의 포스터 생성
|
||||
Map<String, String> posterSizes = aiPosterGenerator.generatePosterSizes(generatedPoster);
|
||||
|
||||
// 생성 조건 정보 구성
|
||||
CreationConditions conditions = CreationConditions.builder()
|
||||
.category(request.getCategory())
|
||||
.requirement(request.getRequirement())
|
||||
// .toneAndManner(request.getToneAndManner())
|
||||
// .emotionIntensity(request.getEmotionIntensity())
|
||||
.eventName(request.getEventName())
|
||||
.startDate(request.getStartDate())
|
||||
.endDate(request.getEndDate())
|
||||
@@ -62,47 +58,41 @@ public class PosterContentService implements PosterContentUseCase {
|
||||
.contentType(ContentType.POSTER.name())
|
||||
.title(request.getTitle())
|
||||
.posterImage(generatedPoster)
|
||||
.posterSizes(posterSizes)
|
||||
.posterSizes(new HashMap<>()) // 빈 맵 반환 (사이즈 변환 안함)
|
||||
.status(ContentStatus.DRAFT.name())
|
||||
//.createdAt(LocalDateTime.now())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 포스터 콘텐츠 저장
|
||||
*
|
||||
*
|
||||
* @param request 포스터 콘텐츠 저장 요청
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void savePosterContent(PosterContentSaveRequest request) {
|
||||
// 생성 조건 정보 구성
|
||||
// 생성 조건 구성
|
||||
CreationConditions conditions = CreationConditions.builder()
|
||||
.category(request.getCategory())
|
||||
.requirement(request.getRequirement())
|
||||
// .toneAndManner(request.getToneAndManner())
|
||||
// .emotionIntensity(request.getEmotionIntensity())
|
||||
.eventName(request.getEventName())
|
||||
.startDate(request.getStartDate())
|
||||
.endDate(request.getEndDate())
|
||||
.photoStyle(request.getPhotoStyle())
|
||||
.build();
|
||||
|
||||
// 콘텐츠 엔티티 생성 및 저장
|
||||
// 콘텐츠 엔티티 생성
|
||||
Content content = Content.builder()
|
||||
.contentType(ContentType.POSTER)
|
||||
.platform(Platform.GENERAL) // 포스터는 범용
|
||||
.title(request.getTitle())
|
||||
.content(null) // 포스터는 이미지가 주 콘텐츠
|
||||
.hashtags(null)
|
||||
.content(request.getContent())
|
||||
.images(request.getImages())
|
||||
.status(ContentStatus.PUBLISHED)
|
||||
.creationConditions(conditions)
|
||||
.storeId(request.getStoreId())
|
||||
.createdAt(LocalDateTime.now())
|
||||
.updatedAt(LocalDateTime.now())
|
||||
.build();
|
||||
|
||||
// 저장
|
||||
contentRepository.save(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
-86
@@ -1,86 +0,0 @@
|
||||
// marketing-content/src/main/java/com/won/smarketing/content/infrastructure/external/ClaudeAiPosterGenerator.java
|
||||
package com.won.smarketing.content.infrastructure.external;
|
||||
|
||||
import com.won.smarketing.content.domain.service.AiPosterGenerator; // 도메인 인터페이스 import
|
||||
import com.won.smarketing.content.presentation.dto.PosterContentCreateRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Claude AI를 활용한 포스터 생성 구현체
|
||||
* Clean Architecture의 Infrastructure Layer에 위치
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ClaudeAiPosterGenerator implements AiPosterGenerator {
|
||||
|
||||
/**
|
||||
* 포스터 생성
|
||||
*
|
||||
* @param request 포스터 생성 요청
|
||||
* @return 생성된 포스터 이미지 URL
|
||||
*/
|
||||
@Override
|
||||
public String generatePoster(PosterContentCreateRequest request) {
|
||||
try {
|
||||
// Claude AI API 호출 로직
|
||||
String prompt = buildPosterPrompt(request);
|
||||
|
||||
// TODO: 실제 Claude AI API 호출
|
||||
// 현재는 더미 데이터 반환
|
||||
return generateDummyPosterUrl(request.getTitle());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("AI 포스터 생성 실패: {}", e.getMessage(), e);
|
||||
return generateFallbackPosterUrl();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 다양한 사이즈의 포스터 생성
|
||||
*
|
||||
* @param baseImage 기본 이미지
|
||||
* @return 사이즈별 포스터 URL 맵
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> generatePosterSizes(String baseImage) {
|
||||
Map<String, String> sizes = new HashMap<>();
|
||||
|
||||
// 다양한 사이즈 생성 (더미 구현)
|
||||
sizes.put("instagram_square", baseImage + "_1080x1080.jpg");
|
||||
sizes.put("instagram_story", baseImage + "_1080x1920.jpg");
|
||||
sizes.put("facebook_post", baseImage + "_1200x630.jpg");
|
||||
sizes.put("a4_poster", baseImage + "_2480x3508.jpg");
|
||||
|
||||
return sizes;
|
||||
}
|
||||
|
||||
private String buildPosterPrompt(PosterContentCreateRequest request) {
|
||||
StringBuilder prompt = new StringBuilder();
|
||||
prompt.append("포스터 제목: ").append(request.getTitle()).append("\n");
|
||||
prompt.append("카테고리: ").append(request.getCategory()).append("\n");
|
||||
|
||||
if (request.getRequirement() != null) {
|
||||
prompt.append("요구사항: ").append(request.getRequirement()).append("\n");
|
||||
}
|
||||
|
||||
if (request.getToneAndManner() != null) {
|
||||
prompt.append("톤앤매너: ").append(request.getToneAndManner()).append("\n");
|
||||
}
|
||||
|
||||
return prompt.toString();
|
||||
}
|
||||
|
||||
private String generateDummyPosterUrl(String title) {
|
||||
return "https://dummy-ai-service.com/posters/" + title.hashCode() + ".jpg";
|
||||
}
|
||||
|
||||
private String generateFallbackPosterUrl() {
|
||||
return "https://dummy-ai-service.com/posters/fallback.jpg";
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.won.smarketing.content.infrastructure.external;
|
||||
|
||||
import com.won.smarketing.content.domain.service.AiPosterGenerator; // 도메인 인터페이스 import
|
||||
import com.won.smarketing.content.presentation.dto.PosterContentCreateRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Claude AI를 활용한 포스터 생성 구현체
|
||||
* Clean Architecture의 Infrastructure Layer에 위치
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class PythonAiPosterGenerator implements AiPosterGenerator {
|
||||
|
||||
private final WebClient webClient;
|
||||
|
||||
@Value("${external.ai-service.base-url}")
|
||||
private String aiServiceBaseUrl;
|
||||
|
||||
/**
|
||||
* 포스터 생성 - Python AI 서비스 호출
|
||||
*
|
||||
* @param request 포스터 생성 요청
|
||||
* @return 생성된 포스터 이미지 URL
|
||||
*/
|
||||
@Override
|
||||
public String generatePoster(PosterContentCreateRequest request) {
|
||||
try {
|
||||
log.info("Python AI 포스터 서비스 호출: {}/api/ai/poster", aiServiceBaseUrl);
|
||||
|
||||
// 요청 데이터 구성
|
||||
Map<String, Object> requestBody = buildRequestBody(request);
|
||||
|
||||
log.debug("포스터 생성 요청 데이터: {}", requestBody);
|
||||
|
||||
// Python AI 서비스 호출
|
||||
Map<String, Object> response = webClient
|
||||
.post()
|
||||
.uri(aiServiceBaseUrl + "/api/ai/poster")
|
||||
.header("Content-Type", "application/json")
|
||||
.bodyValue(requestBody)
|
||||
.retrieve()
|
||||
.bodyToMono(Map.class)
|
||||
.timeout(Duration.ofSeconds(60)) // 포스터 생성은 시간이 오래 걸릴 수 있음
|
||||
.block();
|
||||
|
||||
// 응답에서 content(이미지 URL) 추출
|
||||
if (response != null && response.containsKey("content")) {
|
||||
String imageUrl = (String) response.get("content");
|
||||
log.info("AI 포스터 생성 성공: imageUrl={}", imageUrl);
|
||||
return imageUrl;
|
||||
} else {
|
||||
log.warn("AI 포스터 생성 응답에 content가 없음: {}", response);
|
||||
return generateFallbackPosterUrl(request.getTitle());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("AI 포스터 생성 실패: {}", e.getMessage(), e);
|
||||
return generateFallbackPosterUrl(request.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 다양한 사이즈의 포스터 생성 (사용하지 않음)
|
||||
* 1개의 이미지만 생성하므로 빈 맵 반환
|
||||
*
|
||||
* @param baseImage 기본 이미지 URL
|
||||
* @return 빈 맵
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> generatePosterSizes(String baseImage) {
|
||||
log.info("포스터 사이즈 변환 기능은 사용하지 않음: baseImage={}", baseImage);
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Python AI 서비스 요청 데이터 구성
|
||||
* Python 서비스의 PosterContentGetRequest 모델에 맞춤
|
||||
*/
|
||||
private Map<String, Object> buildRequestBody(PosterContentCreateRequest request) {
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
|
||||
// 기본 정보
|
||||
requestBody.put("title", request.getTitle());
|
||||
requestBody.put("category", request.getCategory());
|
||||
requestBody.put("contentType", request.getContentType());
|
||||
|
||||
// 이미지 정보
|
||||
if (request.getImages() != null && !request.getImages().isEmpty()) {
|
||||
requestBody.put("images", request.getImages());
|
||||
}
|
||||
|
||||
// 스타일 정보
|
||||
if (request.getPhotoStyle() != null) {
|
||||
requestBody.put("photoStyle", request.getPhotoStyle());
|
||||
}
|
||||
|
||||
// 요구사항
|
||||
if (request.getRequirement() != null) {
|
||||
requestBody.put("requirement", request.getRequirement());
|
||||
}
|
||||
|
||||
// 톤앤매너
|
||||
if (request.getToneAndManner() != null) {
|
||||
requestBody.put("toneAndManner", request.getToneAndManner());
|
||||
}
|
||||
|
||||
// 감정 강도
|
||||
if (request.getEmotionIntensity() != null) {
|
||||
requestBody.put("emotionIntensity", request.getEmotionIntensity());
|
||||
}
|
||||
|
||||
// 메뉴명
|
||||
if (request.getMenuName() != null) {
|
||||
requestBody.put("menuName", request.getMenuName());
|
||||
}
|
||||
|
||||
// 이벤트 정보
|
||||
if (request.getEventName() != null) {
|
||||
requestBody.put("eventName", request.getEventName());
|
||||
}
|
||||
|
||||
// 날짜 정보 (LocalDate를 String으로 변환)
|
||||
if (request.getStartDate() != null) {
|
||||
requestBody.put("startDate", request.getStartDate().format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
}
|
||||
|
||||
if (request.getEndDate() != null) {
|
||||
requestBody.put("endDate", request.getEndDate().format(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
}
|
||||
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 폴백 포스터 URL 생성
|
||||
*/
|
||||
private String generateFallbackPosterUrl(String title) {
|
||||
// 기본 포스터 템플릿 URL 반환
|
||||
return "https://stdigitalgarage02.blob.core.windows.net/ai-content/fallback-poster.jpg";
|
||||
}
|
||||
}
|
||||
@@ -37,3 +37,26 @@ logging:
|
||||
external:
|
||||
ai-service:
|
||||
base-url: ${AI_SERVICE_BASE_URL:http://20.249.139.88:5001}
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
base-path: /actuator
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
info:
|
||||
enabled: true
|
||||
health:
|
||||
livenessState:
|
||||
enabled: true
|
||||
readinessState:
|
||||
enabled: true
|
||||
|
||||
info:
|
||||
app:
|
||||
name: ${APP_NAME:smarketing-content}
|
||||
version: "1.0.0-MVP"
|
||||
description: "AI 마케팅 서비스 MVP - content"
|
||||
@@ -31,3 +31,26 @@ jwt:
|
||||
logging:
|
||||
level:
|
||||
com.won.smarketing: ${LOG_LEVEL:DEBUG}
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
base-path: /actuator
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
info:
|
||||
enabled: true
|
||||
health:
|
||||
livenessState:
|
||||
enabled: true
|
||||
readinessState:
|
||||
enabled: true
|
||||
|
||||
info:
|
||||
app:
|
||||
name: ${APP_NAME:smarketing-member}
|
||||
version: "1.0.0-MVP"
|
||||
description: "AI 마케팅 서비스 MVP - member"
|
||||
-1
@@ -8,7 +8,6 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 메뉴 수정 요청 DTO
|
||||
|
||||
+1
-1
@@ -11,7 +11,6 @@ import com.won.smarketing.store.repository.MenuRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -117,6 +116,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
.menuId(menu.getMenuId())
|
||||
.menuName(menu.getMenuName())
|
||||
.category(menu.getCategory())
|
||||
.image(menu.getImage())
|
||||
.price(menu.getPrice())
|
||||
.description(menu.getDescription())
|
||||
.createdAt(menu.getCreatedAt())
|
||||
|
||||
@@ -46,3 +46,26 @@ azure:
|
||||
menu-images: ${AZURE_STORAGE_MENU_CONTAINER:smarketing-menu-images}
|
||||
store-images: ${AZURE_STORAGE_STORE_CONTAINER:smarketing-store-images}
|
||||
max-file-size: ${AZURE_STORAGE_MAX_FILE_SIZE:10485760} # 10MB
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
base-path: /actuator
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
info:
|
||||
enabled: true
|
||||
health:
|
||||
livenessState:
|
||||
enabled: true
|
||||
readinessState:
|
||||
enabled: true
|
||||
|
||||
info:
|
||||
app:
|
||||
name: ${APP_NAME:smarketing-content}
|
||||
version: "1.0.0-MVP"
|
||||
description: "AI 마케팅 서비스 MVP - content"
|
||||
Reference in New Issue
Block a user