Skip to content

Commit

Permalink
✅ 버킷리스트에서 유저 정보 전체 긁어오기
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdals4716 committed Oct 31, 2024
1 parent c18b1e6 commit a1dd411
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/main/java/com/example/moyeothon/Service/BucketService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,21 @@ public ResponseDto updateBucket(Long id, String uid, RequestDto requestDto, User
}

// 해당 유저 버킷리스트 전체 조회
public List<ResponseDto> getUserAllBucket(String uid, UserDetails userDetails){
public List<ResponseDto> getUserAllBucket(String uid, UserDetails userDetails) {
if (!userDetails.getUsername().equals(uid)) {
throw new RuntimeException("인증되지 않은 유저입니다.");
}
List<BucketlistEntity> bucketlistEntityList = bucketRepository.findByUser_Uid(uid);
List<ResponseDto> responseDtoList = new ArrayList<>();
for(BucketlistEntity bucket : bucketlistEntityList){
responseDtoList.add(new ResponseDto(bucket));
}
return responseDtoList;
return bucketRepository.findByUser_Uid(uid).stream()
.map(ResponseDto::entityToDto)
.collect(Collectors.toList());
}

// 버킷리스트 전체 조회
public List<ResponseDto> getAllBucket(String uid, UserDetails userDetails) {
if (!userDetails.getUsername().equals(uid)) {
throw new RuntimeException("인증되지 않은 유저입니다.");
}
List<BucketlistEntity> bucketlistEntityList = bucketRepository.findAll();
List<ResponseDto> responseDtoList = new ArrayList<>();
for (BucketlistEntity bucket : bucketlistEntityList) {
if (bucket.isPublic() || (bucket.getUser().getUid().equals(uid))) {
responseDtoList.add(new ResponseDto(bucket));
}
}
return responseDtoList;
return bucketRepository.findAll().stream().map(ResponseDto::entityToDto).collect(Collectors.toList());
}

// 제목, 내용 키워드별로 버킷리스트 검색하기
Expand Down

0 comments on commit a1dd411

Please sign in to comment.