Skip to content

Conversation

@kih1015
Copy link
Contributor

@kih1015 kih1015 commented Nov 20, 2025

📌 ISSUE 번호

📄 작업 내용 요약

  • 썸네일 이미지 추가
  • 사진 삭제 시, 실제 이미지 삭제
  • 사진 조회 응답값에 썸네일 이미지 경로 추가

📢 참고 사항

✅ 체크리스트

  • ISSUE 번호 연결 했나요?
  • Reviewers 지정 했나요?
  • Assignees 지정 했나요?
  • Labels 지정 했나요?

@kih1015 kih1015 requested a review from chanrhan November 20, 2025 02:58
@kih1015 kih1015 self-assigned this Nov 20, 2025
@kih1015 kih1015 added the enhancement New feature or request label Nov 20, 2025
Comment on lines -60 to +62
location.map(Point::getY).orElse(null),
location.map(Point::getX).orElse(null),
photo.getLongitude(),
photo.getLatitude(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NPE 방지 로직을 photo 도메인 모델로 캡슐화했습니다.

Comment on lines +26 to +28
private static final String ORIGINAL_DIR = "original";
private static final String THUMBNAIL_DIR = "thumbnail";
private static final String BASE_IMAGES_DIR = "/images";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

사진 저장 경로 하위로 original, thumbnail 폴더를 생성합니다.
원본, 썸네일 이미지 각각 같은 이름으로 나누어 저장합니다.

Copy link
Contributor Author

@kih1015 kih1015 Nov 20, 2025

Choose a reason for hiding this comment

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

BASE_IMAGES_DIR 클라이언트에서 접근하는 기본 경로입니다.

실제 저장 경로와 다릅니다.

Comment on lines +68 to +87
public void deleteOriginalImage(String originalPath) {
String fileName = Paths.get(originalPath).getFileName().toString();
Path sourceLocation = this.originalLocation.resolve(fileName);

try {
Files.delete(sourceLocation);
} catch (IOException e) {
throw CustomException.of(ApiResponseCode.FILE_DELETE_FAILED);
}
}

public void deleteThumbnailImage(String thumbnailPath) {
String fileName = Paths.get(thumbnailPath).getFileName().toString();
Path sourceLocation = this.thumbnailLocation.resolve(fileName);

try {
Files.delete(sourceLocation);
} catch (IOException e) {
throw CustomException.of(ApiResponseCode.FILE_DELETE_FAILED);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FileStorage 파일 삭제 API를 추가했습니다.

Comment on lines +74 to +87

public Double getLatitude() {
if (Objects.isNull(location)) {
return null;
}
return location.getX();
}

public Double getLongitude() {
if (Objects.isNull(location)) {
return null;
}
return location.getY();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

위치가 존재하지 않을 경우 npe 가능성이 충분해서 캡슐화했습니다.

Comment on lines 76 to 82
@Transactional
public void deletePhotos(DeletePhotosRequest request) {
List<Photo> photos = photoRepository.findAllById(request.ids());
photos.forEach(photo -> fileStorage.deleteOriginalImage(photo.getFilePath()));
photos.forEach(photo -> fileStorage.deleteThumbnailImage(photo.getFilePath()));
photoRepository.deleteAllByIdInBatch(request.ids());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

사진 삭제 시 실제 이미지도 함께 삭제합니다.

Comment on lines +1 to +2
alter table photos
add column thumbnail_path text not null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

photos 테이블에 썸네일 경로 컬럼을 추가했습니다.

Comment on lines +47 to +49
photo.getThumbnailPath(),
photo.getLongitude(),
photo.getLatitude()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

사진조회 응답 필드로 썸네일 경로를 추가했습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A

현재 지도 사진 마커 조회 API 에서 filePath (원본 이미지 파일), thumbnailPath (리사이징된 이미지 파일) 을 모두 반환하고 있네요.

클라이언트에서 지도 사진 마커 조회를 요청했을 때는 썸네일 이미지만 반환해주고,
클라이언트가 썸네일 이미지를 클릭하면 그 때 원본 이미지를 반환해주는 것은 어떻게 생각하시나요?

어차피 이미지 파일 URL 만 보내주는 것이라 큰 상관은 없을 것이라 생각되지만 고민이 되는 부분이네요:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

클라이언트가 썸네일 이미지를 클릭하고 원본 이미지를 반환 받기 위해 사진 마커 조회 API에서 썸네일 이미지 url을 같이 반환하는 것이 적절하다고 생각했습니다.

Copy link
Collaborator

@chanrhan chanrhan left a comment

Choose a reason for hiding this comment

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

수고하셨습니다! 몇 가지 코멘트 확인해주세요:)

Comment on lines +47 to +49
photo.getThumbnailPath(),
photo.getLongitude(),
photo.getLatitude()
Copy link
Collaborator

Choose a reason for hiding this comment

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

A

현재 지도 사진 마커 조회 API 에서 filePath (원본 이미지 파일), thumbnailPath (리사이징된 이미지 파일) 을 모두 반환하고 있네요.

클라이언트에서 지도 사진 마커 조회를 요청했을 때는 썸네일 이미지만 반환해주고,
클라이언트가 썸네일 이미지를 클릭하면 그 때 원본 이미지를 반환해주는 것은 어떻게 생각하시나요?

어차피 이미지 파일 URL 만 보내주는 것이라 큰 상관은 없을 것이라 생각되지만 고민이 되는 부분이네요:)

Comment on lines +62 to +66
FILE_STORE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "파일 저장 중 오류가 발생했습니다."),
FILE_CREATION_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "파일 생성 중 오류가 발생했습니다."),
DIRECTORY_CREATION_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "폴더 생성 중 오류가 발생했습니다."),
FILE_DELETE_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "파일 삭제 중 오류가 발생했습니다.")
;
Copy link
Collaborator

Choose a reason for hiding this comment

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

A

디테일한 오류 코드 정의는 정말 명확하고 좋네요:)

@kih1015 kih1015 merged commit 06a9edd into develop Nov 20, 2025
1 check passed
@kih1015 kih1015 deleted the feature/35-add-thumbnail branch November 20, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 이미지 리사이징

3 participants