Skip to content

Commit

Permalink
Merge pull request #204 from CHZZK-Study/dev
Browse files Browse the repository at this point in the history
[release] 일기 공개 범위 수정 api 추가
  • Loading branch information
HongYeseul authored Oct 28, 2024
2 parents 0b6ddeb + a6718aa commit 27cb3d3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public DiaryUpdateResponseDTO update(
return diaryService.update(diaryId, requestDto);
}

@PatchMapping("/{diaryId}/visibility")
public ResponseEntity<?> updateVisibility(
@PathVariable(name = "diaryId") Long diaryId,
@AuthenticatedMember AuthMemberPayload loginMember) {
diaryService.updateVisibility(diaryId, loginMember.id());
return ResponseEntity.noContent().build();
}

@DeleteMapping("/{diaryId}")
public Long delete(@PathVariable(name = "diaryId") Long diaryId,
@AuthenticatedMember AuthMemberPayload payload) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/chzzk/grassdiary/domain/diary/entity/Diary.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public void update(String content, Boolean isPrivate, Boolean hasTag,
this.conditionLevel = conditionLevel;
}

public void updateVisibility() {
this.isPrivate = !this.isPrivate;
}

public LocalDateTime getCreatedAt() {
return super.getCreatedAt();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public DiaryUpdateResponseDTO update(Long id, DiaryUpdateRequestDTO requestDto)
return updateDiary(requestDto, originalDiary);
}

@Transactional
public void updateVisibility(Long diaryId, Long loginMemberId) {
Diary diary = getDiaryById(diaryId);

validateDiaryOwner(diary, loginMemberId);
diary.updateVisibility();
}

/**
* diaryId를 이용해서 diaryTag, MemberTag 를 찾아내기 diaryTag 삭제 -> deleteAllInBatch 고려해보기 MemberTag 삭제 해당 일기의 좋아요 찾기 및 삭제
* 이미지 삭제
Expand Down

0 comments on commit 27cb3d3

Please sign in to comment.