Skip to content

Commit 2ae7aff

Browse files
authored
Merge pull request #143 from InningLog/feat/#142/seatview-without-journal
feat : 직관일지 없이 좌석시야 독립 등록 지원 #142
2 parents c87cf38 + b7c2592 commit 2ae7aff

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

src/main/java/com/inninglog/inninglog/domain/seatView/controller/SeatViewController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ public class SeatViewController {
4040
업로드된 파일명을 'fileName' 필드에 포함하여 요청해야 합니다.
4141
4242
✅ 필수 입력 필드:
43-
- `journalId`: 연결된 직관 일지 ID
4443
- `stadiumShortCode`, `section`, `seatRow`: 좌석 정보
44+
45+
📎 선택 입력 필드:
46+
- `journalId`: 연결할 직관 일지 ID (없으면 일지와 무관하게 독립 등록)
4547
- `emotionTagCodes`: 감정 태그 코드 배열 (문자열 리스트)
4648
- `fileNames`: 업로드한 이미지 파일명 리스트 (최대 5장, 확장자 포함)
4749

src/main/java/com/inninglog/inninglog/domain/seatView/dto/req/SeatCreateReqDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@Schema(description = "좌석 후기 등록 요청 DTO")
1616
public class SeatCreateReqDto {
1717

18-
@Schema(description = "매핑되는 직관 일지의 ID", example = "12")
18+
@Schema(description = "매핑되는 직관 일지의 ID (선택, 없으면 독립 등록)", example = "12", nullable = true)
1919
private Long journalId;
2020

2121
@Schema(description = "경기장 숏코드 (ex. JAMS, DAE)", example = "JAM")

src/main/java/com/inninglog/inninglog/domain/seatView/dto/res/SeatCreateResDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class SeatCreateResDto {
1717

1818
public static SeatCreateResDto from(SeatView seatView) {
1919
return SeatCreateResDto.builder()
20-
.JournalId(seatView.getJournal().getId())
20+
.JournalId(seatView.getJournal() != null ? seatView.getJournal().getId() : null)
2121
.SeatViewId(seatView.getId())
2222
.build();
2323
}

src/main/java/com/inninglog/inninglog/domain/seatView/service/SeatViewService.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ public SeatCreateResDto createSeatView(Long memberId, SeatCreateReqDto dto) {
5555
return new CustomException(ErrorCode.USER_NOT_FOUND);
5656
});
5757

58-
Journal journal = journalRepository.findById(dto.getJournalId())
59-
.orElseThrow(() -> {
60-
log.warn("❌ [createSeatView] journalId={} 존재하지 않는 직관 일지 ID", dto.getJournalId());
61-
return new CustomException(ErrorCode.JOURNAL_NOT_FOUND);
62-
});
58+
Journal journal = null;
59+
if (dto.getJournalId() != null) {
60+
journal = journalRepository.findById(dto.getJournalId())
61+
.orElseThrow(() -> {
62+
log.warn("❌ [createSeatView] journalId={} 존재하지 않는 직관 일지 ID", dto.getJournalId());
63+
return new CustomException(ErrorCode.JOURNAL_NOT_FOUND);
64+
});
6365

64-
if (journal.getSeatView() != null) {
65-
log.warn("⚠️ [createSeatView] journalId={} 이미 좌석 시야가 등록된 일지 ID", dto.getJournalId());
66-
throw new CustomException(ErrorCode.SEATVIEW_ALREADY_EXISTS);
66+
if (journal.getSeatView() != null) {
67+
log.warn("⚠️ [createSeatView] journalId={} 이미 좌석 시야가 등록된 일지 ID", dto.getJournalId());
68+
throw new CustomException(ErrorCode.SEATVIEW_ALREADY_EXISTS);
69+
}
6770
}
6871

6972
Stadium stadium = stadiumRepository.findByShortCode(dto.getStadiumShortCode())
@@ -73,7 +76,9 @@ public SeatCreateResDto createSeatView(Long memberId, SeatCreateReqDto dto) {
7376
});
7477

7578
SeatView seatView = SeatView.from(dto, member, journal, stadium);
76-
journal.setSeatView(seatView);
79+
if (journal != null) {
80+
journal.setSeatView(seatView);
81+
}
7782
seatViewRepository.save(seatView);
7883

7984
// ContentImage 테이블에 이미지 저장

0 commit comments

Comments
 (0)