diff --git a/withaeng-api/src/main/kotlin/com/withaeng/api/applicationservice/destination/DestinationApplicationService.kt b/withaeng-api/src/main/kotlin/com/withaeng/api/applicationservice/destination/DestinationApplicationService.kt deleted file mode 100644 index 2421079..0000000 --- a/withaeng-api/src/main/kotlin/com/withaeng/api/applicationservice/destination/DestinationApplicationService.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.withaeng.api.applicationservice.destination - -import com.withaeng.api.applicationservice.accompany.dto.DestinationResponse -import com.withaeng.domain.destination.City -import com.withaeng.domain.destination.Continent -import com.withaeng.domain.destination.Country -import org.springframework.stereotype.Service -import java.util.* - -@Service -class DestinationApplicationService { - - fun getDestinations(): DestinationResponse { - val structure = EnumMap>>(Continent::class.java) - Continent.entries.forEach { continent -> - val countriesInContinent = EnumMap>(Country::class.java) - Country.entries - .filter { it.continentCode == continent.continentCode } - .forEach { country -> - val citiesInCountry = City.entries - .filter { it.countryCode == country.countryCode } - .toList() - countriesInContinent[country] = citiesInCountry - } - structure[continent] = countriesInContinent - } - return DestinationResponse(structure) - } -} \ No newline at end of file diff --git a/withaeng-api/src/main/kotlin/com/withaeng/api/controller/destination/DestinationController.kt b/withaeng-api/src/main/kotlin/com/withaeng/api/controller/destination/DestinationController.kt index 0cd200d..e4bfa4b 100644 --- a/withaeng-api/src/main/kotlin/com/withaeng/api/controller/destination/DestinationController.kt +++ b/withaeng-api/src/main/kotlin/com/withaeng/api/controller/destination/DestinationController.kt @@ -1,22 +1,42 @@ package com.withaeng.api.controller.destination import com.withaeng.api.applicationservice.accompany.dto.DestinationResponse -import com.withaeng.api.applicationservice.destination.DestinationApplicationService import com.withaeng.api.common.ApiResponse +import com.withaeng.domain.destination.City +import com.withaeng.domain.destination.Continent +import com.withaeng.domain.destination.Country import io.swagger.v3.oas.annotations.tags.Tag import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController +import java.util.* @Tag(name = "Destination", description = "여행지 API") @RestController @RequestMapping("/api/v1/destinations") -class DestinationController(private val destinationApplicationService: DestinationApplicationService) { +class DestinationController { @GetMapping fun getDestinations(): ApiResponse { return ApiResponse.success( - destinationApplicationService.getDestinations() + DestinationResponse(createDestinationsMap()) ) } + + private fun createDestinationsMap(): EnumMap>> { + val structure = EnumMap>>(Continent::class.java) + Continent.entries.forEach { continent -> + val countriesInContinent = EnumMap>(Country::class.java) + Country.entries + .filter { it.continentCode == continent.continentCode } + .forEach { country -> + val citiesInCountry = City.entries + .filter { it.countryCode == country.countryCode } + .toList() + countriesInContinent[country] = citiesInCountry + } + structure[continent] = countriesInContinent + } + return structure + } } \ No newline at end of file