Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ject2 into feature/readme
  • Loading branch information
JeongUijeong committed Nov 1, 2023
2 parents e5b3b84 + 8bccdf5 commit 8e10533
Show file tree
Hide file tree
Showing 13 changed files with 354 additions and 202 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [DB 설계](#DB-설계)
- [API 설계](#API-설계)
- [개발 내용](#개발-내용)
- [실행 결과 캡처](#실행-결과-캡처)
- [API 문서](#API-문서)

---
Expand Down Expand Up @@ -94,7 +95,7 @@

---

## 실행결과 캡처
## 실행 결과 캡처

> `Console`
> ![](src/main/resources/image/console.png)
Expand All @@ -120,4 +121,4 @@
> ![](src/main/resources/image/api_docs_trip.png)
>
> `Itinerary API Docs`
> ![](src/main/resources/image/api_docs_itinerary.png)
> ![](src/main/resources/image/api_docs_itinerary.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.fc.toy_project2.domain.itinerary.entity;

import com.fc.toy_project2.domain.itinerary.dto.response.AccommodationResponseDTO;
import com.fc.toy_project2.domain.trip.entity.Trip;
import com.fc.toy_project2.global.util.DateTypeFormatterUtil;
import jakarta.persistence.Entity;
import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

@Getter
@NoArgsConstructor
@Entity
public class Accommodation extends Itinerary{

private String accommodationName;

private String accommodationRoadAddressName;

private LocalDateTime checkIn;

private LocalDateTime checkOut;

@Builder
public Accommodation(Long id, Trip trip, String itineraryName, String accommodationName, String accommodationRoadAddressName,
LocalDateTime checkIn, LocalDateTime checkOut) {
super(id, trip, itineraryName);
this.accommodationName = accommodationName;
this.accommodationRoadAddressName = accommodationRoadAddressName;
this.checkIn = checkIn;
this.checkOut = checkOut;
}

public AccommodationResponseDTO toAccommodationResponseDTO() {
return AccommodationResponseDTO.builder().itineraryId(super.getId())
.itineraryName(super.getItineraryName()).accommodationName(this.accommodationName)
.accommodationRoadAddressName(this.accommodationRoadAddressName)
.checkIn(DateTypeFormatterUtil.localDateTimeToString(this.checkIn))
.checkOut(DateTypeFormatterUtil.localDateTimeToString(this.checkOut)).build();
}

public void updateAccommodationInfo(String itineraryName, String accommodationName,
String accommodationRoadAddressName, LocalDateTime checkIn, LocalDateTime checkOut) {
super.updateItineraryName(itineraryName);
this.accommodationName = accommodationName;
this.accommodationRoadAddressName = accommodationRoadAddressName;
this.checkIn = checkIn;
this.checkOut = checkOut;
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
package com.fc.toy_project2.domain.itinerary.entity;

import com.fc.toy_project2.domain.itinerary.dto.response.AccommodationResponseDTO;
import com.fc.toy_project2.domain.itinerary.dto.response.TransportationResponseDTO;
import com.fc.toy_project2.domain.itinerary.dto.response.VisitResponseDTO;
import com.fc.toy_project2.domain.trip.entity.Trip;
import com.fc.toy_project2.global.util.DateTypeFormatterUtil;
import jakarta.persistence.DiscriminatorColumn;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.Comment;

@SuperBuilder
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
public class Itinerary {
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type")
public abstract class Itinerary {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -33,100 +31,15 @@ public class Itinerary {
@JoinColumn(name = "trip_id")
private Trip trip;

@Comment("0: Accommodation, 1: Transportation, 2: Visit")
private int type;

private String itineraryName;

/**
* 숙박
**/
private String accommodationName;

private String accommodationRoadAddressName;

private LocalDateTime checkIn;

private LocalDateTime checkOut;

/**
* 이동
**/
private String transportation;

private String departurePlace;

private String departurePlaceRoadAddressName;

private String destination;

private String destinationRoadAddressName;

/**
* 체류
**/
private String placeName;

private String placeRoadAddressName;

private LocalDateTime arrivalTime;

private LocalDateTime departureTime;

public AccommodationResponseDTO toAccommodationResponseDTO() {
return AccommodationResponseDTO.builder().itineraryId(this.id)
.itineraryName(this.itineraryName).accommodationName(this.accommodationName)
.accommodationRoadAddressName(this.accommodationRoadAddressName)
.checkIn(DateTypeFormatterUtil.localDateTimeToString(this.checkIn))
.checkOut(DateTypeFormatterUtil.localDateTimeToString(this.checkOut)).build();
}

public TransportationResponseDTO toTransportationResponseDTO() {
return TransportationResponseDTO.builder().itineraryId(this.id)
.itineraryName(this.itineraryName).transportation(this.transportation)
.departurePlace(this.departurePlace)
.departurePlaceRoadAddressName(this.departurePlaceRoadAddressName)
.destination(this.destination)
.destinationRoadAddressName(this.destinationRoadAddressName)
.departureTime(DateTypeFormatterUtil.localDateTimeToString(this.departureTime))
.arrivalTime(DateTypeFormatterUtil.localDateTimeToString(this.arrivalTime)).build();
}

public VisitResponseDTO toVisitResponseDTO() {
return VisitResponseDTO.builder().itineraryId(this.id).itineraryName(this.itineraryName)
.placeName(this.placeName).placeRoadAddressName(this.placeRoadAddressName)
.departureTime(DateTypeFormatterUtil.localDateTimeToString(this.departureTime))
.arrivalTime(DateTypeFormatterUtil.localDateTimeToString(this.arrivalTime)).build();
}

public void updateAccommodationInfo(String itineraryName, String accommodationName,
String accommodationRoadAddressName, LocalDateTime checkIn, LocalDateTime checkOut) {
this.itineraryName = itineraryName;
this.accommodationName = accommodationName;
this.accommodationRoadAddressName = accommodationRoadAddressName;
this.checkIn = checkIn;
this.checkOut = checkOut;
}

public void updateTransportationInfo(String itineraryName, String transportation,
String departurePlace, String departurePlaceRoadAddressName, String destination,
String destinationRoadAddressName, LocalDateTime departureTime, LocalDateTime arrivalTime) {
public Itinerary(Long id, Trip trip, String itineraryName) {
this.id = id;
this.trip = trip;
this.itineraryName = itineraryName;
this.transportation = transportation;
this.departurePlace = departurePlace;
this.departurePlaceRoadAddressName = departurePlaceRoadAddressName;
this.destination = destination;
this.destinationRoadAddressName = destinationRoadAddressName;
this.departureTime = departureTime;
this.arrivalTime = arrivalTime;
}

public void updateVisitInfo(String itineraryName, String placeName, String placeRoadAddressName,
LocalDateTime visitDepartureTime, LocalDateTime visitArrivalTime) {
protected void updateItineraryName(String itineraryName) {
this.itineraryName = itineraryName;
this.placeName = placeName;
this.placeRoadAddressName = placeRoadAddressName;
this.departureTime = visitDepartureTime;
this.arrivalTime = visitArrivalTime;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.fc.toy_project2.domain.itinerary.entity;

import com.fc.toy_project2.domain.itinerary.dto.response.TransportationResponseDTO;
import com.fc.toy_project2.domain.trip.entity.Trip;
import com.fc.toy_project2.global.util.DateTypeFormatterUtil;
import jakarta.persistence.Entity;
import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@Entity
public class Transportation extends Itinerary{

private String transportation;

private String departurePlace;

private String departurePlaceRoadAddressName;

private String destination;

private String destinationRoadAddressName;

private LocalDateTime arrivalTime;

private LocalDateTime departureTime;

@Builder
public Transportation(Long id, Trip trip, String itineraryName, String transportation, String departurePlace,
String departurePlaceRoadAddressName, String destination, String destinationRoadAddressName,
LocalDateTime arrivalTime, LocalDateTime departureTime) {
super(id, trip, itineraryName);
this.transportation = transportation;
this.departurePlace = departurePlace;
this.departurePlaceRoadAddressName = departurePlaceRoadAddressName;
this.destination = destination;
this.destinationRoadAddressName = destinationRoadAddressName;
this.arrivalTime = arrivalTime;
this.departureTime = departureTime;
}

public TransportationResponseDTO toTransportationResponseDTO() {
return TransportationResponseDTO.builder().itineraryId(super.getId())
.itineraryName(super.getItineraryName()).transportation(this.transportation)
.departurePlace(this.departurePlace)
.departurePlaceRoadAddressName(this.departurePlaceRoadAddressName)
.destination(this.destination)
.destinationRoadAddressName(this.destinationRoadAddressName)
.departureTime(DateTypeFormatterUtil.localDateTimeToString(this.departureTime))
.arrivalTime(DateTypeFormatterUtil.localDateTimeToString(this.arrivalTime)).build();
}

public void updateTransportationInfo(String itineraryName, String transportation,
String departurePlace, String departurePlaceRoadAddressName, String destination,
String destinationRoadAddressName, LocalDateTime departureTime, LocalDateTime arrivalTime) {
super.updateItineraryName(itineraryName);
this.transportation = transportation;
this.departurePlace = departurePlace;
this.departurePlaceRoadAddressName = departurePlaceRoadAddressName;
this.destination = destination;
this.destinationRoadAddressName = destinationRoadAddressName;
this.departureTime = departureTime;
this.arrivalTime = arrivalTime;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.fc.toy_project2.domain.itinerary.entity;

import com.fc.toy_project2.domain.itinerary.dto.response.VisitResponseDTO;
import com.fc.toy_project2.domain.trip.entity.Trip;
import com.fc.toy_project2.global.util.DateTypeFormatterUtil;
import jakarta.persistence.Entity;
import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@Entity
public class Visit extends Itinerary {

private String placeName;

private String placeRoadAddressName;

private LocalDateTime arrivalTime;

private LocalDateTime departureTime;

@Builder
public Visit(Long id, Trip trip, String itineraryName, String placeName, String placeRoadAddressName, LocalDateTime arrivalTime,
LocalDateTime departureTime) {
super(id, trip, itineraryName);
this.placeName = placeName;
this.placeRoadAddressName = placeRoadAddressName;
this.arrivalTime = arrivalTime;
this.departureTime = departureTime;
}

public VisitResponseDTO toVisitResponseDTO() {
return VisitResponseDTO.builder().itineraryId(super.getId())
.itineraryName(super.getItineraryName()).placeName(this.placeName)
.placeRoadAddressName(this.placeRoadAddressName)
.departureTime(DateTypeFormatterUtil.localDateTimeToString(this.departureTime))
.arrivalTime(DateTypeFormatterUtil.localDateTimeToString(this.arrivalTime)).build();
}

public void updateVisitInfo(String itineraryName, String placeName, String placeRoadAddressName,
LocalDateTime visitDepartureTime, LocalDateTime visitArrivalTime) {
super.updateItineraryName(itineraryName);
this.placeName = placeName;
this.placeRoadAddressName = placeRoadAddressName;
this.departureTime = visitDepartureTime;
this.arrivalTime = visitArrivalTime;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.fc.toy_project2.domain.itinerary.repository;

import com.fc.toy_project2.domain.itinerary.entity.Accommodation;
import com.fc.toy_project2.domain.itinerary.entity.Itinerary;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AccommodationRepository extends JpaRepository<Accommodation, Long> {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.fc.toy_project2.domain.itinerary.repository;

import com.fc.toy_project2.domain.itinerary.entity.Accommodation;
import com.fc.toy_project2.domain.itinerary.entity.Transportation;
import org.springframework.data.jpa.repository.JpaRepository;

public interface TransportationRepository extends JpaRepository<Transportation, Long> {

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.fc.toy_project2.domain.itinerary.repository;

import com.fc.toy_project2.domain.itinerary.entity.Accommodation;
import com.fc.toy_project2.domain.itinerary.entity.Visit;
import org.springframework.data.jpa.repository.JpaRepository;

public interface VisitRepository extends JpaRepository<Visit, Long> {

}

Loading

0 comments on commit 8e10533

Please sign in to comment.