Skip to content

Commit 6830737

Browse files
JIWONKIMSclaude
andauthored
feat(be): weather 중기기온 강수 DTO 작업(#26) (#27)
* bug(be): application 위치 조정 * refactor(be): SpringBootApplication 어노테이션 간소화 JdbcChatMemoryRepositoryAutoConfiguration 제외 설정 제거 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * test commit to check ktlint * fix: ktlint formatting fixes --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c749840 commit 6830737

File tree

11 files changed

+66
-21
lines changed

11 files changed

+66
-21
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.back.koreaTravelGuide.application
1+
package com.back.koreaTravelGuide
22

33
// TODO: 메인 애플리케이션 클래스 - 스프링 부트 시작점 및 환경변수 로딩
44
import io.github.cdimascio.dotenv.dotenv

src/main/kotlin/com/back/koreaTravelGuide/domain/ai/aiChat/controller/ChatController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ChatController(
117117
return emitter
118118
}
119119

120-
// 날씨 API 직접 테스트용 엔드포인트
120+
// 날씨 API 직접 테스트용 엔드포인트
121121
@GetMapping("/weather/test")
122122
fun testWeather(
123123
@RequestParam(required = false) baseTime: String?,

src/main/kotlin/com/back/koreaTravelGuide/domain/ai/weather/dto/LandForecastData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.back.koreaTravelGuide.domain.ai.weather.dto
22

33
@Suppress("unused") // JSON 직렬화를 위해 필요
4-
class LandForecastData(
4+
data class LandForecastData(
55
private val days: MutableMap<Int, LandForecastInfo?> = mutableMapOf(),
66
) {
77
fun setDay(
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.back.koreaTravelGuide.domain.ai.weather.dto
22

33
data class MidForecastDto(
4-
val regionCode: String,
5-
val baseTime: String,
6-
val precipitation: String,
7-
val temperature: String,
8-
val maritime: String,
9-
val variability: String,
4+
val regionCode: String?,
5+
val baseTime: String?,
6+
val precipitation: String?,
7+
val temperature: String?,
8+
val maritime: String?,
9+
val variability: String?,
1010
)
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package com.back.koreaTravelGuide.domain.ai.weather.dto
22

33
data class TemperatureAndLandForecastDto(
4-
val a: String,
4+
val regionCode: String?,
5+
val baseTime: String?,
6+
val minTemp: Int?,
7+
val maxTemp: Int?,
8+
val minTempRange: String?,
9+
val maxTempRange: String?,
10+
val amRainPercent: Int?,
11+
val pmRainPercent: Int?,
12+
val amWeather: String?,
13+
val pmWeather: String?,
514
)

src/main/kotlin/com/back/koreaTravelGuide/domain/ai/weather/dto/TemperatureData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.back.koreaTravelGuide.domain.ai.weather.dto
22

33
// TODO: 날씨 내부 데이터 구조 - 기상청 API 응답 데이터 매핑용 내부 클래스들
44
@Suppress("unused") // JSON 직렬화를 위해 필요
5-
class TemperatureData(
5+
data class TemperatureData(
66
private val days: MutableMap<Int, TemperatureInfo?> = mutableMapOf(),
77
) {
88
fun setDay(

src/main/kotlin/com/back/koreaTravelGuide/domain/ai/weather/dto/parser/DtoParser.kt

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,49 @@ class DtoParser {
5656
}
5757

5858
fun parseTemperatureAndLandForecast(
59+
regionCode: String,
60+
baseTime: String,
5961
temperatureData: TemperatureData,
6062
landForecastData: LandForecastData,
61-
): TemperatureAndLandForecastDto {
62-
return TemperatureAndLandForecastDto(
63-
"a",
64-
)
63+
): List<TemperatureAndLandForecastDto> {
64+
val resultList = mutableListOf<TemperatureAndLandForecastDto>()
65+
66+
for (i in 4..10) {
67+
val tempInfo = temperatureData.getDay(i)
68+
val landInfo = landForecastData.getDay(i)
69+
70+
if (tempInfo == null || landInfo == null) {
71+
continue
72+
}
73+
74+
val minTemp = tempInfo.minTemp
75+
val maxTemp = tempInfo.maxTemp
76+
val minTempRange = tempInfo.minTempRange
77+
val maxTempRange = tempInfo.maxTempRange
78+
79+
val amRainPercent = landInfo.amRainPercent
80+
val pmRainPercent = landInfo.pmRainPercent
81+
val amWeather = landInfo.amWeather
82+
val pmWeather = landInfo.pmWeather
83+
84+
// 각 날짜별로 필요한 처리를 수행합니다.
85+
val dto =
86+
TemperatureAndLandForecastDto(
87+
regionCode = regionCode,
88+
baseTime = baseTime,
89+
minTemp = minTemp,
90+
maxTemp = maxTemp,
91+
minTempRange = minTempRange,
92+
maxTempRange = maxTempRange,
93+
amRainPercent = amRainPercent,
94+
pmRainPercent = pmRainPercent,
95+
amWeather = amWeather,
96+
pmWeather = pmWeather,
97+
)
98+
99+
resultList.add(dto)
100+
}
101+
102+
return resultList
65103
}
66104
}

src/main/kotlin/com/back/koreaTravelGuide/domain/ai/weather/service/WeatherService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class WeatherService(
3434
fun fetchTemperatureAndLandForecast(
3535
actualRegionCode: String,
3636
actualBaseTime: String,
37-
): TemperatureAndLandForecastDto? {
37+
): List<TemperatureAndLandForecastDto>? {
3838
val tempInfo = weatherApiClient.fetchTemperature(actualRegionCode, actualBaseTime)
3939
val landInfo = weatherApiClient.fetchLandForecast(actualRegionCode, actualBaseTime)
4040

4141
if (tempInfo == null || landInfo == null) return null
4242

43-
return parser.parseTemperatureAndLandForecast(tempInfo, landInfo)
43+
return parser.parseTemperatureAndLandForecast(actualRegionCode, actualBaseTime, tempInfo, landInfo)
4444
}
4545

4646
@CacheEvict(cacheNames = ["weatherMidFore", "weatherTempAndLandFore"], allEntries = true)

src/main/kotlin/com/back/koreaTravelGuide/domain/ai/weather/service/WeatherServiceCore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class WeatherServiceCore(
2222
location: String?,
2323
regionCode: String?,
2424
baseTime: String?,
25-
): TemperatureAndLandForecastDto? {
25+
): List<TemperatureAndLandForecastDto>? {
2626
val actualLocation = location ?: "서울"
2727
val actualRegionCode = regionCode ?: tools.getRegionCodeFromLocation(actualLocation)
2828

src/test/kotlin/com/back/koreaTravelGuide/WeatherApiRealTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
package com.back.koreaTravelGuide.application
2-
31
import com.fasterxml.jackson.databind.ObjectMapper
42
import io.github.cdimascio.dotenv.dotenv
53
import org.junit.jupiter.api.BeforeAll

0 commit comments

Comments
 (0)