-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from tukcomCD2024/backend/feature/67-amadeus-h…
…otel [Backend] feat : 편도 항공권 조회, 좌표로 호텔 조회 API 추가
- Loading branch information
Showing
6 changed files
with
131 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 28 additions & 2 deletions
30
backend/src/main/java/com/isp/backend/domain/hotel/controller/HotelController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/com/isp/backend/domain/hotel/service/HotelService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.isp.backend.domain.hotel.service; | ||
|
||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.Hotel; | ||
import com.isp.backend.domain.hotel.dto.request.SearchGeocodeRequest; | ||
|
||
public interface HotelService { | ||
public String searchHotelsByGeocode(SearchGeocodeRequest request) throws ResponseException; | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
backend/src/main/java/com/isp/backend/domain/hotel/service/HotelServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.isp.backend.domain.hotel.service; | ||
|
||
import com.amadeus.Amadeus; | ||
import com.amadeus.Params; | ||
import com.amadeus.exceptions.ResponseException; | ||
import com.amadeus.resources.Hotel; | ||
import com.amadeus.shopping.HotelOffersSearch; | ||
import com.google.gson.Gson; | ||
import com.isp.backend.domain.hotel.dto.request.SearchGeocodeRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
@Service | ||
public class HotelServiceImpl implements HotelService { | ||
private final Amadeus amadeus; | ||
|
||
/** | ||
* 좌표 주변 호텔 리스트 API | ||
**/ | ||
@Override | ||
public String searchHotelsByGeocode(SearchGeocodeRequest request) throws ResponseException { | ||
String latitude = request.getLatitude(); | ||
String longitude = request.getLongitude(); | ||
int radius = request.getRadius(); | ||
String ratings = request.getRatings(); | ||
|
||
Hotel[] hotelSearch = amadeus.referenceData.locations.hotels.byGeocode.get( | ||
Params.with("latitude", latitude) | ||
.and("longitude", longitude) | ||
.and("radius", radius) | ||
.and("radiusUnit", "KM") | ||
.and("ratings", ratings) | ||
.and("hotelSource", "ALL") | ||
); | ||
Gson gson = new Gson(); | ||
String hotelSearchJson = gson.toJson(hotelSearch); | ||
return hotelSearchJson; | ||
} | ||
|
||
|
||
} |