Skip to content

Comments

feat: 유저픽 게시글 수정 기능 구현#106

Merged
hisonghy merged 5 commits intodevelopfrom
feature/update-post-105
Apr 28, 2025
Merged

feat: 유저픽 게시글 수정 기능 구현#106
hisonghy merged 5 commits intodevelopfrom
feature/update-post-105

Conversation

@hisonghy
Copy link
Member

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • 유저픽 게시글 수정 기능 구현했습니다
  • 유저픽 게시글 수정 로직에서 post 수정, post_image 추가/삭제, post_product 추가/수정/삭제, post_product_image 추가, 삭제 등 코드가 너무 길어져서 각 service 단을 나누어서 구현했습니다
  • 상품 이미지 파일과 각 매핑되는 imageIndex 필드를 검증하는 로직을 Validator 클래스로 두고 공유해서 사용할 수 있도록 했고, 게시글 저장 로직에서도 유효성을 검증하는 방법이 동일해 PostProductValidator 를 사용하도록 수정했습니다
로직 흐름 정리

==========================
1. Post
==========================

// 1-1. Post 수정
// - 게시글(Post) 기본 정보 수정

==========================
2. PostImage
==========================

// 2-1. Post 이미지 추가
// - 기존 이미지가 기본(default) 이미지였다면:
//    1. 기존 기본 이미지 삭제
//    2. 새 이미지 데이터 저장
// - 기본 이미지가 아니었다면:
//    1. 새 이미지 데이터 추가 저장

// 2-2. Post 이미지 삭제
// - 요청된 이미지 삭제
// - 삭제 결과 모든 이미지가 삭제된 경우:
//    - 기본(default) 이미지 저장

==========================
3. PostProduct
==========================

// 3-1. PostProduct 추가
// - 새로운 상품(PostProduct) 추가

// 3-2. PostProduct 수정
// - 기존 상품(PostProduct) 정보 수정

// 3-3. PostProduct 삭제
// - 기존 상품(PostProduct) 삭제

==========================
4. PostProductImage
==========================

// 4-1. PostProduct 이미지 추가
// - 새 상품에 새 이미지 추가

// 4-2. PostProduct 이미지 수정
// - 다음 예외 케이스 고려:
//    - 기본(default) 이미지 삭제 요청
//    - 기존 상품 이미지 존재 + 새 이미지 업로드 요청
//    - 다른 상품의 이미지 잘못 삭제 요청

// 4-3. PostProduct 이미지 삭제
// - 요청된 상품 이미지 삭제

🔍 참고사항

  • 트랜잭션 롤백, 커밋 이벤트를 활용해서 롤백 이벤트 발생 시 업로드된 이미지 파일들을 삭제하고, 커밋 이벤트 발생 시 삭제할 이미지 파일을 삭제하도록 구현했습니다. 만약 먼저 S3 이미지 파일을 삭제하게되면 롤백 발생 시 삭제했던 이미지 파일을 복구하는 작업이 번거로워서 커밋 이벤트 발생 시 실제 이미지 파일을 스토리지에서 삭제될 수 있도록 했습니다

📚 기타

@hisonghy hisonghy added the ⚡ feature 새로운 기능 추가 및 수정 label Apr 27, 2025
@hisonghy hisonghy self-assigned this Apr 27, 2025
@hisonghy hisonghy force-pushed the feature/update-post-105 branch from dfc80b9 to 5abfac6 Compare April 28, 2025 04:52
@hisonghy hisonghy merged commit 75f9924 into develop Apr 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚡ feature 새로운 기능 추가 및 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

⚡ 유저픽 게시글 수정 API 구현

2 participants