From 1301bedaf962cf5bedbdc5933b68f5f998db81f2 Mon Sep 17 00:00:00 2001 From: Hank-Choi Date: Fri, 5 Apr 2024 12:17:56 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"=EA=B0=95=EC=9D=98=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=B0=98=ED=99=98=20=EC=A0=84=EC=97=90=20?= =?UTF-8?q?=EB=B9=8C=EB=94=A9=20=EC=A0=95=EB=B3=B4=20=EB=A7=A4=ED=95=91=20?= =?UTF-8?q?[=EC=9D=B4=ED=9B=84=20=EB=A1=A4=EB=B0=B1]"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b547b59205d04fe49e10ded6f07cfa12dc63c315. --- .../kotlin/handler/LectureSearchHandler.kt | 20 -------------- .../main/kotlin/handler/TimetableHandler.kt | 27 ------------------- .../lectures/dto/ClassPlaceAndTimeDto.kt | 2 -- 3 files changed, 49 deletions(-) diff --git a/api/src/main/kotlin/handler/LectureSearchHandler.kt b/api/src/main/kotlin/handler/LectureSearchHandler.kt index 0ea5e547..0fae7b09 100644 --- a/api/src/main/kotlin/handler/LectureSearchHandler.kt +++ b/api/src/main/kotlin/handler/LectureSearchHandler.kt @@ -3,16 +3,11 @@ package com.wafflestudio.snu4t.handler import com.fasterxml.jackson.annotation.JsonProperty import com.wafflestudio.snu4t.common.enum.DayOfWeek import com.wafflestudio.snu4t.common.enum.Semester -import com.wafflestudio.snu4t.lecturebuildings.data.PlaceInfo -import com.wafflestudio.snu4t.lecturebuildings.service.LectureBuildingService import com.wafflestudio.snu4t.lectures.dto.LectureDto import com.wafflestudio.snu4t.lectures.dto.SearchDto import com.wafflestudio.snu4t.lectures.dto.SearchTimeDto import com.wafflestudio.snu4t.lectures.service.LectureService import com.wafflestudio.snu4t.middleware.SnuttRestApiNoAuthMiddleware -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll -import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.toList import org.springframework.stereotype.Component import org.springframework.web.reactive.function.server.ServerRequest @@ -22,7 +17,6 @@ import org.springframework.web.reactive.function.server.awaitBody @Component class LectureSearchHandler( private val lectureService: LectureService, - private val lectureBuildingService: LectureBuildingService, snuttRestApiNoAuthMiddleware: SnuttRestApiNoAuthMiddleware, ) : ServiceHandler( handlerMiddleware = snuttRestApiNoAuthMiddleware @@ -30,20 +24,6 @@ class LectureSearchHandler( suspend fun searchLectures(req: ServerRequest): ServerResponse = handle(req) { val query: SearchQueryLegacy = req.awaitBody() lectureService.search(query.toSearchDto()).toList().map { LectureDto(it) } - .map { it.addLectureBuildings() } - } - - private suspend fun LectureDto.addLectureBuildings(): LectureDto = coroutineScope { - copy( - classPlaceAndTimes = classPlaceAndTimes.map { classPlaceAndTime -> - async { - classPlaceAndTime.apply { - lectureBuildings = - place?.let { lectureBuildingService.getLectureBuildings(PlaceInfo.getValuesOf(it)) } - } - } - }.awaitAll() - ) } } diff --git a/api/src/main/kotlin/handler/TimetableHandler.kt b/api/src/main/kotlin/handler/TimetableHandler.kt index 1497ca2f..915a019e 100644 --- a/api/src/main/kotlin/handler/TimetableHandler.kt +++ b/api/src/main/kotlin/handler/TimetableHandler.kt @@ -2,17 +2,12 @@ package com.wafflestudio.snu4t.handler import com.wafflestudio.snu4t.common.enum.Semester import com.wafflestudio.snu4t.common.exception.InvalidPathParameterException -import com.wafflestudio.snu4t.lecturebuildings.data.PlaceInfo -import com.wafflestudio.snu4t.lecturebuildings.service.LectureBuildingService import com.wafflestudio.snu4t.middleware.SnuttRestApiDefaultMiddleware import com.wafflestudio.snu4t.timetables.dto.TimetableLegacyDto import com.wafflestudio.snu4t.timetables.dto.request.TimetableAddRequestDto import com.wafflestudio.snu4t.timetables.dto.request.TimetableModifyRequestDto import com.wafflestudio.snu4t.timetables.dto.request.TimetableModifyThemeRequestDto import com.wafflestudio.snu4t.timetables.service.TimetableService -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll -import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.toList import org.springframework.stereotype.Component import org.springframework.web.reactive.function.server.ServerRequest @@ -23,7 +18,6 @@ import timetables.dto.TimetableBriefDto @Component class TimetableHandler( private val timetableService: TimetableService, - private val lectureBuildingService: LectureBuildingService, snuttRestApiDefaultMiddleware: SnuttRestApiDefaultMiddleware, ) : ServiceHandler( handlerMiddleware = snuttRestApiDefaultMiddleware @@ -38,7 +32,6 @@ class TimetableHandler( val userId = req.userId timetableService.getMostRecentlyUpdatedTimetable(userId).let(::TimetableLegacyDto) - .addLectureBuidlings() } suspend fun getTimetablesBySemester(req: ServerRequest): ServerResponse = handle(req) { @@ -48,7 +41,6 @@ class TimetableHandler( Semester.getOfValue(req.pathVariable("semester").toInt()) ?: throw InvalidPathParameterException("semester") timetableService.getTimetablesBySemester(userId, year, semester).toList().map(::TimetableLegacyDto) - .map { it.addLectureBuidlings() } } suspend fun addTimetable(req: ServerRequest): ServerResponse = handle(req) { @@ -69,7 +61,6 @@ class TimetableHandler( val timetableId = req.pathVariable("timetableId") timetableService.getTimetable(userId, timetableId).let(::TimetableLegacyDto) - .addLectureBuidlings() } suspend fun modifyTimetable(req: ServerRequest): ServerResponse = handle(req) { @@ -109,7 +100,6 @@ class TimetableHandler( val body = req.awaitBody() timetableService.modifyTimetableTheme(userId, timetableId, body.theme, body.themeId).let(::TimetableLegacyDto) - .addLectureBuidlings() } suspend fun setPrimary(req: ServerRequest): ServerResponse = handle(req) { @@ -121,21 +111,4 @@ class TimetableHandler( val timetableId = req.pathVariable("timetableId") timetableService.unSetPrimary(req.userId, timetableId) } - - private suspend fun TimetableLegacyDto.addLectureBuidlings(): TimetableLegacyDto = coroutineScope { - copy( - lectures = lectures.map { lecture -> - lecture.apply { - classPlaceAndTimes = classPlaceAndTimes.map { placeAndTime -> - async { - placeAndTime.apply { - lectureBuildings = - place?.let { lectureBuildingService.getLectureBuildings(PlaceInfo.getValuesOf(it)) } - } - } - }.awaitAll() - } - } - ) - } } diff --git a/core/src/main/kotlin/lectures/dto/ClassPlaceAndTimeDto.kt b/core/src/main/kotlin/lectures/dto/ClassPlaceAndTimeDto.kt index 607d0d62..7c889848 100644 --- a/core/src/main/kotlin/lectures/dto/ClassPlaceAndTimeDto.kt +++ b/core/src/main/kotlin/lectures/dto/ClassPlaceAndTimeDto.kt @@ -2,7 +2,6 @@ package com.wafflestudio.snu4t.lectures.dto import com.fasterxml.jackson.annotation.JsonProperty import com.wafflestudio.snu4t.common.enum.DayOfWeek -import com.wafflestudio.snu4t.lecturebuildings.data.LectureBuilding import com.wafflestudio.snu4t.lectures.data.ClassPlaceAndTime import com.wafflestudio.snu4t.lectures.utils.endPeriod import com.wafflestudio.snu4t.lectures.utils.minuteToString @@ -35,7 +34,6 @@ data class ClassPlaceAndTimeLegacyDto( val periodLength: Double, @JsonProperty("start") val startPeriod: Double, - var lectureBuildings: List? = null, ) fun ClassPlaceAndTimeLegacyDto(classPlaceAndTime: ClassPlaceAndTime): ClassPlaceAndTimeLegacyDto = ClassPlaceAndTimeLegacyDto(