Repository navigation
[Feat/#97] 사물함 구역 배치·사진 저장과 구역 상세 응답 개편 #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
189162e
feat: 사물함 구역 배치 테이블 추가
tnals0924 99ffb83
feat: 구역 상세 조회가 구역 정보와 배치를 함께 반환
tnals0924 895dedf
feat: 구역 상세 응답을 layout·사진 기반으로 개편
tnals0924 cbdd4fa
feat: 사물함 구역 사진 파일 카테고리 추가
tnals0924 d73c70d
refactor: 구역 배치 형식 버전 컬럼 매핑을 columnDefinition으로 변경
tnals0924 6823df8
refactor: 구역 상세 조회의 읽기 전용 트랜잭션 제거
tnals0924 eeeab6f
refactor: 구역 사진 URL 조립의 중복 null 체크 제거
tnals0924 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
51 changes: 45 additions & 6 deletions
51
.../java/kr/ac/kookmin/stream/api/app/event/locker/response/LockerSectionDetailResponse.java
This file contains hidden or 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,22 +1,61 @@ | ||
| package kr.ac.kookmin.stream.api.app.event.locker.response; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonRawValue; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import kr.ac.kookmin.stream.event.domain.locker.domain.Locker; | ||
| import kr.ac.kookmin.stream.api.common.StorageUrlBuilder; | ||
| import kr.ac.kookmin.stream.event.domain.locker.domain.LockerSectionDetail; | ||
| import kr.ac.kookmin.stream.event.domain.locker.domain.LockerSectionLayout; | ||
| import kr.ac.kookmin.stream.file.domain.File; | ||
|
|
||
| public record LockerSectionDetailResponse(List<LockerResponse> lockers) { | ||
| /** | ||
| * @param layout 칸 배치 구조. 배치 구조를 아직 등록하지 않은 구역이면 {@code null} | ||
| * @param photoUrl 구역 실제 사진. 배치 구조를 아직 등록하지 않았거나 사진 파일이 삭제됐으면 {@code null} | ||
| */ | ||
| public record LockerSectionDetailResponse( | ||
| Long sectionId, | ||
| String section, | ||
| Layout layout, | ||
| String photoUrl, | ||
| List<LockerResponse> lockers | ||
| ) { | ||
|
|
||
| /** | ||
| * @param photo 구역 사진 파일. 배치 구조를 아직 등록하지 않았거나 파일이 삭제됐으면 {@code null} | ||
| * @param appliedLockerIds 해당 운영 회차에 이미 신청된 사물함 식별자 | ||
| * @param myLockerId 조회한 회원이 신청한 사물함. 신청하지 않았으면 {@code null} | ||
| */ | ||
| public static LockerSectionDetailResponse of( | ||
| List<Locker> lockers, | ||
| LockerSectionDetail detail, | ||
| File photo, | ||
| Set<Long> appliedLockerIds, | ||
| Long myLockerId | ||
| ) { | ||
| return new LockerSectionDetailResponse(lockers.stream() | ||
| .map(locker -> LockerResponse.of(locker, appliedLockerIds.contains(locker.getId()), myLockerId)) | ||
| .toList()); | ||
| return new LockerSectionDetailResponse( | ||
| detail.section().getId(), | ||
| detail.section().getLabel(), | ||
| detail.layout() == null ? null : Layout.from(detail.layout()), | ||
| StorageUrlBuilder.build(photo), | ||
| detail.lockers().stream() | ||
| .map(locker -> LockerResponse.of(locker, appliedLockerIds.contains(locker.getId()), myLockerId)) | ||
| .toList() | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @param version layout 형식 버전. 앱은 모르는 버전이면 그리지 않고 업데이트를 안내한다 | ||
| * @param root 저장된 JSON을 해석하지 않고 그대로 끼워 넣는다 | ||
| */ | ||
| public record Layout( | ||
| int version, | ||
| @JsonRawValue | ||
| @Schema(type = "object", description = "root 블록 트리. 블록은 type으로 구분하고, 칸 번호는 lockers[].lockerNumber와 같다") | ||
| String root | ||
| ) { | ||
|
|
||
| public static Layout from(LockerSectionLayout layout) { | ||
| return new Layout(layout.getVersion(), layout.getLayout()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
...nt/src/main/java/kr/ac/kookmin/stream/event/domain/locker/domain/LockerSectionDetail.java
This file contains hidden or 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,16 @@ | ||
| package kr.ac.kookmin.stream.event.domain.locker.domain; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * 사물함 구역 상세 한 건. 칸 선택 화면이 구역 정보·배치 구조·사물함을 한 번에 받는다. | ||
| * | ||
| * @param layout 배치 구조와 사진. 아직 등록하지 않은 구역이면 {@code null} | ||
| * @param lockers 구역에 속한 사물함. 선택 가능 여부는 담지 않는다 | ||
| */ | ||
| public record LockerSectionDetail( | ||
| LockerSection section, | ||
| LockerSectionLayout layout, | ||
| List<Locker> lockers | ||
| ) { | ||
| } |
30 changes: 30 additions & 0 deletions
30
...nt/src/main/java/kr/ac/kookmin/stream/event/domain/locker/domain/LockerSectionLayout.java
This file contains hidden or 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,30 @@ | ||
| package kr.ac.kookmin.stream.event.domain.locker.domain; | ||
|
|
||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.Getter; | ||
|
|
||
| /** | ||
| * 구역 상세 화면의 칸 배치 구조와 구역 사진. 구역마다 하나다. | ||
| * <p> | ||
| * 배치 구조에는 칸 위치와 창문·벽면 같은 고정 구조만 담는다. 선택 가능 여부처럼 신청할 때마다 바뀌는 칸 상태는 | ||
| * 조회 시점에 사물함에서 계산하고, 둘은 사물함 번호({@link Locker#getLockerNumber()})로 잇는다. | ||
| */ | ||
| @Getter | ||
| @EqualsAndHashCode | ||
| @AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class LockerSectionLayout { | ||
|
|
||
| private Long id; | ||
| private Long sectionId; | ||
| /** root 블록 트리 JSON 원문. 서버는 해석하지 않고 그대로 내려준다. */ | ||
| private String layout; | ||
| /** layout 형식 버전. 블록 종류·필드가 바뀌면 올려서 옛 앱이 모르는 형식을 알아채게 한다. */ | ||
| private int version; | ||
| private Long photoFileId; | ||
|
|
||
| public static LockerSectionLayout of(Long id, Long sectionId, String layout, int version, Long photoFileId) { | ||
| return new LockerSectionLayout(id, sectionId, layout, version, photoFileId); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
조회 전용 메서드에
@Transactional(readOnly = true)를 붙여야 합니다.getSectionDetail은 조회만 합니다. 이 메서드는 회차, 구역, 배치, 사물함을 차례로 네 번 조회합니다. path instructions는 "조회 전용은@Transactional(readOnly = true)"로 규정합니다. 같은 클래스의getSections도 이 규칙을 따릅니다. 커밋 기록에서 이 어노테이션을 일부러 제거했다면, 그 근거를 주석으로 남기십시오.수정안
@Override + @Transactional(readOnly = true) public LockerSectionDetail getSectionDetail(Long lockerPeriodId, Long sectionId) {As per path instructions: "트랜잭션 경계는 Service 메서드에 둔다. 조회 전용은
@Transactional(readOnly = true)".📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Path instructions