-
Notifications
You must be signed in to change notification settings - Fork 0
develop 변경 내용 main으로 머지 #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fcccb9c
6116ee7
51fc96e
68ec06c
c81ad47
005b516
4da8a86
44cf962
6096e72
2ccbb6a
b9cba92
6bfba60
0f65a81
56a36d9
c384d85
9e51cf9
47e6873
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,7 +68,7 @@ public PortfolioResponse write(Long userId, PortfolioRequest request) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public PortfolioResponse edit(Long userId, Long portfolioId, PortfolioRequest request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PortfolioJpaEntity portfolio = portfolioRepository.findByIdAndUserId(portfolioId, userId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PortfolioJpaEntity portfolio = portfolioRepository.findByIdAndUser_Id(portfolioId, userId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .orElseThrow(() -> new ExpectedException(HttpStatus.NOT_FOUND, "존재하지 않는 포트폴리오입니다.")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| portfolio.update(request.title(),request.content(),request.introduce()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -92,12 +92,12 @@ public PortfolioResponse edit(Long userId, Long portfolioId, PortfolioRequest re | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public void delete(Long userId, Long portfolioId) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<PortfolioImageJpaEntity> images = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| portfolioImageRepository.findByPortfolioId(portfolioId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| portfolioImageRepository.findByPortfolio_Id(portfolioId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (PortfolioImageJpaEntity img : images) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| imageService.deleteImage(img.getImageUrl()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PortfolioJpaEntity portfolio = portfolioRepository.findByIdAndUserId(portfolioId, userId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PortfolioJpaEntity portfolio = portfolioRepository.findByIdAndUser_Id(portfolioId, userId) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .orElseThrow(() -> new ExpectedException(HttpStatus.NOT_FOUND, "존재하지 않는 포트폴리오입니다.")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| portfolioRepository.delete(portfolio); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
93
to
103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이
아래와 같이 수정하여 문제를 해결하는 것을 강력히 권장합니다.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -209,7 +209,7 @@ public void deletePortfolioImage(Long userId, Long imageId) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public List<ImageResponse> getPortfolioImages(Long portfolioId) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| List<PortfolioImageJpaEntity> images = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| portfolioImageRepository.findByPortfolioId(portfolioId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| portfolioImageRepository.findByPortfolio_Id(portfolioId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return images.stream() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(img -> new ImageResponse( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,4 +76,31 @@ protected void doFilterInternal(HttpServletRequest request, | |
| } | ||
| filterChain.doFilter(request, response); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean shouldNotFilter(HttpServletRequest request) { | ||
| String uri = request.getRequestURI(); | ||
|
|
||
| if (uri.startsWith("/api/v1/auth/sign") | ||
| || uri.startsWith("/api/v1/auth/login") | ||
| || uri.startsWith("/api/v1/auth/verify") | ||
| || uri.startsWith("/api/v1/auth/google") | ||
| || uri.startsWith("/api/v1/auth/kakao")) { | ||
| return true; | ||
| } else if (request.getMethod().equals("GET") && ( | ||
| uri.startsWith("/api/v1/main/") | ||
| || uri.startsWith("/api/v1/profile/") | ||
| || uri.startsWith("/api/v1/portfolio/view/") | ||
| || uri.startsWith("/api/v1/portfolio/comment/") | ||
| || uri.startsWith("/api/v1/blog/view/") | ||
| || uri.startsWith("/api/v1/blog/comment/"))) { | ||
| return true; | ||
| } | ||
|
|
||
| if(request.getMethod().equals("OPTIONS")) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
Comment on lines
+81
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 새로 추가된
개선 제안:
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이
delete메서드는@Transactional로 관리되고 있지만, 데이터베이스 트랜잭션 내에서 외부 시스템(Minio)의 파일을 삭제하는 로직이 있어 데이터 불일치 위험이 있습니다.imageService.deleteImage()호출이 반복문 중간에 실패할 경우,imageService.deleteImage()로 성공적으로 삭제된 파일들은 외부 저장소에서 영구적으로 사라지며 복구되지 않습니다.이로 인해 DB에는 존재하지만 실제 파일은 없는 '깨진 데이터'가 발생할 수 있습니다.
개선 제안:
데이터베이스 작업과 외부 시스템 호출을 분리하는 것을 고려해 보세요. 예를 들어, 트랜잭션이 성공적으로 커밋된 후에만 파일을 삭제하도록
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)를 사용하는 방법이 있습니다. 이렇게 하면 DB 작업의 원자성을 보장하면서 외부 시스템과의 상호작용으로 인한 부작용을 최소화할 수 있습니다.