Skip to content

refactor: 불필요한 레이어 제거 #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<DestinationResponse> {
return ApiResponse.success(
destinationApplicationService.getDestinations()
DestinationResponse(createDestinationsMap())
)
}

private fun createDestinationsMap(): EnumMap<Continent, EnumMap<Country, List<City>>> {
val structure = EnumMap<Continent, EnumMap<Country, List<City>>>(Continent::class.java)
Continent.entries.forEach { continent ->
val countriesInContinent = EnumMap<Country, List<City>>(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
}
}
Loading