-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: AgendaPhotoService 클래스에 nullifyPhotoInAgendaPhotoList(List<Long>…
… photoIdList) 구현 CQRS 패턴에 따라 PhotoService에서 PhotoQueryService를 분화시켜 순환 참조를 방지하였다.
- Loading branch information
Showing
10 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,8 @@ public void delete() { | |
} | ||
super.delete(); | ||
} | ||
|
||
public void nullifyPhoto() { | ||
this.photo = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/umc/naoman/domain/photo/service/PhotoQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.umc.naoman.domain.photo.service; | ||
|
||
import com.umc.naoman.domain.member.entity.Member; | ||
import com.umc.naoman.domain.photo.entity.Photo; | ||
|
||
public interface PhotoQueryService { | ||
Photo findPhoto(Long photoId); | ||
boolean hasSamplePhoto(Member member); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/umc/naoman/domain/photo/service/PhotoQueryServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.umc.naoman.domain.photo.service; | ||
|
||
import com.umc.naoman.domain.member.entity.Member; | ||
import com.umc.naoman.domain.photo.entity.Photo; | ||
import com.umc.naoman.domain.photo.repository.PhotoRepository; | ||
import com.umc.naoman.domain.photo.repository.SamplePhotoRepository; | ||
import com.umc.naoman.global.error.BusinessException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import static com.umc.naoman.global.error.code.S3ErrorCode.PHOTO_NOT_FOUND; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class PhotoQueryServiceImpl implements PhotoQueryService { | ||
private final PhotoRepository photoRepository; | ||
private final SamplePhotoRepository samplePhotoRepository; | ||
|
||
@Override | ||
public Photo findPhoto(Long photoId) { | ||
return photoRepository.findById(photoId) | ||
.orElseThrow(() -> new BusinessException(PHOTO_NOT_FOUND)); | ||
} | ||
|
||
@Override | ||
public boolean hasSamplePhoto(Member member) { | ||
return samplePhotoRepository.existsByMemberId(member.getId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters