-
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.
* feat: block별 좌석 조회 쿼리 추가 * feat: 쿼리 수정 및 controller 완성 * test: 열별 좌석 번호 범위 계산 테스트 코드 추가 * refactor: stream 적용, 공통 메서드 분리
- Loading branch information
Showing
21 changed files
with
394 additions
and
52 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
15 changes: 15 additions & 0 deletions
15
...on/src/main/java/org/depromeet/spot/application/block/dto/response/BlockInfoResponse.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,15 @@ | ||
package org.depromeet.spot.application.block.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.BlockInfo; | ||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.RowInfo; | ||
|
||
public record BlockInfoResponse(Long id, String code, List<RowInfoResponse> rowInfo) { | ||
public static BlockInfoResponse from(BlockInfo blockInfo) { | ||
List<RowInfo> rowInfos = blockInfo.getRowInfo(); | ||
List<RowInfoResponse> rowInfoResponses = | ||
rowInfos.stream().map(RowInfoResponse::from).toList(); | ||
return new BlockInfoResponse(blockInfo.getId(), blockInfo.getCode(), rowInfoResponses); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...tion/src/main/java/org/depromeet/spot/application/block/dto/response/RowInfoResponse.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 org.depromeet.spot.application.block.dto.response; | ||
|
||
import org.depromeet.spot.usecase.port.in.block.BlockReadUsecase.RowInfo; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record RowInfoResponse(Long id, int number, int minSeatNum, int maxSeatNum) { | ||
|
||
public static RowInfoResponse from(RowInfo rowInfo) { | ||
return RowInfoResponse.builder() | ||
.id(rowInfo.getId()) | ||
.number(rowInfo.getNumber()) | ||
.minSeatNum(rowInfo.getMinSeatNum()) | ||
.maxSeatNum(rowInfo.getMaxSeatNum()) | ||
.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
17 changes: 7 additions & 10 deletions
17
domain/src/main/java/org/depromeet/spot/domain/block/BlockRow.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,19 +1,16 @@ | ||
package org.depromeet.spot.domain.block; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
public class BlockRow { | ||
|
||
private final Long id; | ||
private final Long blockId; | ||
private final Long number; | ||
private final Long maxSeats; | ||
|
||
public BlockRow(Long id, Long blockId, Long number, Long max_seats) { | ||
this.id = id; | ||
this.blockId = blockId; | ||
this.number = number; | ||
this.maxSeats = max_seats; | ||
} | ||
private final Block block; | ||
private final Integer number; | ||
private final Integer maxSeats; | ||
} |
25 changes: 11 additions & 14 deletions
25
domain/src/main/java/org/depromeet/spot/domain/seat/Seat.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,24 +1,21 @@ | ||
package org.depromeet.spot.domain.seat; | ||
|
||
import org.depromeet.spot.domain.block.Block; | ||
import org.depromeet.spot.domain.block.BlockRow; | ||
import org.depromeet.spot.domain.section.Section; | ||
import org.depromeet.spot.domain.stadium.Stadium; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class Seat { | ||
|
||
private final Long id; | ||
private final Long stadiumId; | ||
private final Long sectionId; | ||
private final Long blockId; | ||
private final Long rowId; | ||
private final Stadium stadium; | ||
private final Section section; | ||
private final Block block; | ||
private final BlockRow row; | ||
private final Integer seatNumber; | ||
|
||
public Seat( | ||
Long id, Long stadiumId, Long sectionId, Long blockId, Long rowId, Integer seatNumber) { | ||
this.id = id; | ||
this.stadiumId = stadiumId; | ||
this.sectionId = sectionId; | ||
this.blockId = blockId; | ||
this.rowId = rowId; | ||
this.seatNumber = seatNumber; | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...ture/jpa/src/main/java/org/depromeet/spot/jpa/block/repository/BlockCustomRepository.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,34 @@ | ||
package org.depromeet.spot.jpa.block.repository; | ||
|
||
import static com.querydsl.core.group.GroupBy.groupBy; | ||
import static com.querydsl.core.group.GroupBy.list; | ||
import static org.depromeet.spot.jpa.block.entity.QBlockEntity.blockEntity; | ||
import static org.depromeet.spot.jpa.block.entity.QBlockRowEntity.blockRowEntity; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.depromeet.spot.jpa.block.entity.BlockEntity; | ||
import org.depromeet.spot.jpa.block.entity.BlockRowEntity; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class BlockCustomRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public Map<BlockEntity, List<BlockRowEntity>> findRowInfosBy(final Long sectionId) { | ||
return queryFactory | ||
.from(blockRowEntity) | ||
.join(blockEntity) | ||
.on(blockRowEntity.block.id.eq(blockEntity.id)) | ||
.where(blockEntity.sectionId.eq(sectionId)) | ||
.orderBy(blockRowEntity.number.asc()) | ||
.transform(groupBy(blockEntity).as(list(blockRowEntity))); | ||
} | ||
} |
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
Oops, something went wrong.