Skip to content

Conversation

@ckkim817
Copy link
Member

💡 Issue

📄 Description

  • AWS S3 SDK v2 마이그레이션에 따른 Presigned URL 획득 로직 수정
  • Presigned URL 획득 과정에 이미지 파일 확장자를 검증하는 로직 추가
  • apply_spot 테이블에서 관리하던 신청 장소 데이터들을 spot 테이블로 통합
  • spot 데이터 삽입 전까지 임시 s3 경로에 저장하던 이미지들을 정상 경로로 이동시키는 로직 추가
  • 누락되어 있던 Member 탈퇴 시 연관 엔티티 cascade delete 처리 로직 추가

@ckkim817 ckkim817 requested a review from Copilot September 11, 2025 13:32
@ckkim817 ckkim817 self-assigned this Sep 11, 2025
@ckkim817 ckkim817 added 🛠️ FIX 버그, 오류 등을 수정 ♻️ REFACTOR 코드 리팩토링 🐈‍⬛ 창균 size/L labels Sep 11, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the application to AWS S3 SDK v2 and consolidates the spot application data management by integrating previously separated tables. The major changes include updating the S3 adapter for presigned URL generation with file validation, consolidating apply_spot data into the main spot table, and adding cascade delete functionality for member withdrawal.

  • AWS S3 SDK v2 migration with enhanced file validation and presigned URL generation
  • Table consolidation: moving apply_spot data directly into spot table with status tracking
  • Member withdrawal cascade delete implementation for related entities

Reviewed Changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
S3Adapter.java Complete migration to AWS SDK v2 with file validation and move operations
SpotService.java Refactored spot application logic to use main spot table instead of separate apply_spot table
SpotEntity.java Added appliedMemberId and spotStatus fields to support consolidated data model
MemberService.java Updated presigned URL generation with file extension validation and cascade delete logic
ImageType.java Enhanced with file extension validation and content type mapping
SpotStatus.java New enum to track spot application status

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

DISCARDED,
;

private static final Map<String, SpotStatus> SPOT_STATUS_MAP = new HashMap<>();
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using EnumMap instead of HashMap for better performance and type safety when mapping enum values.

Copilot uses AI. Check for mistakes.
Comment on lines +657 to +660
for (String imageUrl : request.imageList()) {
s3Adapter.validateImageExists(imageUrl);
}

Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validating images individually in a loop can be inefficient for large image lists. Consider batch validation or parallel processing for better performance.

Suggested change
for (String imageUrl : request.imageList()) {
s3Adapter.validateImageExists(imageUrl);
}
request.imageList().parallelStream().forEach(s3Adapter::validateImageExists);

Copilot uses AI. Check for mistakes.
Comment on lines +663 to +670
for (String imageUrl : request.imageList()) {
String fileName = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
String destinationKey = String.format("spots/%d/spot/%s", spotId, fileName);

String newImageUrl = s3Adapter.moveFile(imageUrl, destinationKey);
movedImageList.add(newImageUrl);
}

Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving files sequentially in a loop can be slow for multiple images. Consider using parallel processing or batch operations for S3 file moves.

Suggested change
for (String imageUrl : request.imageList()) {
String fileName = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
String destinationKey = String.format("spots/%d/spot/%s", spotId, fileName);
String newImageUrl = s3Adapter.moveFile(imageUrl, destinationKey);
movedImageList.add(newImageUrl);
}
movedImageList.addAll(
request.imageList().parallelStream()
.map(imageUrl -> {
String fileName = imageUrl.substring(imageUrl.lastIndexOf("/") + 1);
String destinationKey = String.format("spots/%d/spot/%s", spotId, fileName);
return s3Adapter.moveFile(imageUrl, destinationKey);
})
.collect(Collectors.toList())
);

Copilot uses AI. Check for mistakes.

private final List<String> allowedExtensions;

private static final Map<String, ImageType> IMAGE_TYPE_MAP = new HashMap<>();
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using EnumMap instead of HashMap for better performance and type safety when mapping enum values.

Copilot uses AI. Check for mistakes.
Comment on lines +718 to +721
preferenceRepository.deleteById(memberId);
guidedSpotRepository.deleteAllByMemberId(memberId);
savedSpotRepository.deleteAllByMemberId(memberId);
verifiedAreaRepository.deleteAllByMemberId(memberId);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sequential deletion operations can be inefficient. Consider using @transactional with batch operations or database cascade delete constraints for better performance.

Suggested change
preferenceRepository.deleteById(memberId);
guidedSpotRepository.deleteAllByMemberId(memberId);
savedSpotRepository.deleteAllByMemberId(memberId);
verifiedAreaRepository.deleteAllByMemberId(memberId);
// Related entities are deleted via cascade delete from MemberEntity.

Copilot uses AI. Check for mistakes.
@ckkim817 ckkim817 merged commit f688e32 into develop Sep 11, 2025
1 check passed
@ckkim817 ckkim817 deleted the refactor/#118 branch September 11, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ FIX 버그, 오류 등을 수정 ♻️ REFACTOR 코드 리팩토링 size/L 🐈‍⬛ 창균

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] AWS S3 SDK v2 마이그레이션 및 분리되어 있던 테이블 통합

2 participants