Skip to content

Commit

Permalink
[Fix] confilct 해결 #151
Browse files Browse the repository at this point in the history
  • Loading branch information
parseyong committed Oct 1, 2024
2 parents 25fa1aa + 7275c9a commit 1451f88
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public interface ProfileService {
/* loginId에 해당하는 User가 Tag된 snap들을 조회합니다 */
List<ProfileTagSnapResDto> getTagSnap(String email);


}
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ public List<ProfileTagSnapResDto> getTagSnap(String email) {
return profileRepository.findTagSnap(user);
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public record SnapDetailInfoResDto(
List<TagUserFindResDto> tagUserFindResDtos,
Long likeCnt,
boolean isLikedSnap

) {
public static SnapDetailInfoResDto toDto(Tuple tuple, String profilePhotoURL, String snapPhotoURL,
List<TagUserFindResDto> tagUserFindResDtos, Long likeCnt, boolean isLikedSnap){
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/me/snaptime/snap/service/impl/SnapServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,20 @@ public Long createSnap(CreateSnapReqDto createSnapReqDto, String userEmail, bool
}

@Override
public SnapDetailInfoResDto findSnap(Long id, String userEmail) {
Snap foundSnap = snapRepository.findById(id).orElseThrow(() -> new CustomException(ExceptionCode.SNAP_NOT_EXIST));
if(foundSnap.isPrivate()) {
User foundUser = userRepository.findByEmail(userEmail).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST));
// Snap이 비공개라면, 요청한 유저와 스냅의 ID가 일치하는지 확인한다.
if (!Objects.equals(foundUser.getUserId(), foundSnap.getUser().getUserId())) {
throw new CustomException(ExceptionCode.SNAP_IS_PRIVATE);
public SnapDetailInfoResDto findSnap(Long id, String userEmail) {
Snap foundSnap = snapRepository.findById(id).orElseThrow(() -> new CustomException(ExceptionCode.SNAP_NOT_EXIST));
if(foundSnap.isPrivate()) {
User foundUser = userRepository.findByEmail(userEmail).orElseThrow(() -> new CustomException(ExceptionCode.USER_NOT_EXIST));
// Snap이 비공개라면, 요청한 유저와 스냅의 ID가 일치하는지 확인한다.
if (!Objects.equals(foundUser.getUserId(), foundSnap.getUser().getUserId())) {
throw new CustomException(ExceptionCode.SNAP_IS_PRIVATE);
}
}
}

String snapPhotoUrl = urlComponent.makePhotoURL(foundSnap.getFileName(), foundSnap.isPrivate());
String profilePhotoUrl = urlComponent.makeProfileURL(foundSnap.getUser().getProfilePhoto().getProfilePhotoId());
List<TagUserFindResDto> tagUserFindResDtos = snapTagService.findTagUsers(foundSnap.getId(), userEmail);

Long likeCnt = snapLikeService.findSnapLikeCnt(foundSnap.getId());
boolean isLikedSnap = snapLikeService.isLikedSnap(foundSnap.getId(), userEmail);
return SnapDetailInfoResDto.toDto(foundSnap, profilePhotoUrl, snapPhotoUrl, tagUserFindResDtos, likeCnt, isLikedSnap);
Expand Down
Binary file modified src/main/resources/test_resource/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1451f88

Please sign in to comment.