-
Notifications
You must be signed in to change notification settings - Fork 1
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
46 changed files
with
507 additions
and
18 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
application/src/main/java/org/depromeet/spot/application/review/CreateReviewController.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,41 @@ | ||
package org.depromeet.spot.application.review; | ||
|
||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
|
||
import org.depromeet.spot.application.review.dto.request.CreateReviewRequest; | ||
import org.depromeet.spot.application.review.dto.response.ReviewResponse; | ||
import org.depromeet.spot.domain.review.Review; | ||
import org.depromeet.spot.usecase.port.in.review.CreateReviewUsecase; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "리뷰") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class CreateReviewController { | ||
|
||
private final CreateReviewUsecase createReviewUsecase; | ||
|
||
@ResponseStatus(HttpStatus.CREATED) | ||
@Operation(summary = "특정 좌석에 신규 리뷰를 추가한다.") | ||
@PostMapping("/seats/{seatId}/members/{memberId}/reviews") | ||
public ReviewResponse create( | ||
@PathVariable @Positive @NotNull final Long seatId, | ||
@PathVariable @Positive @NotNull final Long memberId, | ||
@RequestBody @Valid @NotNull CreateReviewRequest request) { | ||
Review review = createReviewUsecase.create(seatId, memberId, request.toCommand()); | ||
return ReviewResponse.from(review); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../src/main/java/org/depromeet/spot/application/review/dto/request/CreateReviewRequest.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,32 @@ | ||
package org.depromeet.spot.application.review.dto.request; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.DateTimeParseException; | ||
import java.util.List; | ||
|
||
import org.depromeet.spot.common.exception.review.ReviewException.InvalidReviewDateTimeFormatException; | ||
import org.depromeet.spot.usecase.port.in.review.CreateReviewUsecase.CreateReviewCommand; | ||
|
||
public record CreateReviewRequest( | ||
List<String> images, List<String> good, List<String> bad, String content, String dateTime) { | ||
|
||
public CreateReviewCommand toCommand() { | ||
return CreateReviewCommand.builder() | ||
.images(images) | ||
.good(good) | ||
.bad(bad) | ||
.content(content) | ||
.dateTime(toLocalDateTime(dateTime)) | ||
.build(); | ||
} | ||
|
||
private LocalDateTime toLocalDateTime(String dateTimeStr) { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
try { | ||
return LocalDateTime.parse(dateTimeStr, formatter); | ||
} catch (DateTimeParseException e) { | ||
throw new InvalidReviewDateTimeFormatException(); | ||
} | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
common/src/main/java/org/depromeet/spot/common/exception/seat/SeatErrorCode.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 org.depromeet.spot.common.exception.seat; | ||
|
||
import org.depromeet.spot.common.exception.ErrorCode; | ||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum SeatErrorCode implements ErrorCode { | ||
SEAT_NOT_FOUND(HttpStatus.NOT_FOUND, "SEAT001", "요청 좌석이 존재하지 않습니다."), | ||
; | ||
|
||
private final HttpStatus status; | ||
private final String code; | ||
private String message; | ||
|
||
SeatErrorCode(HttpStatus status, String code, String message) { | ||
this.status = status; | ||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
public SeatErrorCode appended(Object o) { | ||
message = message + " {" + o.toString() + "}"; | ||
return this; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/main/java/org/depromeet/spot/common/exception/seat/SeatException.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 org.depromeet.spot.common.exception.seat; | ||
|
||
import org.depromeet.spot.common.exception.BusinessException; | ||
|
||
public abstract class SeatException extends BusinessException { | ||
|
||
protected SeatException(SeatErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
|
||
public static class SeatNotFoundException extends SeatException { | ||
public SeatNotFoundException() { | ||
super(SeatErrorCode.SEAT_NOT_FOUND); | ||
} | ||
|
||
public SeatNotFoundException(Object obj) { | ||
super(SeatErrorCode.SEAT_NOT_FOUND.appended(obj)); | ||
} | ||
} | ||
} |
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
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
8 changes: 8 additions & 0 deletions
8
...cture/jpa/src/main/java/org/depromeet/spot/jpa/review/repository/ReviewJpaRepository.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 org.depromeet.spot.jpa.review.repository; | ||
|
||
import org.depromeet.spot.jpa.review.entity.ReviewEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ReviewJpaRepository extends JpaRepository<ReviewEntity, Long> { | ||
long countByUserId(Long userId); | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...rc/main/java/org/depromeet/spot/jpa/review/repository/image/ReviewImageJpaRepository.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,6 @@ | ||
package org.depromeet.spot.jpa.review.repository.image; | ||
|
||
import org.depromeet.spot.jpa.review.entity.ReviewImageEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ReviewImageJpaRepository extends JpaRepository<ReviewImageEntity, Long> {} |
Oops, something went wrong.