From f25ec023e82a932908359b436ceac9a49db2b0d6 Mon Sep 17 00:00:00 2001 From: eunbin00 Date: Thu, 22 Jun 2023 12:20:21 +0900 Subject: [PATCH] #2 - Feat: Add Introduction Detail Information Search basic MVCs --- .../CommonDetailSearchRestController.java | 4 +- .../DetailSearchRestController.java | 78 ++++ .../AttractionDetailSearchService.java | 21 + .../AttractionInformationSearchService.java | 12 - .../DefaultAttractionDetailSearchService.java | 439 ++++++++++++++++++ ...ultAttractionInformationSearchService.java | 75 --- .../infra/tourapi/vo/AttractionSearchVO.java | 2 + .../vo/attraction/AreaBasedAttractionVO.java | 2 +- .../tourapi/vo/attraction/AttractionVO.java | 2 +- .../vo/attraction/FestivalAttractionVO.java | 2 +- .../attraction/KeywordBasedAttractionVO.java | 2 +- .../attraction/LocationBasedAttractionVO.java | 2 +- .../vo/attraction/StayAttractionVO.java | 3 +- .../tourapi/vo/detail/CommonDetailVO.java | 3 +- .../vo/detail/CourseAttractionDetailVO.java | 42 ++ .../vo/detail/CultureAttractionDetailVO.java | 60 +++ .../vo/detail/FestivalAttractionDetailVO.java | 81 ++++ .../vo/detail/LeportsAttractionDetailVO.java | 60 +++ .../detail/RestaurantAttractionDetailVO.java | 60 +++ .../vo/detail/ShoppingAttractionDetailVO.java | 62 +++ .../vo/detail/StayAttractionDetailVO.java | 92 ++++ .../vo/detail/TourAttractionDetailVO.java | 69 +++ 22 files changed, 1077 insertions(+), 96 deletions(-) create mode 100644 src/main/java/org/routemaster/api/total/domain/attraction/controller/DetailSearchRestController.java create mode 100644 src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionDetailSearchService.java delete mode 100644 src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionInformationSearchService.java create mode 100644 src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionDetailSearchService.java delete mode 100644 src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionInformationSearchService.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CourseAttractionDetailVO.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CultureAttractionDetailVO.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/FestivalAttractionDetailVO.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/LeportsAttractionDetailVO.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/RestaurantAttractionDetailVO.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/ShoppingAttractionDetailVO.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/StayAttractionDetailVO.java create mode 100644 src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/TourAttractionDetailVO.java diff --git a/src/main/java/org/routemaster/api/total/domain/attraction/controller/CommonDetailSearchRestController.java b/src/main/java/org/routemaster/api/total/domain/attraction/controller/CommonDetailSearchRestController.java index 48f2de1..7e72959 100644 --- a/src/main/java/org/routemaster/api/total/domain/attraction/controller/CommonDetailSearchRestController.java +++ b/src/main/java/org/routemaster/api/total/domain/attraction/controller/CommonDetailSearchRestController.java @@ -8,7 +8,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.routemaster.api.total.domain.attraction.service.AttractionInformationSearchService; +import org.routemaster.api.total.domain.attraction.service.AttractionDetailSearchService; import org.routemaster.api.total.infra.tourapi.vo.AttractionSearchVO; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -23,7 +23,7 @@ @RequiredArgsConstructor public class CommonDetailSearchRestController { - private final AttractionInformationSearchService service; + private final AttractionDetailSearchService service; @Operation( summary = "공통 상세 정보 조회", diff --git a/src/main/java/org/routemaster/api/total/domain/attraction/controller/DetailSearchRestController.java b/src/main/java/org/routemaster/api/total/domain/attraction/controller/DetailSearchRestController.java new file mode 100644 index 0000000..e401f41 --- /dev/null +++ b/src/main/java/org/routemaster/api/total/domain/attraction/controller/DetailSearchRestController.java @@ -0,0 +1,78 @@ +package org.routemaster.api.total.domain.attraction.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.routemaster.api.total.domain.attraction.service.AttractionDetailSearchService; +import org.routemaster.api.total.infra.tourapi.vo.detail.*; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; + +@Slf4j +@RestController +@RequestMapping("/attraction-detail/info") +@RequiredArgsConstructor +public class DetailSearchRestController { + + private final AttractionDetailSearchService service; + + @GetMapping("/tour") + public ResponseEntity> tourAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchTourAttractionDetail(contentId)); + } + + @GetMapping("/culture") + public ResponseEntity> cultureAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchCultureAttractionDetail(contentId)); + } + + @GetMapping("/stay") + public ResponseEntity> stayAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchStayAttractionDetail(contentId)); + } + + @GetMapping("/festival") + public ResponseEntity> festivalAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchFestivalAttractionDetail(contentId)); + } + + @GetMapping("/leports") + public ResponseEntity> leportsAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchLeportsAttractionDetail(contentId)); + } + + @GetMapping("/restaurant") + public ResponseEntity> restaurantAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchRestaurantAttractionDetail(contentId)); + } + + @GetMapping("/shopping") + public ResponseEntity> shoppingAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchShoppingAttractionDetail(contentId)); + } + + @GetMapping("/course") + public ResponseEntity> courseAttractionDetail( + @RequestParam Integer contentId + ) { + return ResponseEntity.ok().body(service.searchCourseAttractionDetail(contentId)); + } + +} diff --git a/src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionDetailSearchService.java b/src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionDetailSearchService.java new file mode 100644 index 0000000..5a23f61 --- /dev/null +++ b/src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionDetailSearchService.java @@ -0,0 +1,21 @@ +package org.routemaster.api.total.domain.attraction.service; + +import org.routemaster.api.total.infra.tourapi.vo.AttractionSearchVO; +import org.routemaster.api.total.infra.tourapi.vo.detail.*; +import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; +import reactor.core.publisher.Mono; + +public interface AttractionDetailSearchService { + + Mono searchAttractionCommonDetail(Integer contentId); + Mono searchTourAttractionDetail(Integer contentId); + Mono searchCultureAttractionDetail(Integer contentId); + Mono searchLeportsAttractionDetail(Integer contentId); + Mono searchFestivalAttractionDetail(Integer contentId); + Mono searchRestaurantAttractionDetail(Integer contentId); + Mono searchShoppingAttractionDetail(Integer contentId); + Mono searchStayAttractionDetail(Integer contentId); + Mono searchCourseAttractionDetail(Integer contentId); + + +} diff --git a/src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionInformationSearchService.java b/src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionInformationSearchService.java deleted file mode 100644 index 237e4da..0000000 --- a/src/main/java/org/routemaster/api/total/domain/attraction/service/AttractionInformationSearchService.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.routemaster.api.total.domain.attraction.service; - -import org.routemaster.api.total.infra.tourapi.vo.AttractionSearchVO; -import reactor.core.publisher.Mono; - -public interface AttractionInformationSearchService { - - Mono searchAttractionDetail( - Integer contentId - ); - -} diff --git a/src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionDetailSearchService.java b/src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionDetailSearchService.java new file mode 100644 index 0000000..d4f16c6 --- /dev/null +++ b/src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionDetailSearchService.java @@ -0,0 +1,439 @@ +package org.routemaster.api.total.domain.attraction.service.impl; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; +import org.routemaster.api.total.domain.attraction.service.AttractionDetailSearchService; +import org.routemaster.api.total.infra.tourapi.value.TourAPI; +import org.routemaster.api.total.infra.tourapi.vo.AttractionSearchVO; +import org.routemaster.api.total.infra.tourapi.vo.detail.*; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Service; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.util.DefaultUriBuilderFactory; +import reactor.core.publisher.Mono; + +import java.io.IOException; + +@Slf4j +@Service +public class DefaultAttractionDetailSearchService implements AttractionDetailSearchService { + + private final String MOBILEOS = "ETC"; + private final String MOBILEAPP = "TimeMap"; + private final String TYPE = "json"; + + @Override + public Mono searchAttractionCommonDetail( + Integer contentId + ) { + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailCommon1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("defaultYN", "Y") + .queryParam("firstImageYN", "Y") + .queryParam("areacodeYN", "Y") + .queryParam("catcodeYN", "Y") + .queryParam("addrinfoYN", "Y") + .queryParam("mapinfoYN", "Y") + .queryParam("overviewYN", "Y") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + ObjectMapper objectMapper = new ObjectMapper(); + try { + JsonNode jsonNode = mapper.readTree(str); + AttractionSearchVO vo = AttractionSearchVO.builder() + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .commonDetailItems(jsonNode.get("response").get("body")) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + public Mono searchTourAttractionDetail(Integer contentId) { + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "12") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + ObjectMapper objectMapper = new ObjectMapper(); + try { + JsonNode jsonNode = mapper.readTree(str); + TourAttractionDetailVO vo = TourAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + @Override + public Mono searchCultureAttractionDetail(Integer contentId) { + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "14") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + try { + JsonNode jsonNode = mapper.readTree(str); + CultureAttractionDetailVO vo = CultureAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + @Override + public Mono searchLeportsAttractionDetail(Integer contentId) { + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "28") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + try { + JsonNode jsonNode = mapper.readTree(str); + LeportsAttractionDetailVO vo = LeportsAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + @Override + public Mono searchFestivalAttractionDetail(Integer contentId) { + + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "15") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + try { + JsonNode jsonNode = mapper.readTree(str); + FestivalAttractionDetailVO vo = FestivalAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + @Override + public Mono searchRestaurantAttractionDetail(Integer contentId) { + + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "39") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + try { + JsonNode jsonNode = mapper.readTree(str); + RestaurantAttractionDetailVO vo = RestaurantAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + @Override + public Mono searchShoppingAttractionDetail(Integer contentId) { + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "38") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + try { + JsonNode jsonNode = mapper.readTree(str); + ShoppingAttractionDetailVO vo = ShoppingAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + @Override + public Mono searchStayAttractionDetail(Integer contentId) { + + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "32") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + try { + JsonNode jsonNode = mapper.readTree(str); + StayAttractionDetailVO vo = StayAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } + + @Override + public Mono searchCourseAttractionDetail(Integer contentId) { + ObjectMapper mapper = new ObjectMapper(); + + DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); + factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); + + WebClient webClient = WebClient.builder() + .uriBuilderFactory(factory) + .baseUrl(TourAPI.baseUrl) + .build(); + + Mono result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/detailIntro1") + .queryParam("serviceKey", TourAPI.encodingKey) + .queryParam("MobileOS", MOBILEOS) + .queryParam("MobileApp", MOBILEAPP) + .queryParam("_type", TYPE) + .queryParam("contentId", contentId) + .queryParam("contentTypeId", "25") + .build() + ) + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(String.class) + .map(str -> { + try { + JsonNode jsonNode = mapper.readTree(str); + CourseAttractionDetailVO vo = CourseAttractionDetailVO.builder() + .builder(jsonNode.get("response").get("body")) + .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) + .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) + .numOfRows(jsonNode.get("response").get("body").get("numOfRows").asInt()) + .pageNo(jsonNode.get("response").get("body").get("pageNo").asInt()) + .totalCount(jsonNode.get("response").get("body").get("totalCount").asInt()) + .build(); + return vo; + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return result; + } +} diff --git a/src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionInformationSearchService.java b/src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionInformationSearchService.java deleted file mode 100644 index 8a389f4..0000000 --- a/src/main/java/org/routemaster/api/total/domain/attraction/service/impl/DefaultAttractionInformationSearchService.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.routemaster.api.total.domain.attraction.service.impl; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.routemaster.api.total.domain.attraction.service.AttractionInformationSearchService; -import org.routemaster.api.total.infra.tourapi.value.TourAPI; -import org.routemaster.api.total.infra.tourapi.vo.AttractionSearchVO; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Service; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.util.DefaultUriBuilderFactory; -import reactor.core.publisher.Mono; - -import java.io.IOException; - -@Slf4j -@Service -public class DefaultAttractionInformationSearchService implements AttractionInformationSearchService { - - private final String MOBILEOS = "ETC"; - private final String MOBILEAPP = "TimeMap"; - private final String TYPE = "json"; - - @Override - public Mono searchAttractionDetail( - Integer contentId - ) { - ObjectMapper mapper = new ObjectMapper(); - - DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(TourAPI.baseUrl); - factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY); - - WebClient webClient = WebClient.builder() - .uriBuilderFactory(factory) - .baseUrl(TourAPI.baseUrl) - .build(); - - Mono result = webClient.get() - .uri(uriBuilder -> uriBuilder - .path("/detailCommon1") - .queryParam("serviceKey", TourAPI.encodingKey) - .queryParam("MobileOS", MOBILEOS) - .queryParam("MobileApp", MOBILEAPP) - .queryParam("_type", TYPE) - .queryParam("contentId", contentId) - .queryParam("defaultYN", "Y") - .queryParam("firstImageYN", "Y") - .queryParam("areacodeYN", "Y") - .queryParam("catcodeYN", "Y") - .queryParam("addrinfoYN", "Y") - .queryParam("mapinfoYN", "Y") - .queryParam("overviewYN", "Y") - .build() - ) - .accept(MediaType.APPLICATION_JSON) - .retrieve() - .bodyToMono(String.class) - .map(str -> { - ObjectMapper objectMapper = new ObjectMapper(); - try { - JsonNode jsonNode = mapper.readTree(str); - AttractionSearchVO attractionSearchVO = AttractionSearchVO.builder() - .resultCode(jsonNode.get("response").get("header").get("resultCode").asText()) - .resultMessage(jsonNode.get("response").get("header").get("resultMsg").asText()) - .commonDetailItems(jsonNode.get("response").get("body")) - .build(); - return attractionSearchVO; - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - return result; - } -} diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/AttractionSearchVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/AttractionSearchVO.java index 8d1cf41..904ab96 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/AttractionSearchVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/AttractionSearchVO.java @@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.extern.slf4j.Slf4j; +import org.routemaster.api.total.infra.tourapi.vo.attraction.*; +import org.routemaster.api.total.infra.tourapi.vo.detail.CommonDetailVO; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AreaBasedAttractionVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AreaBasedAttractionVO.java index 25de703..ef5dae4 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AreaBasedAttractionVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AreaBasedAttractionVO.java @@ -1,4 +1,4 @@ -package org.routemaster.api.total.infra.tourapi.vo; +package org.routemaster.api.total.infra.tourapi.vo.attraction; import com.fasterxml.jackson.databind.JsonNode; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AttractionVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AttractionVO.java index 4d40569..491dc2a 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AttractionVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/AttractionVO.java @@ -1,4 +1,4 @@ -package org.routemaster.api.total.infra.tourapi.vo; +package org.routemaster.api.total.infra.tourapi.vo.attraction; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/FestivalAttractionVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/FestivalAttractionVO.java index cc3fd81..2d7fc41 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/FestivalAttractionVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/FestivalAttractionVO.java @@ -1,4 +1,4 @@ -package org.routemaster.api.total.infra.tourapi.vo; +package org.routemaster.api.total.infra.tourapi.vo.attraction; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/KeywordBasedAttractionVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/KeywordBasedAttractionVO.java index 51591c1..e908c39 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/KeywordBasedAttractionVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/KeywordBasedAttractionVO.java @@ -1,4 +1,4 @@ -package org.routemaster.api.total.infra.tourapi.vo; +package org.routemaster.api.total.infra.tourapi.vo.attraction; import com.fasterxml.jackson.databind.JsonNode; import lombok.*; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/LocationBasedAttractionVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/LocationBasedAttractionVO.java index 770ec9e..df8f0bf 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/LocationBasedAttractionVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/LocationBasedAttractionVO.java @@ -1,4 +1,4 @@ -package org.routemaster.api.total.infra.tourapi.vo; +package org.routemaster.api.total.infra.tourapi.vo.attraction; import com.fasterxml.jackson.databind.JsonNode; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/StayAttractionVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/StayAttractionVO.java index bdd8328..21264b3 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/StayAttractionVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/attraction/StayAttractionVO.java @@ -1,8 +1,9 @@ -package org.routemaster.api.total.infra.tourapi.vo; +package org.routemaster.api.total.infra.tourapi.vo.attraction; import com.fasterxml.jackson.databind.JsonNode; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; +import org.routemaster.api.total.infra.tourapi.vo.attraction.AttractionVO; import java.text.ParseException; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CommonDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CommonDetailVO.java index 600a62a..677b09b 100644 --- a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CommonDetailVO.java +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CommonDetailVO.java @@ -1,8 +1,9 @@ -package org.routemaster.api.total.infra.tourapi.vo; +package org.routemaster.api.total.infra.tourapi.vo.detail; import com.fasterxml.jackson.databind.JsonNode; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; +import org.routemaster.api.total.infra.tourapi.vo.attraction.AttractionVO; import java.text.ParseException; import java.util.Objects; diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CourseAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CourseAttractionDetailVO.java new file mode 100644 index 0000000..f3c567f --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CourseAttractionDetailVO.java @@ -0,0 +1,42 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class CourseAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + private static class Detail { + private @Getter String distance; + private @Getter String spendTime; + private @Getter String theme; + private @Getter String infoCenter; + private @Getter String schedule; + } + + public static final class CourseAttractionDetailVOBuilder { + public CourseAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.distance = item.get("distance").asText().isEmpty() ? null : item.get("distance").asText(); + this.detail.spendTime = item.get("taketime").asText().isEmpty() ? null : item.get("taketime").asText(); + this.detail.theme = item.get("theme").asText().isEmpty() ? null : item.get("theme").asText(); + this.detail.infoCenter = item.get("infocentertourcourse").asText().isEmpty() ? null : item.get("infocentertourcourse").asText(); + this.detail.schedule = item.get("schedule").asText().isEmpty() ? null : item.get("schedule").asText(); + }); + return this; + } + } + +} diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CultureAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CultureAttractionDetailVO.java new file mode 100644 index 0000000..69ad0eb --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/CultureAttractionDetailVO.java @@ -0,0 +1,60 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class CultureAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + private static class Detail { + private @Getter Integer accomodationCount; + private @Getter String babyCarriageInfo; + private @Getter String creditcardInfo; + private @Getter String allowPetInfo; + private @Getter String discountInfo; + private @Getter String infoCenter; + private @Getter String parking; + private @Getter String parkingFee; + private @Getter String restDate; + private @Getter String usageFee; + private @Getter String hoursOfOperation; + private @Getter String scale; + private @Getter String spendTime; + } + + public final static class CultureAttractionDetailVOBuilder { + + public CultureAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.accomodationCount = item.get("accomcountculture").asText().isEmpty() ? null : item.get("accomcountculture").asInt(); + this.detail.babyCarriageInfo = item.get("chkbabycarriageculture").asText().isEmpty() ? null : item.get("chkbabycarriageculture").asText(); + this.detail.creditcardInfo = item.get("chkcreditcardculture").asText().isEmpty() ? null : item.get("chkcreditcardculture").asText(); + this.detail.allowPetInfo = item.get("chkpetculture").asText().isEmpty() ? null : item.get("chkpetculture").asText(); + this.detail.discountInfo = item.get("discountinfo").asText().isEmpty() ? null : item.get("discountinfo").asText(); + this.detail.infoCenter = item.get("infocenterculture").asText().isEmpty() ? null : item.get("infocenterculture").asText(); + this.detail.parking = item.get("parkingculture").asText().isEmpty() ? null : item.get("parkingculture").asText(); + this.detail.parkingFee = item.get("parkingfee").asText().isEmpty() ? null : item.get("parkingfee").asText(); + this.detail.restDate = item.get("restdateculture").asText().isEmpty() ? null : item.get("restdateculture").asText(); + this.detail.usageFee = item.get("usefee").asText().isEmpty() ? null : item.get("usefee").asText(); + this.detail.hoursOfOperation = item.get("usetimeculture").asText().isEmpty() ? null : item.get("usetimeculture").asText(); + this.detail.scale = item.get("scale").asText().isEmpty() ? null : item.get("scale").asText(); + this.detail.spendTime = item.get("spendtime").asText().isEmpty() ? null : item.get("spendtime").asText(); + }); + return this; + } + + } +} + diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/FestivalAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/FestivalAttractionDetailVO.java new file mode 100644 index 0000000..83b0edc --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/FestivalAttractionDetailVO.java @@ -0,0 +1,81 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class FestivalAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + private static class Detail { + private @Getter String ageLimit; + private @Getter String bookingPlace; + private @Getter String discountInfo; + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") + private @Getter Date eventStartDate; + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") + private @Getter Date eventEndDate; + private @Getter String eventHomepage; + private @Getter String eventPlace; + private @Getter String festivalGrade; + private @Getter String placeInfo; + private @Getter String playTime; + private @Getter String program; + private @Getter String spendTime; + private @Getter String sponsor; + private @Getter String sponsorTel; + private @Getter String organizer; + private @Getter String organizerTel; + private @Getter String subEvent; + private @Getter String usageFee; + } + + public final static class FestivalAttractionDetailVOBuilder { + SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); + + public FestivalAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.ageLimit = item.get("agelimit").asText().isEmpty() ? null : item.get("agelimit").asText(); + this.detail.bookingPlace = item.get("bookingplace").asText().isEmpty() ? null : item.get("bookingplace").asText(); + this.detail.discountInfo = item.get("discountinfofestival").asText().isEmpty() ? null : item.get("discountinfofestival").asText(); + try { + this.detail.eventStartDate = item.get("eventstartdate").asText().isEmpty() ? null : formatter.parse(item.get("eventstartdate").asText());; + this.detail.eventEndDate = item.get("eventenddate").asText().isEmpty() ? null : formatter.parse(item.get("eventenddate").asText());; + } catch (ParseException e) { + e.printStackTrace(); + } + this.detail.eventHomepage = item.get("eventhomepage").asText().isEmpty() ? null : item.get("eventhomepage").asText(); + this.detail.eventPlace = item.get("eventplace").asText().isEmpty() ? null : item.get("eventplace").asText(); + this.detail.festivalGrade = item.get("festivalgrade").asText().isEmpty() ? null : item.get("festivalgrade").asText(); + this.detail.placeInfo = item.get("placeinfo").asText().isEmpty() ? null : item.get("placeinfo").asText(); + this.detail.playTime = item.get("playtime").asText().isEmpty() ? null : item.get("playtime").asText(); + this.detail.program = item.get("program").asText().isEmpty() ? null : item.get("program").asText(); + this.detail.spendTime = item.get("spendtimefestival").asText().isEmpty() ? null : item.get("spendtimefestival").asText(); + this.detail.sponsor = item.get("sponsor1").asText().isEmpty() ? null : item.get("sponsor1").asText(); + this.detail.sponsorTel = item.get("sponsor1tel").asText().isEmpty() ? null : item.get("sponsor1tel").asText(); + this.detail.organizer = item.get("sponsor2").asText().isEmpty() ? null : item.get("sponsor2").asText(); + this.detail.organizerTel = item.get("sponsor2tel").asText().isEmpty() ? null : item.get("sponsor2tel").asText(); + this.detail.subEvent = item.get("subevent").asText().isEmpty() ? null : item.get("subevent").asText(); + this.detail.usageFee = item.get("usetimefestival").asText().isEmpty() ? null : item.get("usetimefestival").asText(); + }); + return this; + } + } + +} diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/LeportsAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/LeportsAttractionDetailVO.java new file mode 100644 index 0000000..49c018f --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/LeportsAttractionDetailVO.java @@ -0,0 +1,60 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class LeportsAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + private static class Detail { + private @Getter String accomodationCount; + private @Getter String babyCarriageInfo; + private @Getter String creditcardInfo; + private @Getter String allowPetInfo; + private @Getter String experienceAgeRange; + private @Getter String infoCenter; + private @Getter String openPeriod; + private @Getter String parking; + private @Getter String parkingFee; + private @Getter String reservation; + private @Getter String restDate; + private @Getter String scale; + private @Getter String usageFee; + private @Getter String hoursOfOperation; + } + + public static final class LeportsAttractionDetailVOBuilder { + public LeportsAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.accomodationCount = item.get("accomcountleports").asText().isEmpty() ? null : item.get("accomcountleports").asText(); + this.detail.babyCarriageInfo = item.get("chkbabycarriageleports").asText().isEmpty() ? null : item.get("chkbabycarriageleports").asText(); + this.detail.creditcardInfo = item.get("chkcreditcardleports").asText().isEmpty() ? null : item.get("chkcreditcardleports").asText(); + this.detail.allowPetInfo = item.get("chkpetleports").asText().isEmpty() ? null : item.get("chkpetleports").asText(); + this.detail.experienceAgeRange = item.get("expagerangeleports").asText().isEmpty() ? null : item.get("expagerangeleports").asText(); + this.detail.infoCenter = item.get("infocenterleports").asText().isEmpty() ? null : item.get("infocenterleports").asText(); + this.detail.openPeriod = item.get("openperiod").asText().isEmpty() ? null : item.get("openperiod").asText(); + this.detail.parking = item.get("parkingleports").asText().isEmpty() ? null : item.get("parkingleports").asText(); + this.detail.parkingFee = item.get("parkingfeeleports").asText().isEmpty() ? null : item.get("parkingfeeleports").asText(); + this.detail.reservation = item.get("reservation").asText().isEmpty() ? null : item.get("reservation").asText(); + this.detail.restDate = item.get("restdateleports").asText().isEmpty() ? null : item.get("restdateleports").asText(); + this.detail.scale = item.get("scaleleports").asText().isEmpty() ? null : item.get("scaleleports").asText(); + this.detail.usageFee = item.get("usefeeleports").asText().isEmpty() ? null : item.get("usefeeleports").asText(); + this.detail.hoursOfOperation = item.get("usetimeleports").asText().isEmpty() ? null : item.get("usetimeleports").asText(); + }); + return this; + } + } + +} diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/RestaurantAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/RestaurantAttractionDetailVO.java new file mode 100644 index 0000000..1e6ee2f --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/RestaurantAttractionDetailVO.java @@ -0,0 +1,60 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class RestaurantAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + private static class Detail { + public @Getter String creditcardInfo; + public @Getter String discountInfo; + public @Getter String signatureMenu; + public @Getter String infoCenter; + public @Getter String kidsFacility; + public @Getter String openDate; + public @Getter String packing; + public @Getter String parking; + public @Getter String reservation; + public @Getter String restDate; + public @Getter String scale; + public @Getter String smoking; + public @Getter String menu; + public @Getter String licenseNumber; + } + + public static final class RestaurantAttractionDetailVOBuilder { + public RestaurantAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.creditcardInfo = item.get("chkcreditcardfood").asText().isEmpty() ? null : item.get("chkcreditcardfood").asText(); + this.detail.discountInfo = item.get("discountinfofood").asText().isEmpty() ? null : item.get("discountinfofood").asText(); + this.detail.signatureMenu = item.get("firstmenu").asText().isEmpty() ? null : item.get("firstmenu").asText(); + this.detail.infoCenter = item.get("infocenterfood").asText().isEmpty() ? null : item.get("infocenterfood").asText(); + this.detail.kidsFacility = item.get("kidsfacility").asText().isEmpty() ? null : item.get("kidsfacility").asText(); + this.detail.openDate = item.get("opendatefood").asText().isEmpty() ? null : item.get("opendatefood").asText(); + this.detail.packing = item.get("packing").asText().isEmpty() ? null : item.get("packing").asText(); + this.detail.parking = item.get("parkingfood").asText().isEmpty() ? null : item.get("parkingfood").asText(); + this.detail.reservation = item.get("reservationfood").asText().isEmpty() ? null : item.get("reservationfood").asText(); + this.detail.restDate = item.get("restdatefood").asText().isEmpty() ? null : item.get("restdatefood").asText(); + this.detail.scale = item.get("scalefood").asText().isEmpty() ? null : item.get("scalefood").asText(); + this.detail.smoking = item.get("smoking").asText().isEmpty() ? null : item.get("smoking").asText(); + this.detail.menu = item.get("treatmenu").asText().isEmpty() ? null : item.get("treatmenu").asText(); + this.detail.licenseNumber = item.get("lcnsno").asText().isEmpty() ? null : item.get("lcnsno").asText(); + }); + return this; + } + } + +} diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/ShoppingAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/ShoppingAttractionDetailVO.java new file mode 100644 index 0000000..b6ab3ab --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/ShoppingAttractionDetailVO.java @@ -0,0 +1,62 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class ShoppingAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + private static class Detail { + private @Getter String babyCarriageInfo; + private @Getter String creditcardInfo; + private @Getter String allowPetInfo; + private @Getter String cultureCenterInfo; + private @Getter String fairDay; + private @Getter String infoCenter; + private @Getter String openDate; + private @Getter String openTime; + private @Getter String parking; + private @Getter String restDate; + private @Getter String restRoom; + private @Getter String saleItem; + private @Getter String saleItemCost; + private @Getter String scale; + private @Getter String shopGuide; + } + + public static final class ShoppingAttractionDetailVOBuilder { + public ShoppingAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.babyCarriageInfo = item.get("chkbabycarriageshopping").asText().isEmpty() ? null : item.get("chkbabycarriageshopping").asText(); + this.detail.creditcardInfo = item.get("chkcreditcardshopping").asText().isEmpty() ? null : item.get("chkcreditcardshopping").asText(); + this.detail.allowPetInfo = item.get("chkpetshopping").asText().isEmpty() ? null : item.get("chkpetshopping").asText(); + this.detail.cultureCenterInfo = item.get("culturecenter").asText().isEmpty() ? null : item.get("culturecenter").asText(); + this.detail.fairDay = item.get("fairday").asText().isEmpty() ? null : item.get("fairday").asText(); + this.detail.infoCenter = item.get("infocentershopping").asText().isEmpty() ? null : item.get("infocentershopping").asText(); + this.detail.openDate = item.get("opendateshopping").asText().isEmpty() ? null : item.get("opendateshopping").asText(); + this.detail.openTime = item.get("opentime").asText().isEmpty() ? null : item.get("opentime").asText(); + this.detail.parking = item.get("parkingshopping").asText().isEmpty() ? null : item.get("parkingshopping").asText(); + this.detail.restDate = item.get("restdateshopping").asText().isEmpty() ? null : item.get("restdateshopping").asText(); + this.detail.restRoom = item.get("restroom").asText().isEmpty() ? null : item.get("restroom").asText(); + this.detail.saleItem = item.get("saleitem").asText().isEmpty() ? null : item.get("saleitem").asText(); + this.detail.saleItemCost = item.get("saleitemcost").asText().isEmpty() ? null : item.get("saleitemcost").asText(); + this.detail.scale = item.get("scaleshopping").asText().isEmpty() ? null : item.get("scaleshopping").asText(); + this.detail.shopGuide = item.get("shopguide").asText().isEmpty() ? null : item.get("shopguide").asText(); + }); + return this; + } + } + +} diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/StayAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/StayAttractionDetailVO.java new file mode 100644 index 0000000..31812cb --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/StayAttractionDetailVO.java @@ -0,0 +1,92 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class StayAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + private static class Detail { + private @Getter String accomodationCount; + private @Getter boolean benikia; + private @Getter String checkInTime; + private @Getter String checkOutTime; + private @Getter String cookingInfo; + private @Getter String foodPlace; + private @Getter boolean goodStay; + private @Getter boolean hanok; + private @Getter String infoCenter; + private @Getter String parking; + private @Getter String pickup; + private @Getter String roomCount; + private @Getter String reservation; + private @Getter String reservationUrl; + private @Getter String roomType; + private @Getter String scale; + private @Getter String subFacility; + private @Getter boolean barbecue; + private @Getter boolean beautyFacility; + private @Getter boolean beverage; + private @Getter boolean bicycleRent; + private @Getter boolean campfire; + private @Getter boolean fitness; + private @Getter boolean karaoke; + private @Getter boolean publicBath; + private @Getter boolean publicPC; + private @Getter boolean sauna; + private @Getter boolean seminar; + private @Getter boolean sports; + private @Getter String refundPolicy; + } + + public static final class StayAttractionDetailVOBuilder { + public StayAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.accomodationCount = item.get("accomcountlodging").asText().isEmpty() ? null : item.get("accomcountlodging").asText(); + this.detail.benikia = item.get("benikia").asText().equals("1"); + this.detail.checkInTime = item.get("checkintime").asText().isEmpty() ? null : item.get("checkintime").asText(); + this.detail.checkOutTime = item.get("checkouttime").asText().isEmpty() ? null : item.get("checkouttime").asText(); + this.detail.cookingInfo = item.get("chkcooking").asText().isEmpty() ? null : item.get("chkcooking").asText(); + this.detail.foodPlace = item.get("foodplace").asText().isEmpty() ? null : item.get("foodplace").asText(); + this.detail.goodStay = item.get("goodstay").asText().equals("1"); + this.detail.hanok = item.get("hanok").asText().equals("1"); + this.detail.infoCenter = item.get("infocenterlodging").asText().isEmpty() ? null : item.get("infocenterlodging").asText(); + this.detail.parking = item.get("parkinglodging").asText().isEmpty() ? null : item.get("parkinglodging").asText(); + this.detail.pickup = item.get("pickup").asText().isEmpty() ? null : item.get("pickup").asText(); + this.detail.roomCount = item.get("roomcount").asText().isEmpty() ? null : item.get("roomcount").asText(); + this.detail.reservation = item.get("reservationlodging").asText().isEmpty() ? null : item.get("reservationlodging").asText(); + this.detail.reservationUrl = item.get("reservationurl").asText().isEmpty() ? null : item.get("reservationurl").asText(); + this.detail.roomType = item.get("roomtype").asText().isEmpty() ? null : item.get("roomtype").asText(); + this.detail.scale = item.get("scalelodging").asText().isEmpty() ? null : item.get("scalelodging").asText(); + this.detail.subFacility = item.get("subfacility").asText().isEmpty() ? null : item.get("subfacility").asText(); + this.detail.barbecue = item.get("barbecue").asText().equals("1"); + this.detail.beautyFacility = item.get("beauty").asText().equals("1"); + this.detail.beverage = item.get("beverage").asText().equals("1"); + this.detail.bicycleRent = item.get("bicycle").asText().equals("1"); + this.detail.campfire = item.get("campfire").asText().equals("1"); + this.detail.fitness = item.get("fitness").asText().equals("1"); + this.detail.karaoke = item.get("karaoke").asText().equals("1"); + this.detail.publicBath = item.get("publicbath").asText().equals("1"); + this.detail.publicPC = item.get("publicpc").asText().equals("1"); + this.detail.sauna = item.get("sauna").asText().equals("1"); + this.detail.seminar = item.get("seminar").asText().equals("1"); + this.detail.sports = item.get("sports").asText().equals("1"); + this.detail.refundPolicy = item.get("refundregulation").asText().isEmpty() ? null : item.get("refundregulation").asText(); + }); + return this; + } + } + +} diff --git a/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/TourAttractionDetailVO.java b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/TourAttractionDetailVO.java new file mode 100644 index 0000000..a509735 --- /dev/null +++ b/src/main/java/org/routemaster/api/total/infra/tourapi/vo/detail/TourAttractionDetailVO.java @@ -0,0 +1,69 @@ +package org.routemaster.api.total.infra.tourapi.vo.detail; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.*; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@Builder +@Getter +@ToString +public class TourAttractionDetailVO { + + private @Getter String resultCode; + private @Getter String resultMessage; + private @Getter Integer numOfRows; + private @Getter Integer pageNo; + private @Getter Integer totalCount; + private @Getter Detail detail; + + + private static class Detail { + private @Getter Integer contentId; + private @Getter Integer contentTypeId; + private @Getter Integer accomodationCount; + private @Getter String babyCarriageInfo; + private @Getter String creditcardInfo; + private @Getter String allowPetInfo; + private @Getter String experienceAgeRange; + private @Getter String experienceGuide; + private @Getter boolean cultureHeritage; + private @Getter boolean NatureHeritage; + private @Getter boolean recordHeritage; + private @Getter String infoCenter; + private @Getter String openDate; + private @Getter String parking; + private @Getter String restDate; + private @Getter String seasonsOfOperation; + private @Getter String hoursOfOperation; + } + + public final static class TourAttractionDetailVOBuilder { + + public TourAttractionDetailVOBuilder builder(JsonNode jsonNode) { + this.detail = new Detail(); + jsonNode.get("items").get("item").forEach(item -> { + this.detail.contentId = item.get("contentid").asInt(); + this.detail.contentTypeId = item.get("contenttypeid").asInt(); + this.detail.accomodationCount = item.get("accomcount").asText().isEmpty() ? null : item.get("accomCount").asInt(); + this.detail.babyCarriageInfo = item.get("chkbabycarriage").asText().isEmpty() ? null : item.get("chkbabycarriage").asText(); + this.detail.creditcardInfo = item.get("chkcreditcard").asText().isEmpty() ? null : item.get("chkcreditcard").asText(); + this.detail.allowPetInfo = item.get("chkpet").asText().isEmpty() ? null : item.get("chkpet").asText(); + this.detail.experienceAgeRange = item.get("expguide").asText().isEmpty() ? null : item.get("expguide").asText(); + this.detail.experienceGuide = item.get("expguide").asText().isEmpty() ? null : item.get("expguide").asText(); + this.detail.cultureHeritage = item.get("heritage1").asText().equals("1"); + this.detail.NatureHeritage = item.get("heritage2").asText().equals("1"); + this.detail.recordHeritage = item.get("heritage3").asText().equals("1"); + this.detail.infoCenter = item.get("infocenter").asText().isEmpty() ? null : item.get("infocenter").asText(); + this.detail.openDate = item.get("opendate").asText().isEmpty() ? null : item.get("opendate").asText(); + this.detail.parking = item.get("parking").asText().isEmpty() ? null : item.get("parking").asText(); + this.detail.restDate = item.get("restdate").asText().isEmpty() ? null : item.get("restdate").asText(); + this.detail.seasonsOfOperation = item.get("useseason").asText().isEmpty() ? null : item.get("useseason").asText(); + this.detail.hoursOfOperation = item.get("usetime").asText().isEmpty() ? null : item.get("usetime").asText(); + }); + return this; + } + + } + +}