Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 2fe63f0

Browse files
thelightway24LEELISEchanbyoung
authored
✨ Feature: #62 코드 통합 (#64)
* ♻️ Refactor: 자연어 검색 로직을 리팩토링 하였습니다.(헥사고날 구조 적용 및 내부 리팩토링), 스위칭 로직을 도입하였습니다. * ✨ Feature: yakplus-batch의 코드 통합 초안 * 🐛 Fix: 변수 선언 안된 문제 수정 * 🐛 Fix: 임포트 문제 수정 * 🐛 Fix: 컴파일 오류 수정 * 📦 Chore: 불필요한 import 삭제 * 📦 Chore: Swagger 의존성 및 설정 추가 * ✨ Feat: 컨트롤러 Swagger 적용 * ♻️ Refactor: 인덱스 이름 상수로 변경 및 매퍼 분리 --------- Co-authored-by: leelise <jaszzzzz@naver.com> Co-authored-by: pcb7893@naver.com <122460524+chanbyoung@users.noreply.github.com>
1 parent 57b5a9a commit 2fe63f0

File tree

79 files changed

+1689
-2111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1689
-2111
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ dependencies {
4949
//ai
5050
implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter:1.0.0-M5'
5151

52+
// Swagger 설치
53+
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0'
54+
5255
// build.gradle
5356
if (project.hasProperty('env') && project.env == 'test') {
5457
dependencies {
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.likelion.backendplus4.yakplus;
22

3-
import com.likelion.backendplus4.yakplus.common.configuration.LogbackConfig;
43
import org.springframework.boot.SpringApplication;
54
import org.springframework.boot.autoconfigure.SpringBootApplication;
65

76
@SpringBootApplication
87
public class YakplusApplication {
9-
public static void main(String[] args) {
10-
LogbackConfig logbackConfig = new LogbackConfig();
11-
logbackConfig.configure();
12-
SpringApplication.run(YakplusApplication.class, args);
13-
}
8+
public static void main(String[] args) {
9+
SpringApplication.run(YakplusApplication.class, args);
10+
}
1411
}
Lines changed: 168 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package com.likelion.backendplus4.yakplus.common.configuration;
22

3+
import java.nio.file.Files;
4+
import java.nio.file.Path;
5+
import java.nio.file.Paths;
6+
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.springframework.beans.factory.annotation.Value;
10+
import org.springframework.context.annotation.Configuration;
11+
312
import ch.qos.logback.classic.Level;
413
import ch.qos.logback.classic.LoggerContext;
514
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
@@ -9,171 +18,171 @@
918
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
1019
import ch.qos.logback.core.util.FileSize;
1120
import jakarta.annotation.PostConstruct;
12-
import org.slf4j.Logger;
13-
import org.slf4j.LoggerFactory;
14-
import org.springframework.context.annotation.Configuration;
15-
16-
import java.nio.file.Files;
17-
import java.nio.file.Path;
18-
import java.nio.file.Paths;
1921

2022
/**
2123
* 로깅 설정을 위한 설정 클래스
22-
*
24+
*
2325
* @modified 2025-04-18
2426
* @since 2025-04-16
2527
*/
2628
@Configuration
2729
public class LogbackConfig {
28-
private static final String LOG_DIRECTORY = "logs";
29-
private static final String LOG_FILE_NAME = "like-lion.log";
30-
private static final String LOG_PATTERN = "%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n";
31-
private static final int MAX_HISTORY = 30;
32-
private static final String TOTAL_SIZE_CAP = "1GB";
33-
34-
/**
35-
* 로깅 설정을 초기화하는 메서드
36-
*
37-
* @author 정안식
38-
* @modified 2025-04-18
39-
* @since 2025-04-16
40-
*/
41-
@PostConstruct
42-
public void configure() {
43-
LoggerContext context = initializeLoggerContext();
44-
createLogDirectory();
45-
46-
ConsoleAppender<ILoggingEvent> consoleAppender = createConsoleAppender(context);
47-
FileAppender<ILoggingEvent> fileAppender = createFileAppender(context);
48-
49-
configureRootLogger(context, consoleAppender, fileAppender);
50-
}
51-
52-
/**
53-
* LoggerContext를 초기화하는 메서드
54-
*
55-
* @return LoggerContext 초기화된 로거 컨텍스트
56-
* @author 정안식
57-
* @modified 2025-04-18
58-
* @since 2025-04-16
59-
*/
60-
private LoggerContext initializeLoggerContext() {
61-
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
62-
context.reset();
63-
return context;
64-
}
65-
66-
/**
67-
* 로그 디렉토리를 생성하는 메서드
68-
*
69-
* @author 정안식
70-
* @modified 2025-04-18
71-
* @since 2025-04-16
72-
*/
73-
private void createLogDirectory() {
74-
Path logPath = Paths.get(LOG_DIRECTORY);
75-
try {
76-
if (!Files.exists(logPath)) {
77-
Files.createDirectories(logPath);
78-
}
79-
} catch (Exception e) {
80-
throw new RuntimeException("로그 디렉토리 생성 실패", e);
81-
}
82-
}
83-
84-
/**
85-
* 콘솔 어펜더를 생성하는 메서드
86-
*
87-
* @param context LoggerContext 로거 컨텍스트
88-
* @return ConsoleAppender 생성된 콘솔 어펜더
89-
* @author 정안식
90-
* @modified 2025-04-18
91-
* @since 2025-04-16
92-
*/
93-
private ConsoleAppender<ILoggingEvent> createConsoleAppender(LoggerContext context) {
94-
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
95-
appender.setContext(context);
96-
appender.setEncoder(createEncoder(context));
97-
appender.start();
98-
return appender;
99-
}
100-
101-
/**
102-
* 파일 어펜더를 생성하는 메서드
103-
*
104-
* @param context LoggerContext 로거 컨텍스트
105-
* @return FileAppender 생성된 파일 어펜더
106-
* @author 정안식
107-
* @modified 2025-04-18
108-
* @since 2025-04-16
109-
*/
110-
private FileAppender<ILoggingEvent> createFileAppender(LoggerContext context) {
111-
FileAppender<ILoggingEvent> appender = new FileAppender<>();
112-
appender.setContext(context);
113-
appender.setFile(LOG_DIRECTORY + "/" + LOG_FILE_NAME);
114-
appender.setAppend(true);
115-
appender.setEncoder(createEncoder(context));
116-
117-
TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = createRollingPolicy(context, appender);
118-
rollingPolicy.start();
119-
120-
appender.start();
121-
return appender;
122-
}
123-
124-
/**
125-
* 패턴 레이아웃 인코더를 생성하는 메서드
126-
*
127-
* @param context LoggerContext 로거 컨텍스트
128-
* @return PatternLayoutEncoder 생성된 패턴 레이아웃 인코더
129-
* @author 정안식
130-
* @modified 2025-04-18
131-
* @since 2025-04-16
132-
*/
133-
private PatternLayoutEncoder createEncoder(LoggerContext context) {
134-
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
135-
encoder.setContext(context);
136-
encoder.setPattern(LOG_PATTERN);
137-
encoder.start();
138-
return encoder;
139-
}
140-
141-
/**
142-
* 롤링 정책을 생성하는 메서드
143-
*
144-
* @param context LoggerContext 로거 컨텍스트
145-
* @param parent FileAppender 부모 파일 어펜더
146-
* @return TimeBasedRollingPolicy 생성된 롤링 정책
147-
* @author 정안식
148-
* @modified 2025-04-18
149-
* @since 2025-04-16
150-
*/
151-
private TimeBasedRollingPolicy<ILoggingEvent> createRollingPolicy(LoggerContext context, FileAppender<ILoggingEvent> parent) {
152-
TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<>();
153-
policy.setContext(context);
154-
policy.setParent(parent);
155-
policy.setFileNamePattern(LOG_DIRECTORY + "/" + LOG_FILE_NAME.replace(".log", ".%d{yyyy-MM-dd}.log"));
156-
policy.setMaxHistory(MAX_HISTORY);
157-
policy.setTotalSizeCap(FileSize.valueOf(TOTAL_SIZE_CAP));
158-
return policy;
159-
}
160-
161-
/**
162-
* 루트 로거를 설정하는 메서드
163-
*
164-
* @param context LoggerContext 로거 컨텍스트
165-
* @param consoleAppender ConsoleAppender 콘솔 어펜더
166-
* @param fileAppender FileAppender 파일 어펜더
167-
* @author 정안식
168-
* @since 2025-04-16
169-
*/
170-
private void configureRootLogger(LoggerContext context, ConsoleAppender<ILoggingEvent> consoleAppender, FileAppender<ILoggingEvent> fileAppender) {
171-
Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
172-
if (logger instanceof ch.qos.logback.classic.Logger) {
173-
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) logger;
174-
rootLogger.setLevel(Level.INFO);
175-
rootLogger.addAppender(consoleAppender);
176-
rootLogger.addAppender(fileAppender);
177-
}
178-
}
30+
@Value("${log.rolling.directory}")
31+
private String LOG_DIRECTORY;
32+
@Value("${log.rolling.file-name}")
33+
private String LOG_FILE_NAME;
34+
@Value("${log.rolling.pattern}")
35+
private String LOG_PATTERN;
36+
@Value("${log.rolling.max-history}")
37+
private int MAX_HISTORY;
38+
@Value("${log.rolling.total-size-cap}")
39+
private String TOTAL_SIZE_CAP;
40+
41+
/**
42+
* 로깅 설정을 초기화하는 메서드
43+
*
44+
* @author 정안식
45+
* @modified 2025-04-18
46+
* @since 2025-04-16
47+
*/
48+
@PostConstruct
49+
public void configure() {
50+
LoggerContext context = initializeLoggerContext();
51+
createLogDirectory();
52+
53+
ConsoleAppender<ILoggingEvent> consoleAppender = createConsoleAppender(context);
54+
FileAppender<ILoggingEvent> fileAppender = createFileAppender(context);
55+
56+
configureRootLogger(context, consoleAppender, fileAppender);
57+
}
58+
59+
/**
60+
* LoggerContext를 초기화하는 메서드
61+
*
62+
* @return LoggerContext 초기화된 로거 컨텍스트
63+
* @author 정안식
64+
* @modified 2025-04-18
65+
* @since 2025-04-16
66+
*/
67+
private LoggerContext initializeLoggerContext() {
68+
LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory();
69+
context.reset();
70+
return context;
71+
}
72+
73+
/**
74+
* 로그 디렉토리를 생성하는 메서드
75+
*
76+
* @author 정안식
77+
* @modified 2025-04-18
78+
* @since 2025-04-16
79+
*/
80+
private void createLogDirectory() {
81+
Path logPath = Paths.get(LOG_DIRECTORY);
82+
try {
83+
if (!Files.exists(logPath)) {
84+
Files.createDirectories(logPath);
85+
}
86+
} catch (Exception e) {
87+
throw new RuntimeException("로그 디렉토리 생성 실패", e);
88+
}
89+
}
90+
91+
/**
92+
* 콘솔 어펜더를 생성하는 메서드
93+
*
94+
* @param context LoggerContext 로거 컨텍스트
95+
* @return ConsoleAppender 생성된 콘솔 어펜더
96+
* @author 정안식
97+
* @modified 2025-04-18
98+
* @since 2025-04-16
99+
*/
100+
private ConsoleAppender<ILoggingEvent> createConsoleAppender(LoggerContext context) {
101+
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
102+
appender.setContext(context);
103+
appender.setEncoder(createEncoder(context));
104+
appender.start();
105+
return appender;
106+
}
107+
108+
/**
109+
* 파일 어펜더를 생성하는 메서드
110+
*
111+
* @param context LoggerContext 로거 컨텍스트
112+
* @return FileAppender 생성된 파일 어펜더
113+
* @author 정안식
114+
* @modified 2025-04-18
115+
* @since 2025-04-16
116+
*/
117+
private FileAppender<ILoggingEvent> createFileAppender(LoggerContext context) {
118+
FileAppender<ILoggingEvent> appender = new FileAppender<>();
119+
appender.setContext(context);
120+
appender.setFile(LOG_DIRECTORY + "/" + LOG_FILE_NAME);
121+
appender.setAppend(true);
122+
appender.setEncoder(createEncoder(context));
123+
124+
TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = createRollingPolicy(context, appender);
125+
rollingPolicy.start();
126+
127+
appender.start();
128+
return appender;
129+
}
130+
131+
/**
132+
* 패턴 레이아웃 인코더를 생성하는 메서드
133+
*
134+
* @param context LoggerContext 로거 컨텍스트
135+
* @return PatternLayoutEncoder 생성된 패턴 레이아웃 인코더
136+
* @author 정안식
137+
* @modified 2025-04-18
138+
* @since 2025-04-16
139+
*/
140+
private PatternLayoutEncoder createEncoder(LoggerContext context) {
141+
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
142+
encoder.setContext(context);
143+
encoder.setPattern(LOG_PATTERN);
144+
encoder.start();
145+
return encoder;
146+
}
147+
148+
/**
149+
* 롤링 정책을 생성하는 메서드
150+
*
151+
* @param context LoggerContext 로거 컨텍스트
152+
* @param parent FileAppender 부모 파일 어펜더
153+
* @return TimeBasedRollingPolicy 생성된 롤링 정책
154+
* @author 정안식
155+
* @modified 2025-04-18
156+
* @since 2025-04-16
157+
*/
158+
private TimeBasedRollingPolicy<ILoggingEvent> createRollingPolicy(LoggerContext context,
159+
FileAppender<ILoggingEvent> parent) {
160+
TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<>();
161+
policy.setContext(context);
162+
policy.setParent(parent);
163+
policy.setFileNamePattern(LOG_DIRECTORY + "/" + LOG_FILE_NAME.replace(".log", ".%d{yyyy-MM-dd}.log"));
164+
policy.setMaxHistory(MAX_HISTORY);
165+
policy.setTotalSizeCap(FileSize.valueOf(TOTAL_SIZE_CAP));
166+
return policy;
167+
}
168+
169+
/**
170+
* 루트 로거를 설정하는 메서드
171+
*
172+
* @param context LoggerContext 로거 컨텍스트
173+
* @param consoleAppender ConsoleAppender 콘솔 어펜더
174+
* @param fileAppender FileAppender 파일 어펜더
175+
* @author 정안식
176+
* @since 2025-04-16
177+
*/
178+
private void configureRootLogger(LoggerContext context, ConsoleAppender<ILoggingEvent> consoleAppender,
179+
FileAppender<ILoggingEvent> fileAppender) {
180+
Logger logger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
181+
if (logger instanceof ch.qos.logback.classic.Logger) {
182+
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger)logger;
183+
rootLogger.setLevel(Level.INFO);
184+
rootLogger.addAppender(consoleAppender);
185+
rootLogger.addAppender(fileAppender);
186+
}
187+
}
179188
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.likelion.backendplus4.yakplus.common.configuration;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
7+
import io.swagger.v3.oas.models.OpenAPI;
8+
import io.swagger.v3.oas.models.info.Info;
9+
10+
@Configuration
11+
public class SwaggerConfig {
12+
13+
@Bean
14+
public OpenAPI openAPI() {
15+
return new OpenAPI()
16+
.info(new Info()
17+
.title("YakPlus API")
18+
.description("YakPlus 프로젝트의 API 문서입니다.")
19+
.version("1.0.0"));
20+
}
21+
}

0 commit comments

Comments
 (0)