Skip to content

Commit

Permalink
Merge pull request #86 from HyeJiJUN11/feature/85-friendDiary
Browse files Browse the repository at this point in the history
feat: 친구 일기 수정
  • Loading branch information
peeerr authored Nov 5, 2024
2 parents 7cad1f3 + 8e785ec commit 34ea26a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public FriendDiaryResponse getFriendDiary(Long memberId, Long diaryId) {
Diary diary = diaryRepository.findById(diaryId)
.orElseThrow(() -> new GlobalException(ErrorCode.DIARY_NOT_FOUND));

if(!diary.isPublic()){
throw new GlobalException(ErrorCode.DIARY_NOT_PUBLIC);
}

//글쓴사람이 친구인지 확인
Member currentMember = memberRepository.findById(memberId)
.orElseThrow(() -> new GlobalException(ErrorCode.MEMBER_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -49,10 +50,10 @@ public OneFriendDiariesResponse OneFriendDiariesResponse(Long memberid, Long fri
friendRepository.findByMemberAndFriend(currentMember, friend)
.orElseThrow(() -> new GlobalException(ErrorCode.FRIEND_NOT_FOUND));

Pageable pageable = PageRequest.of(key, size);
Pageable pageable = PageRequest.of(key, size, Sort.by(Sort.Direction.DESC, "createAt"));

Page<Diary> diaries = diaryRepository.findAll(
DiarySpecification.filterDiaries(null, null, null, date, null, null, null)
FriendDiarySpecification.filterDiaries(null, null, null, date, null, null)
.and((root, query, builder) -> builder.equal(root.get("member").get("id"), friendId)),
pageable);

Expand Down

0 comments on commit 34ea26a

Please sign in to comment.