-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
706 additions
and
74 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/main/java/com/fc/toy_project2/domain/itinerary/controller/ItineraryPatchController.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,50 @@ | ||
package com.fc.toy_project2.domain.itinerary.controller; | ||
|
||
import com.fc.toy_project2.domain.itinerary.dto.request.createDTO.ItineraryAccommodationCreateDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.request.createDTO.ItineraryTransportationCreateDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.request.createDTO.ItineraryVisitCreateDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.request.patchDTO.ItineraryAccommodationPatchDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.request.patchDTO.ItineraryVisitPatchDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.request.patchDTO.ItineraryTransportationPatchDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.response.ItineraryAccommodationResponseDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.response.ItineraryTransportationResponseDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.response.ItineraryVisitResponseDTO; | ||
import com.fc.toy_project2.domain.itinerary.service.ItineraryPostUpdateService; | ||
import com.fc.toy_project2.global.DTO.ResponseDTO; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/itinerary") | ||
public class ItineraryPatchController { | ||
|
||
private final ItineraryPostUpdateService itinerarypostUpdateService; | ||
|
||
@PatchMapping("/accommodation/{tripId}/{itineraryId}") | ||
public ResponseEntity<ResponseDTO<ItineraryAccommodationResponseDTO>> updateAccommodation(@PathVariable Long tripId, @PathVariable Long itineraryId, | ||
@Valid @RequestBody ItineraryAccommodationPatchDTO ItineraryAccommodationPatchDTO) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDTO.res(HttpStatus.OK, | ||
itinerarypostUpdateService.patchAccommodation(ItineraryAccommodationPatchDTO, tripId, itineraryId), | ||
"숙박 여정을 성공적으로 수정했습니다.")); | ||
} | ||
|
||
@PatchMapping("/transportation/{tripId}/{itineraryId}") | ||
public ResponseEntity<ResponseDTO<ItineraryTransportationResponseDTO>> updateTransportation(@PathVariable Long tripId, @PathVariable Long itineraryId, | ||
@Valid @RequestBody ItineraryTransportationPatchDTO itineraryTransportationPatchDTO) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDTO.res(HttpStatus.OK, | ||
itinerarypostUpdateService.patchTransportation(itineraryTransportationPatchDTO, tripId, itineraryId), | ||
"이동 여정을 성공적으로 수정했습니다.")); | ||
} | ||
|
||
@PatchMapping("/visit/{tripId}/{itineraryId}") | ||
public ResponseEntity<ResponseDTO<ItineraryVisitResponseDTO>> updateVisit(@PathVariable Long tripId, @PathVariable Long itineraryId, | ||
@Valid @RequestBody ItineraryVisitPatchDTO itineraryVisitPatchDTO) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDTO.res(HttpStatus.OK, | ||
itinerarypostUpdateService.patchVisit(itineraryVisitPatchDTO, tripId, itineraryId), | ||
"체류 여정을 성공적으로 수정했습니다.")); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/com/fc/toy_project2/domain/itinerary/controller/ItineraryPostController.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,48 @@ | ||
package com.fc.toy_project2.domain.itinerary.controller; | ||
|
||
import com.fc.toy_project2.domain.itinerary.dto.request.createDTO.ItineraryAccommodationCreateDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.request.createDTO.ItineraryTransportationCreateDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.request.createDTO.ItineraryVisitCreateDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.response.ItineraryAccommodationResponseDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.response.ItineraryTransportationResponseDTO; | ||
import com.fc.toy_project2.domain.itinerary.dto.response.ItineraryVisitResponseDTO; | ||
import com.fc.toy_project2.domain.itinerary.service.ItineraryPostUpdateService; | ||
import com.fc.toy_project2.global.DTO.ResponseDTO; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/itinerary") | ||
public class ItineraryPostController { | ||
|
||
private final ItineraryPostUpdateService itinerarypostUpdateService; | ||
|
||
|
||
@PostMapping("/accommodation/{tripId}") | ||
public ResponseEntity<ResponseDTO<ItineraryAccommodationResponseDTO>> createAccommodation(@PathVariable Long tripId, | ||
@Valid @RequestBody ItineraryAccommodationCreateDTO itineraryAccommodationCreateDTO) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDTO.res(HttpStatus.CREATED, | ||
itinerarypostUpdateService.createAccommodation(itineraryAccommodationCreateDTO, tripId), | ||
"숙박 여정을 성공적으로 등록했습니다.")); | ||
} | ||
|
||
@PostMapping("/transportation/{tripId}") | ||
public ResponseEntity<ResponseDTO<ItineraryTransportationResponseDTO>> createTransportation(@PathVariable Long tripId, | ||
@Valid @RequestBody ItineraryTransportationCreateDTO itineraryTransportationCreateDTO) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDTO.res(HttpStatus.CREATED, | ||
itinerarypostUpdateService.createTransportation(itineraryTransportationCreateDTO, tripId), | ||
"이동 여정을 성공적으로 등록했습니다.")); | ||
} | ||
|
||
@PostMapping("/visit/{tripId}") | ||
public ResponseEntity<ResponseDTO<ItineraryVisitResponseDTO>> createVisit(@PathVariable Long tripId, | ||
@Valid @RequestBody ItineraryVisitCreateDTO itineraryVisitCreateDTO) { | ||
return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDTO.res(HttpStatus.CREATED, | ||
itinerarypostUpdateService.createVisit(itineraryVisitCreateDTO, tripId), | ||
"체류 여정을 성공적으로 등록했습니다.")); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...n/java/com/fc/toy_project2/domain/itinerary/controller/ItineraryPostControllerAdvice.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.fc.toy_project2.domain.itinerary.controller; | ||
|
||
import com.fc.toy_project2.domain.itinerary.dto.response.ItineraryGetResponseDTO; | ||
import com.fc.toy_project2.domain.itinerary.exception.InvalidAccommodationException; | ||
import com.fc.toy_project2.domain.itinerary.exception.InvalidTransportationException; | ||
import com.fc.toy_project2.domain.itinerary.exception.InvalidVisitException; | ||
import com.fc.toy_project2.global.DTO.ResponseDTO; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@RestControllerAdvice | ||
public class ItineraryPostControllerAdvice { | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ResponseDTO<ItineraryGetResponseDTO>> invalidAccommodationException( | ||
InvalidAccommodationException e) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(ResponseDTO.res(HttpStatus.BAD_REQUEST, e.getMessage())); | ||
} | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ResponseDTO<ItineraryGetResponseDTO>> invalidTransportationException( | ||
InvalidTransportationException e) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(ResponseDTO.res(HttpStatus.BAD_REQUEST, e.getMessage())); | ||
} | ||
|
||
@ExceptionHandler | ||
public ResponseEntity<ResponseDTO<ItineraryGetResponseDTO>> invalidVisitException( | ||
InvalidVisitException e) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
.body(ResponseDTO.res(HttpStatus.BAD_REQUEST, e.getMessage())); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
.../toy_project2/domain/itinerary/dto/request/createDTO/ItineraryAccommodationCreateDTO.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,23 @@ | ||
package com.fc.toy_project2.domain.itinerary.dto.request.createDTO; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ItineraryAccommodationCreateDTO { | ||
|
||
@NotNull | ||
private String accommodationName; | ||
|
||
@NotNull | ||
private String accommodationRoadAddressName; | ||
|
||
@NotBlank | ||
private String checkIn; | ||
|
||
@NotBlank | ||
private String checkOut; | ||
} |
31 changes: 31 additions & 0 deletions
31
...toy_project2/domain/itinerary/dto/request/createDTO/ItineraryTransportationCreateDTO.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,31 @@ | ||
package com.fc.toy_project2.domain.itinerary.dto.request.createDTO; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ItineraryTransportationCreateDTO { | ||
@NotNull | ||
private String transportation; | ||
|
||
@NotNull | ||
private String departurePlace; | ||
|
||
@NotNull | ||
private String departurePlaceRoadAddressName; | ||
|
||
@NotNull | ||
private String destinationRoadAddressName; | ||
|
||
@NotNull | ||
private String destination; | ||
|
||
@NotBlank | ||
private String departureTime; | ||
|
||
@NotBlank | ||
private String arrivalTime; | ||
} |
20 changes: 20 additions & 0 deletions
20
...a/com/fc/toy_project2/domain/itinerary/dto/request/createDTO/ItineraryVisitCreateDTO.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,20 @@ | ||
package com.fc.toy_project2.domain.itinerary.dto.request.createDTO; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ItineraryVisitCreateDTO { | ||
@NotNull | ||
private String placeName; | ||
@NotNull | ||
private String placeRoadAddressName; | ||
@NotBlank | ||
private String arrivalTime; | ||
@NotBlank | ||
private String departureTime; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...fc/toy_project2/domain/itinerary/dto/request/patchDTO/ItineraryAccommodationPatchDTO.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,14 @@ | ||
package com.fc.toy_project2.domain.itinerary.dto.request.patchDTO; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ItineraryAccommodationPatchDTO { | ||
|
||
private String accommodationName; | ||
private String accommodationRoadAddressName; | ||
private String checkIn; | ||
private String checkOut; | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...ava/com/fc/toy_project2/domain/itinerary/dto/request/patchDTO/ItineraryVisitPatchDTO.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,16 @@ | ||
package com.fc.toy_project2.domain.itinerary.dto.request.patchDTO; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@Builder | ||
public class ItineraryVisitPatchDTO { | ||
|
||
private String placeName; | ||
private String placeRoadAddressName; | ||
private LocalDateTime arrivalTime; | ||
private LocalDateTime departureTime; | ||
} |
15 changes: 0 additions & 15 deletions
15
...ain/java/com/fc/toy_project2/domain/itinerary/dto/response/ItineraryAccommodationDTO.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
.../com/fc/toy_project2/domain/itinerary/dto/response/ItineraryAccommodationResponseDTO.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,27 @@ | ||
package com.fc.toy_project2.domain.itinerary.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@Builder | ||
public class ItineraryAccommodationResponseDTO { | ||
|
||
private String accommodationName; | ||
private String accommodationRoadAddressName; | ||
private LocalDateTime checkIn; | ||
private LocalDateTime checkOut; | ||
|
||
public static ItineraryAccommodationResponseDTO of(String accommodationName, | ||
String accommodationRoadAddressName, LocalDateTime checkIn, LocalDateTime checkOut) { | ||
return ItineraryAccommodationResponseDTO.builder() | ||
.accommodationName(accommodationName) | ||
.accommodationRoadAddressName(accommodationRoadAddressName) | ||
.checkIn(checkIn) | ||
.checkOut(checkOut) | ||
.build(); | ||
} | ||
|
||
} |
12 changes: 10 additions & 2 deletions
12
src/main/java/com/fc/toy_project2/domain/itinerary/dto/response/ItineraryGetResponseDTO.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,11 +1,19 @@ | ||
package com.fc.toy_project2.domain.itinerary.dto.response; | ||
|
||
import com.fc.toy_project2.domain.trip.entity.Trip; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ItineraryGetResponseDTO { | ||
|
||
private Long itineraryId; | ||
} | ||
private Long id; | ||
private Trip trip; | ||
public static ItineraryGetResponseDTO of(Long id, Trip trip) { | ||
return ItineraryGetResponseDTO.builder() | ||
.id(id) | ||
.trip(trip) | ||
.build(); | ||
} | ||
} |
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
Oops, something went wrong.