-
Notifications
You must be signed in to change notification settings - Fork 5
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
44 changed files
with
926 additions
and
113 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
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/woowacourse/touroot/global/exception/BadRequestException.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,8 @@ | ||
package woowacourse.touroot.global.exception; | ||
|
||
public class BadRequestException extends RuntimeException { | ||
|
||
public BadRequestException(String message) { | ||
super(message); | ||
} | ||
} |
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
13 changes: 9 additions & 4 deletions
13
backend/src/main/java/woowacourse/touroot/travelogue/controller/TravelogueController.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,23 +1,28 @@ | ||
package woowacourse.touroot.travelogue.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import woowacourse.touroot.travelogue.dto.TravelogueResponse; | ||
import woowacourse.touroot.travelogue.service.TravelogueService; | ||
import woowacourse.touroot.travelogue.service.TravelogueFacadeService; | ||
|
||
@Tag(name = "여행기") | ||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("api/v1/travelogues") | ||
public class TravelogueController { | ||
|
||
private final TravelogueService travelogueService; | ||
private final TravelogueFacadeService travelogueFacadeService; | ||
|
||
@Operation(description = "여행기 상세 조회") | ||
@GetMapping("/{id}") | ||
public ResponseEntity<TravelogueResponse> findTravelogue(@PathVariable Long id) { | ||
return ResponseEntity.ok(travelogueService.findTravelogueById(id)); | ||
public ResponseEntity<TravelogueResponse> findTravelogue(@Valid @PathVariable Long id) { | ||
return ResponseEntity.ok(travelogueFacadeService.findTravelogueById(id)); | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
backend/src/main/java/woowacourse/touroot/travelogue/day/dto/TravelogueDayResponse.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
.../src/main/java/woowacourse/touroot/travelogue/day/repository/TravelogueDayRepository.java
This file was deleted.
Oops, something went wrong.
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
18 changes: 18 additions & 0 deletions
18
...nd/src/main/java/woowacourse/touroot/travelogue/domain/day/dto/TravelogueDayResponse.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,18 @@ | ||
package woowacourse.touroot.travelogue.domain.day.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import woowacourse.touroot.travelogue.domain.place.dto.TraveloguePlaceResponse; | ||
|
||
@Builder | ||
public record TravelogueDayResponse( | ||
@Schema(description = "여행기 일자 ID", example = "1") | ||
@NotNull(message = "ID는 비어있을 수 없습니다.") | ||
Long id, | ||
@Schema(description = "여행기 장소 목록") | ||
@NotNull(message = "여행기 장소 정보는 비어있을 수 없습니다.") | ||
List<TraveloguePlaceResponse> places | ||
) { | ||
} |
11 changes: 11 additions & 0 deletions
11
...in/java/woowacourse/touroot/travelogue/domain/day/repository/TravelogueDayRepository.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,11 @@ | ||
package woowacourse.touroot.travelogue.domain.day.repository; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import woowacourse.touroot.travelogue.domain.Travelogue; | ||
import woowacourse.touroot.travelogue.domain.day.domain.TravelogueDay; | ||
|
||
public interface TravelogueDayRepository extends JpaRepository<TravelogueDay, Long> { | ||
|
||
List<TravelogueDay> findByTravelogue(Travelogue travelogue); | ||
} |
28 changes: 28 additions & 0 deletions
28
...src/main/java/woowacourse/touroot/travelogue/domain/day/service/TravelogueDayService.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 woowacourse.touroot.travelogue.domain.day.service; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import woowacourse.touroot.global.exception.BadRequestException; | ||
import woowacourse.touroot.travelogue.domain.Travelogue; | ||
import woowacourse.touroot.travelogue.domain.day.domain.TravelogueDay; | ||
import woowacourse.touroot.travelogue.domain.day.repository.TravelogueDayRepository; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class TravelogueDayService { | ||
|
||
private final TravelogueDayRepository travelogueDayRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public List<TravelogueDay> findDaysByTravelogue(Travelogue travelogue) { | ||
return travelogueDayRepository.findByTravelogue(travelogue); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public TravelogueDay findDayById(Long id) { | ||
return travelogueDayRepository.findById(id) | ||
.orElseThrow(() -> new BadRequestException("존재하지 않는 여행 일자입니다.")); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
...ava/woowacourse/touroot/travelogue/domain/photo/repository/TraveloguePhotoRepository.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,11 @@ | ||
package woowacourse.touroot.travelogue.domain.photo.repository; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import woowacourse.touroot.travelogue.domain.photo.domain.TraveloguePhoto; | ||
import woowacourse.touroot.travelogue.domain.place.domain.TraveloguePlace; | ||
|
||
public interface TraveloguePhotoRepository extends JpaRepository<TraveloguePhoto, Long> { | ||
|
||
List<TraveloguePhoto> findByTraveloguePlace(TraveloguePlace traveloguePlace); | ||
} |
25 changes: 25 additions & 0 deletions
25
...main/java/woowacourse/touroot/travelogue/domain/photo/service/TraveloguePhotoService.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,25 @@ | ||
package woowacourse.touroot.travelogue.domain.photo.service; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import woowacourse.touroot.travelogue.domain.photo.domain.TraveloguePhoto; | ||
import woowacourse.touroot.travelogue.domain.photo.repository.TraveloguePhotoRepository; | ||
import woowacourse.touroot.travelogue.domain.place.domain.TraveloguePlace; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class TraveloguePhotoService { | ||
|
||
private final TraveloguePhotoRepository traveloguePhotoRepository; | ||
|
||
public List<String> findPhotoUrlsByPlace(TraveloguePlace traveloguePlace) { | ||
List<TraveloguePhoto> photos = traveloguePhotoRepository.findByTraveloguePlace(traveloguePlace); | ||
|
||
return photos.stream() | ||
.sorted(Comparator.comparing(TraveloguePhoto::getOrder)) | ||
.map(TraveloguePhoto::getKey) | ||
.toList(); | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
...rc/main/java/woowacourse/touroot/travelogue/domain/place/dto/TraveloguePlaceResponse.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 woowacourse.touroot.travelogue.domain.place.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.util.List; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record TraveloguePlaceResponse( | ||
@Schema(description = "여행기 장소 ID", example = "1") | ||
@NotNull(message = "ID는 비어있을 수 없습니다.") | ||
Long id, | ||
@Schema(description = "여행기 장소 이름", example = "선릉 캠퍼스") | ||
@NotBlank(message = "여행기 장소 이름은 비어있을 수 없습니다.") | ||
String name, | ||
@Schema(description = "여행기 장소 설명", example = "성담 빌딩에 위치한 선릉 캠퍼스입니다.") | ||
@NotBlank(message = "여행기 장소 설명은 비어있을 수 없습니다.") | ||
String description, | ||
@Schema(description = "여행기 장소 위도", example = "37.5175896") | ||
@NotBlank(message = "여행기 장소 위도는 비어있을 수 없습니다.") | ||
String lat, | ||
@Schema(description = "여행기 장소 설명", example = "127.0867236") | ||
@NotBlank(message = "여행기 장소 경도는 비어있을 수 없습니다.") | ||
String lng, | ||
List<String> photoUrls | ||
) { | ||
} |
11 changes: 11 additions & 0 deletions
11
...java/woowacourse/touroot/travelogue/domain/place/repsitory/TraveloguePlaceRepository.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,11 @@ | ||
package woowacourse.touroot.travelogue.domain.place.repsitory; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import woowacourse.touroot.travelogue.domain.day.domain.TravelogueDay; | ||
import woowacourse.touroot.travelogue.domain.place.domain.TraveloguePlace; | ||
|
||
public interface TraveloguePlaceRepository extends JpaRepository<TraveloguePlace, Long> { | ||
|
||
List<TraveloguePlace> findByTravelogueDay(TravelogueDay travelogueDay); | ||
} |
Oops, something went wrong.