Skip to content

Commit

Permalink
[FEAT] Album 튜토리얼용 Example 삭제하는 케이스 추가 #138
Browse files Browse the repository at this point in the history
  • Loading branch information
jun02160 committed Mar 9, 2024
1 parent b67ef05 commit f8a69a8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public String deleteAlbum(final Long albumId, final Long userId) {

User user = getUserById(userId);
Parentchild parentchild = getParentchildByUser(user);

// Sample Album을 삭제할 경우
if (albumId.equals(0L)) {
parentchild.updateDeleteSampleAlbum();
}

Album album = getAlbumById(albumId);

album.deleteParentchild();
Expand All @@ -75,23 +81,18 @@ public List<AlbumResponseDto> getAlbumList(final Long userId) {
parentchild);

// Album을 아직 한번도 등록하지 않은 경우
if (albumList.isEmpty() && !parentchild.isFirstAlbumUpload()) {
return List.of(AlbumResponseDto.of(createAlbumExample(parentchild)));
if (albumList.isEmpty() && !parentchild.isFirstAlbumUpload() && !parentchild.isDeleteSampleAlbum()) {
return List.of(AlbumResponseDto.of(createAlbumExample()));
}

return albumList.stream()
.map(AlbumResponseDto::of)
.collect(Collectors.toList());
}

private Album createAlbumExample(Parentchild parentchild) {
return Album.builder()
.title("사진의 제목을 입력할 수 있어요")
.content("사진에 대해 소개해요")
.imgUrl("imgUrl")
.writer("직성자")
.parentchild(parentchild)
.build();
private Album createAlbumExample() {
return new Album(0L, "사진의 제목을 입력할 수 있어요", "사진에 대해 소개해요",
"imgUrl", "직성자");
}

private User getUserById(Long userId) { // TODO userId -> Parentchild 한번에 가져오기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ private Album(String title, String content, String imgUrl, String writer, Parent
this.parentchild = parentchild;
}

public Album(Long id, String title, String content, String imgUrl, String writer) {
this.id = id;
this.title = title;
this.content = content;
this.imgUrl = imgUrl;
this.writer = writer;
}

public void setParentchild(Parentchild parentchild) {
this.parentchild = parentchild;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@ public void changeParentOnboardingAnswerList(List<OnboardingAnswer> onboardingAn

private boolean isFirstAlbumUpload = false;

private boolean isDeleteSampleAlbum = false;

public void updateFirstAlbumUpload() {
this.isFirstAlbumUpload = true;
}
public void updateDeleteSampleAlbum() {
this.isDeleteSampleAlbum = true;
}


public void setQna(QnA qnA) {
if (qnaList.size() >= 7) {
Expand Down

0 comments on commit f8a69a8

Please sign in to comment.