Skip to content

Commit

Permalink
#2 - Feat: Add Location based Search basic MVCs
Browse files Browse the repository at this point in the history
  • Loading branch information
eun61n00 committed Jun 13, 2023
1 parent d476441 commit bb7fb70
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package org.routemaster.api.total.domain.air.controller;public class BookingController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.routemaster.api.total.domain.attraction.controller;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.routemaster.api.total.domain.attraction.service.AttractionSearchService;
import org.springframework.http.HttpStatus;
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-search")
@RequiredArgsConstructor
public class AttractionSearchRestController {

private final AttractionSearchService attractionSearchService;

@GetMapping("/location-based")
public ResponseEntity<Mono<JsonNode>> locationBase(
@RequestParam(required = false) Integer numOfRows,
@RequestParam(required = false) Integer pageNo,
@RequestParam String MobileOS,
@RequestParam String MobileApp,
@RequestParam(required = false) String _type,
@RequestParam(required = false) String listYN,
@RequestParam(required = false) String arrange,
@RequestParam Double mapX,
@RequestParam Double mapY,
@RequestParam Integer radius,
@RequestParam(required = false) Integer contentTypeId,
@RequestParam(required = false) String modifiedTime
) {
Mono<JsonNode> result = attractionSearchService.searchLocationBasedAttraction(
numOfRows,
pageNo,
MobileOS,
MobileApp,
_type,
listYN,
arrange,
mapX,
mapY,
radius,
contentTypeId,
modifiedTime
);
return new ResponseEntity<>(result, HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.routemaster.api.total.domain.attraction.service;

import com.fasterxml.jackson.databind.JsonNode;
import reactor.core.publisher.Mono;

public interface AttractionSearchService {

Mono<JsonNode> searchLocationBasedAttraction(
Integer numOfRows,
Integer pageNo,
String MobileOS,
String MobileApp,
String _type,
String listYN,
String arrange,
Double mapX,
Double mapY,
Integer radius,
Integer contentTypeId,
String modifiedtime
);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package org.routemaster.api.total.domain.attraction.service.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
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.AttractionSearchService;
import org.routemaster.api.total.infra.tourapi.value.TourAPI;
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;


@Slf4j
@Service
public class DefaultAttractionSearchService implements AttractionSearchService {

@Override
public Mono<JsonNode> searchLocationBasedAttraction(
Integer numOfRows,
Integer pageNo,
String MobileOS,
String MobileApp,
String _type,
String listYN,
String arrange,
Double mapX,
Double mapY,
Integer radius,
Integer contentTypeId,
String modifiedtime
) {
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<JsonNode> result = webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/locationBasedList1")
.queryParam("serviceKey", TourAPI.encodingKey)
.queryParam("MobileOS", MobileOS)
.queryParam("MobileApp", MobileApp)
.queryParam("mapX", mapX)
.queryParam("mapY", mapY)
.queryParam("radius", radius)
.queryParam("_type", "json")
.queryParam("numOfRows", numOfRows)
.queryParam("pageNo", pageNo)
.queryParam("listYN", listYN)
.queryParam("arrange", arrange)
.queryParam("contentTypeId", contentTypeId)
.queryParam("modifiedtime", modifiedtime)
.build()
)
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.bodyToMono(String.class)
.map(str -> {
ObjectMapper objectMapper = new ObjectMapper();
try {
return mapper.readTree(str);

} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
);
return result;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.routemaster.api.total.infra.amadeus.vo;

public class FlightOrdersVO {

com.amadeus.booking.FlightOrders
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.routemaster.api.total.infra.amadeus.vo;

import lombok.*;

//@NoArgsConstructor(access = AccessLevel.PROTECTED)
//@AllArgsConstructor(access = AccessLevel.PROTECTED)
//@Builder
//@Getter
//@ToString
//public class FlightOfferPriceVO {
// public static final class FlightOfferPriceVOBuilder {
// public FlightOfferPriceVOBuilder flightOfferPrice() {
// return this;
// }
// }
//
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.routemaster.api.total.infra.tourapi.value;

import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Getter
public class TourAPI{

public static String baseUrl;
public static String encodingKey;
public static String decodingKey;


@Value("${tour-api.end-point}")
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}

@Value("${tour-api.encoding-key}")
public void setEncodingKey(String encodingKey) {
this.encodingKey = encodingKey;
}

@Value("${tour-api.decoding-key}")
public void setDecodingKey(String decodingKey) {
this.decodingKey = decodingKey;
}

}
8 changes: 8 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
spring:
config:
import:
- dev/amadeus.yml
- dev/tour-api.yml
jackson:
default-property-inclusion: non_null

temp-string: prod

0 comments on commit bb7fb70

Please sign in to comment.