Skip to content

Commit

Permalink
fix : resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
EunjiShin committed Jul 16, 2024
2 parents 0cf3fae + 0e873da commit d4f8126
Show file tree
Hide file tree
Showing 111 changed files with 3,791 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# docker
db/**

## shell script
dev-restart.sh

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
Expand Down
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();
}
}
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());
}
}
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();
}
}
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public record MemberResponse(Long id, String name) {

public static MemberResponse from(Member member) {
return new MemberResponse(member.getId(), member.getName());
return new MemberResponse(member.getUserId(), member.getName());
}
}
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);
}
}
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) {}
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) {}
}
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) {}
}
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);
}
}
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();
}
}
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);
}
}
Loading

0 comments on commit d4f8126

Please sign in to comment.