-
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
111 changed files
with
3,791 additions
and
31 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
48 changes: 48 additions & 0 deletions
48
application/src/main/java/org/depromeet/spot/application/block/BlockReadController.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 org.depromeet.spot.application.block; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
|
||
import org.depromeet.spot.application.block.dto.response.BlockCodeInfoResponse; | ||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase; | ||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.BlockCodeInfo; | ||
import org.springframework.http.HttpStatus; | ||
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.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "블록") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class BlockReadController { | ||
|
||
private final BlockReadUsecase blockReadUsecase; | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/stadiums/{stadiumId}/sections/{sectionId}/blocks") | ||
@Operation(summary = "특정 야구 경기장 특정 구역 내의 블록 리스트를 조회한다.") | ||
public List<BlockCodeInfoResponse> findCodeInfosByStadium( | ||
@PathVariable("stadiumId") | ||
@NotNull | ||
@Positive | ||
@Parameter(name = "stadiumId", description = "야구 경기장 PK", required = true) | ||
final Long stadiumId, | ||
@PathVariable("sectionId") | ||
@NotNull | ||
@Positive | ||
@Parameter(name = "sectionId", description = "구역 PK", required = true) | ||
final Long sectionId) { | ||
List<BlockCodeInfo> infos = blockReadUsecase.findCodeInfosByStadium(stadiumId, sectionId); | ||
return infos.stream().map(BlockCodeInfoResponse::from).toList(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...rc/main/java/org/depromeet/spot/application/block/dto/response/BlockCodeInfoResponse.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,10 @@ | ||
package org.depromeet.spot.application.block.dto.response; | ||
|
||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.BlockCodeInfo; | ||
|
||
public record BlockCodeInfoResponse(Long id, String code) { | ||
|
||
public static BlockCodeInfoResponse from(BlockCodeInfo blockCodeInfo) { | ||
return new BlockCodeInfoResponse(blockCodeInfo.getId(), blockCodeInfo.getCode()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
application/src/main/java/org/depromeet/spot/application/common/dto/RgbCodeRequest.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,9 @@ | ||
package org.depromeet.spot.application.common.dto; | ||
|
||
import org.depromeet.spot.domain.common.RgbCode; | ||
|
||
public record RgbCodeRequest(Integer red, Integer green, Integer blue) { | ||
public RgbCode toDomain() { | ||
return RgbCode.builder().red(red).green(green).blue(blue).build(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
application/src/main/java/org/depromeet/spot/application/common/dto/RgbCodeResponse.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,13 @@ | ||
package org.depromeet.spot.application.common.dto; | ||
|
||
import org.depromeet.spot.domain.common.RgbCode; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record RgbCodeResponse(Integer red, Integer green, Integer blue) { | ||
|
||
public static RgbCodeResponse from(RgbCode rgbCode) { | ||
return new RgbCodeResponse(rgbCode.getRed(), rgbCode.getGreen(), rgbCode.getBlue()); | ||
} | ||
} |
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
58 changes: 58 additions & 0 deletions
58
application/src/main/java/org/depromeet/spot/application/review/ReviewReadController.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,58 @@ | ||
package org.depromeet.spot.application.review; | ||
|
||
import jakarta.validation.constraints.Max; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
import jakarta.validation.constraints.PositiveOrZero; | ||
|
||
import org.depromeet.spot.application.review.dto.response.ReviewListResponse; | ||
import org.depromeet.spot.domain.review.ReviewListResult; | ||
import org.depromeet.spot.usecase.port.in.review.ReviewReadUsecase; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "리뷰") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class ReviewReadController { | ||
|
||
private final ReviewReadUsecase reviewReadUsecase; | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/stadiums/{stadiumId}/blocks/{blockId}/reviews") | ||
@Operation(summary = "특정 야구장의 특정 블록에 대한 리뷰 목록을 조회한다.") | ||
public ReviewListResponse findReviewsByBlockId( | ||
@PathVariable("stadiumId") | ||
@NotNull | ||
@Positive | ||
@Parameter(description = "야구장 PK", required = true) | ||
Long stadiumId, | ||
@PathVariable("blockId") | ||
@NotNull | ||
@Positive | ||
@Parameter(description = "블록 PK", required = true) | ||
Long blockId, | ||
@RequestParam(required = false) @Parameter(description = "열 ID (필터링)") Long rowId, | ||
@RequestParam(required = false) @Parameter(description = "좌석 번호 (필터링)") Long seatNumber, | ||
@RequestParam(defaultValue = "0") | ||
@PositiveOrZero | ||
@Parameter(description = "시작 위치 (기본값: 0)") | ||
int offset, | ||
@RequestParam(defaultValue = "10") | ||
@Positive | ||
@Max(50) | ||
@Parameter(description = "조회할 리뷰 수 (기본값: 10, 최대: 50)") | ||
int limit) { | ||
|
||
ReviewListResult result = | ||
reviewReadUsecase.findReviewsByBlockId( | ||
stadiumId, blockId, rowId, seatNumber, offset, limit); | ||
return ReviewListResponse.from(result); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...n/src/main/java/org/depromeet/spot/application/review/dto/request/ReviewBlockRequest.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,12 @@ | ||
package org.depromeet.spot.application.review.dto.request; | ||
|
||
import jakarta.validation.constraints.Max; | ||
import jakarta.validation.constraints.PositiveOrZero; | ||
|
||
import io.swagger.v3.oas.annotations.Parameter; | ||
|
||
public record ReviewBlockRequest( | ||
@Parameter(description = "열 ID (필터링)") Long rowId, | ||
@Parameter(description = "좌석 번호 (필터링)") Long seatNumber, | ||
@PositiveOrZero @Parameter(description = "시작 위치 (기본값: 0)") int offset, | ||
@Max(50) @Parameter(description = "조회할 리뷰 수 (기본값: 10, 최대: 50)") int limit) {} |
43 changes: 43 additions & 0 deletions
43
.../src/main/java/org/depromeet/spot/application/review/dto/response/ReviewListResponse.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,43 @@ | ||
package org.depromeet.spot.application.review.dto.response; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.depromeet.spot.domain.review.ReviewListResult; | ||
|
||
public record ReviewListResponse( | ||
List<KeywordCountResponse> keywords, | ||
List<ReviewResponse> reviews, | ||
Long totalCount, | ||
int filteredCount, | ||
int offset, | ||
int limit, | ||
boolean hasMore, | ||
FilterInfo filter) { | ||
public static ReviewListResponse from(ReviewListResult result) { | ||
List<ReviewResponse> reviewResponses = | ||
result.reviews().stream().map(ReviewResponse::from).collect(Collectors.toList()); | ||
|
||
List<KeywordCountResponse> keywordResponses = | ||
result.topKeywords().stream() | ||
.map(kc -> new KeywordCountResponse(kc.content(), kc.count())) | ||
.collect(Collectors.toList()); | ||
|
||
boolean hasMore = (result.offset() + result.reviews().size()) < result.totalCount(); | ||
FilterInfo filter = new FilterInfo(null, null); // Assuming no filter info for now | ||
|
||
return new ReviewListResponse( | ||
keywordResponses, | ||
reviewResponses, | ||
result.totalCount(), | ||
result.reviews().size(), | ||
result.offset(), | ||
result.limit(), | ||
hasMore, | ||
filter); | ||
} | ||
|
||
record KeywordCountResponse(String content, Long count) {} | ||
|
||
record FilterInfo(Long rowId, Integer seatNumber) {} | ||
} |
60 changes: 60 additions & 0 deletions
60
...tion/src/main/java/org/depromeet/spot/application/review/dto/response/ReviewResponse.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,60 @@ | ||
package org.depromeet.spot.application.review.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.depromeet.spot.domain.review.Review; | ||
import org.depromeet.spot.domain.review.ReviewImage; | ||
import org.depromeet.spot.domain.review.ReviewKeyword; | ||
|
||
public record ReviewResponse( | ||
Long id, | ||
Long userId, | ||
Long blockId, | ||
Long seatId, | ||
Long rowId, | ||
Long seatNumber, | ||
LocalDateTime date, | ||
String content, | ||
LocalDateTime createdAt, | ||
LocalDateTime updatedAt, | ||
List<ImageResponse> images, | ||
List<KeywordResponse> keywords) { | ||
public static ReviewResponse from(Review review) { | ||
return new ReviewResponse( | ||
review.getId(), | ||
review.getUserId(), | ||
review.getBlockId(), | ||
review.getSeatId(), | ||
review.getRowId(), | ||
review.getSeatNumber(), | ||
review.getDateTime(), | ||
review.getContent(), | ||
review.getCreatedAt(), | ||
review.getUpdatedAt(), | ||
mapToImageResponses(review.getImages()), | ||
mapToKeywordResponses(review.getKeywords())); | ||
} | ||
|
||
private static List<ImageResponse> mapToImageResponses(List<ReviewImage> images) { | ||
return images.stream() | ||
.map(image -> new ImageResponse(image.getId(), image.getUrl())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private static List<KeywordResponse> mapToKeywordResponses(List<ReviewKeyword> keywords) { | ||
return keywords.stream() | ||
.map( | ||
keyword -> | ||
new KeywordResponse( | ||
keyword.getId(), | ||
keyword.getKeywordId(), | ||
keyword.getIsPositive())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
record ImageResponse(Long id, String url) {} | ||
|
||
record KeywordResponse(Long id, Long keywordId, Boolean isPositive) {} | ||
} |
41 changes: 41 additions & 0 deletions
41
application/src/main/java/org/depromeet/spot/application/section/SectionReadController.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.section; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
|
||
import org.depromeet.spot.application.section.dto.response.StadiumSectionsResponse; | ||
import org.depromeet.spot.usecase.port.in.section.SectionReadUsecase; | ||
import org.depromeet.spot.usecase.port.in.section.SectionReadUsecase.StadiumSections; | ||
import org.springframework.http.HttpStatus; | ||
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.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@Tag(name = "구역") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1") | ||
public class SectionReadController { | ||
|
||
private final SectionReadUsecase sectionReadUsecase; | ||
|
||
@ResponseStatus(HttpStatus.OK) | ||
@GetMapping("/stadiums/{stadiumId}/sections") | ||
@Operation(summary = "특정 야구 경기장 내의 모든 구역 정보를 구장 좌석 배치도와 함께 조회한다.") | ||
public StadiumSectionsResponse findAllByStadium( | ||
@PathVariable("stadiumId") | ||
@NotNull | ||
@Positive | ||
@Parameter(name = "stadiumId", description = "야구 경기장 PK", required = true) | ||
final Long stadiumId) { | ||
StadiumSections sectionInfo = sectionReadUsecase.findAllByStadium(stadiumId); | ||
return StadiumSectionsResponse.from(sectionInfo); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...rc/main/java/org/depromeet/spot/application/section/dto/response/SectionInfoResponse.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,19 @@ | ||
package org.depromeet.spot.application.section.dto.response; | ||
|
||
import org.depromeet.spot.domain.common.RgbCode; | ||
import org.depromeet.spot.usecase.port.in.section.SectionReadUsecase.SectionInfo; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record SectionInfoResponse(Long id, String name, String alias, RgbCode color) { | ||
|
||
public static SectionInfoResponse from(SectionInfo sectionInfo) { | ||
return SectionInfoResponse.builder() | ||
.id(sectionInfo.getId()) | ||
.name(sectionInfo.getName()) | ||
.alias(sectionInfo.getAlias()) | ||
.color(sectionInfo.getColor()) | ||
.build(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ain/java/org/depromeet/spot/application/section/dto/response/StadiumSectionsResponse.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 org.depromeet.spot.application.section.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import org.depromeet.spot.usecase.port.in.section.SectionReadUsecase.StadiumSections; | ||
|
||
public record StadiumSectionsResponse(String seatChart, List<SectionInfoResponse> sectionList) { | ||
|
||
public static StadiumSectionsResponse from(StadiumSections stadiumSections) { | ||
List<SectionInfoResponse> infos = | ||
stadiumSections.getSectionList().stream().map(SectionInfoResponse::from).toList(); | ||
return new StadiumSectionsResponse(stadiumSections.getSeatChart(), infos); | ||
} | ||
} |
Oops, something went wrong.