-
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 #66 from tukcomCD2024/backend/feature/25-amadeus-api
Backend/feature/25 amadeus api
- Loading branch information
Showing
32 changed files
with
758 additions
and
267 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
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
36 changes: 36 additions & 0 deletions
36
backend/src/main/java/com/isp/backend/domain/flight/dto/request/FlightLikeRequest.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,36 @@ | ||
package com.isp.backend.domain.flight.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
public class FlightLikeRequest { | ||
|
||
private String carrierCode; | ||
|
||
private int totalPrice; | ||
|
||
private String abroadDuration; | ||
|
||
private String abroadDepartureTime; | ||
|
||
private String abroadArrivalTime; | ||
|
||
private String homeDuration; | ||
|
||
private String homeDepartureTime; | ||
|
||
private String homeArrivalTime; | ||
|
||
private String departureIataCode; | ||
|
||
private String arrivalIataCode; | ||
|
||
private String transferCount; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/com/isp/backend/domain/flight/dto/request/SkyScannerRequest.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,28 @@ | ||
package com.isp.backend.domain.flight.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class SkyScannerRequest { | ||
|
||
private String departureIataCode; | ||
|
||
private String arrivalIataCode; | ||
|
||
private String departureDate; | ||
|
||
private String returnDate; | ||
|
||
private int adults; | ||
|
||
private int children; | ||
|
||
private String departureTime; | ||
|
||
private int transferCount; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/main/java/com/isp/backend/domain/flight/dto/response/FlightLikeResponse.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,38 @@ | ||
package com.isp.backend.domain.flight.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
public class FlightLikeResponse { | ||
|
||
private Long id; | ||
|
||
private String carrierCode; | ||
|
||
private int totalPrice; | ||
|
||
private String abroadDuration; | ||
|
||
private String abroadDepartureTime; | ||
|
||
private String abroadArrivalTime; | ||
|
||
private String homeDuration; | ||
|
||
private String homeDepartureTime; | ||
|
||
private String homeArrivalTime; | ||
|
||
private String departureIataCode; | ||
|
||
private String arrivalIataCode; | ||
|
||
private String transferCount; | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
backend/src/main/java/com/isp/backend/domain/flight/entity/Flight.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 |
---|---|---|
@@ -1,4 +1,53 @@ | ||
package com.isp.backend.domain.flight.entity; | ||
|
||
import com.isp.backend.domain.country.entity.Country; | ||
import com.isp.backend.domain.member.entity.Member; | ||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@Entity | ||
@Builder | ||
@NoArgsConstructor | ||
@Table(name = "flight") | ||
public class Flight { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id ; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id", nullable = false) | ||
private Member member; | ||
|
||
private String carrierCode ; | ||
|
||
private Double price ; | ||
|
||
private String abroadDuration ; | ||
|
||
private String abroadDepartureTime ; // 출국-출발 | ||
|
||
private String abroadArrivalTime ; // 출국-도착 | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "departure_iata_code_id") | ||
private Country departureIataCode ; | ||
|
||
private String homeDuration ; | ||
|
||
private String homeDepartureTime ; // 입국-출발 | ||
|
||
private String homeArrivalTime ; // 입국-도착 | ||
@ManyToOne | ||
@JoinColumn(name = "arrival_iata_code_id") | ||
private Country arrivalIataCode ; | ||
|
||
private int transferCount ; | ||
|
||
|
||
} |
4 changes: 0 additions & 4 deletions
4
backend/src/main/java/com/isp/backend/domain/flight/entity/FlightBooking.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
backend/src/main/java/com/isp/backend/domain/flight/mapper/FlightMapper.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,57 @@ | ||
package com.isp.backend.domain.flight.mapper; | ||
|
||
import com.isp.backend.domain.country.entity.Country; | ||
import com.isp.backend.domain.flight.dto.request.FlightLikeRequest; | ||
import com.isp.backend.domain.flight.dto.response.FlightLikeResponse; | ||
import com.isp.backend.domain.flight.entity.Flight; | ||
import com.isp.backend.domain.member.entity.Member; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class FlightMapper { | ||
|
||
public Flight toEntity(FlightLikeRequest request, Member member, Country departureIataCode, Country arrivalIataCode) { | ||
return Flight.builder() | ||
.member(member) // 주입된 member 객체 사용 | ||
.carrierCode(request.getCarrierCode()) | ||
.price((double) request.getTotalPrice()) | ||
.abroadDuration(request.getAbroadDuration()) | ||
.abroadDepartureTime(request.getAbroadDepartureTime()) | ||
.abroadArrivalTime(request.getAbroadArrivalTime()) | ||
.homeDuration(request.getHomeDuration()) | ||
.homeDepartureTime(request.getHomeDepartureTime()) | ||
.homeArrivalTime(request.getHomeArrivalTime()) | ||
.departureIataCode(departureIataCode) | ||
.arrivalIataCode(arrivalIataCode) | ||
.transferCount(Integer.parseInt(request.getTransferCount())) | ||
.build(); | ||
} | ||
|
||
public FlightLikeResponse toFlightLikeRequest(Flight flight) { | ||
FlightLikeResponse response = new FlightLikeResponse(); | ||
response.setId(flight.getId()); | ||
response.setCarrierCode(flight.getCarrierCode()); | ||
response.setTotalPrice((int) Math.round(flight.getPrice())); | ||
response.setAbroadDuration(flight.getAbroadDuration()); | ||
response.setAbroadDepartureTime(flight.getAbroadDepartureTime()); | ||
response.setAbroadArrivalTime(flight.getAbroadArrivalTime()); | ||
response.setHomeDuration(flight.getHomeDuration()); | ||
response.setHomeDepartureTime(flight.getHomeDepartureTime()); | ||
response.setHomeArrivalTime(flight.getHomeArrivalTime()); | ||
response.setDepartureIataCode(flight.getDepartureIataCode().getAirportCode()); | ||
response.setArrivalIataCode(flight.getArrivalIataCode().getAirportCode()); | ||
response.setTransferCount(String.valueOf(flight.getTransferCount())); | ||
return response; | ||
} | ||
|
||
public List<FlightLikeResponse> toFlightLikeRequestList(List<Flight> flights) { | ||
return flights.stream() | ||
.map(this::toFlightLikeRequest) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
} |
Oops, something went wrong.