@@ -5,6 +5,8 @@ import com.coffee.api.cafe.application.port.inbound.FindCafeArea
55import com.coffee.api.cafe.application.port.inbound.FindCafeDetails
66import com.coffee.api.cafe.application.port.inbound.FindRecommendCafe
77import com.coffee.api.cafe.presentation.adapter.`in`.restapi.dto.response.*
8+ import com.coffee.api.cafe.presentation.adapter.`in`.restapi.mapper.FindAllCafesResponseMapper
9+ import com.coffee.api.cafe.presentation.adapter.`in`.restapi.mapper.GetCafeDetailsResponseMapper
810import com.coffee.api.cafe.presentation.docs.CafeApi
911import com.coffee.api.common.support.response.ApiResponse
1012import org.springframework.web.bind.annotation.GetMapping
@@ -29,29 +31,7 @@ class CafeController(
2931 @RequestParam(value = " area" , required = false ) area : String? ,
3032 ): ApiResponse <FindAllCafesResponseWrapper > {
3133 val result = findCafe.invoke(FindCafe .Query (lastCafeId, area))
32-
33- val cafes = result.cafes.map { cafe ->
34- FindAllCafesResponse (
35- cafeId = cafe.cafeId.value.toString(),
36- name = cafe.name,
37- nearestStation = cafe.nearestStation,
38- location = cafe.location,
39- price = cafe.price,
40- previewImages = cafe.previewImages,
41- tags = cafe.tags.map { tag ->
42- TagResponse (
43- id = tag.id.value.toString(),
44- name = tag.name,
45- )
46- },
47- )
48- }
49-
50- val response = FindAllCafesResponseWrapper (
51- cafes = cafes,
52- hasNext = result.hasNext,
53- )
54-
34+ val response = FindAllCafesResponseMapper .toResponse(result)
5535 return ApiResponse .success(response)
5636 }
5737
@@ -60,51 +40,7 @@ class CafeController(
6040 @PathVariable cafeId : UUID ,
6141 ): ApiResponse <GetCafeDetailsResponse > {
6242 val result = findCafeDetails.invoke(FindCafeDetails .Query (cafeId))
63-
64- val response = GetCafeDetailsResponse (
65- cafe = CafeResponse (
66- id = result.cafeDetails.cafe.id.value.toString(),
67- reasonForSelection = result.cafeDetails.cafe.reasonForSelection,
68- naverMapUrl = result.cafeDetails.cafe.naverMapUrl,
69- name = result.cafeDetails.cafe.name,
70- nearestStation = result.cafeDetails.cafe.nearestStation,
71- location = result.cafeDetails.cafe.location,
72- price = result.cafeDetails.cafe.price,
73- mainImageUrl = result.cafeDetails.cafe.mainImages,
74- ),
75- coffeeBean = CoffeeBeanResponse (
76- id = result.cafeDetails.coffeeBean.id.value.toString(),
77- description = result.cafeDetails.coffeeBean.description,
78- name = result.cafeDetails.coffeeBean.name,
79- engName = result.cafeDetails.coffeeBean.engName,
80- flavors = result.cafeDetails.coffeeBean.flavors.map { flavor ->
81- FlavorResponse (
82- flavor.displayName,
83- flavor.category
84- )
85- },
86- countryOfOrigin = result.cafeDetails.coffeeBean.countryOfOrigin,
87- roastingPoint = result.cafeDetails.coffeeBean.roastingPoint.toString(),
88- ),
89- menus = result.cafeDetails.menu.map { menu ->
90- MenuResponse (
91- id = menu.id.value.toString(),
92- name = menu.name,
93- price = menu.price,
94- imageUrl = menu.imageUrl,
95- description = menu.description,
96- )
97- },
98- tags = result.cafeDetails.tag.map { tag ->
99- DetailTagResponse (
100- id = tag.id.value.toString(),
101- name = tag.name,
102- imageUrl = tag.imageUrl
103- )
104- },
105- updatedAt = result.cafeDetails.updatedAt,
106- )
107-
43+ val response = GetCafeDetailsResponseMapper .toResponse(result)
10844 return ApiResponse .success(response)
10945 }
11046
0 commit comments