Conversation
| location.map(Point::getY).orElse(null), | ||
| location.map(Point::getX).orElse(null), | ||
| photo.getLongitude(), | ||
| photo.getLatitude(), |
There was a problem hiding this comment.
NPE 방지 로직을 photo 도메인 모델로 캡슐화했습니다.
| private static final String ORIGINAL_DIR = "original"; | ||
| private static final String THUMBNAIL_DIR = "thumbnail"; | ||
| private static final String BASE_IMAGES_DIR = "/images"; |
There was a problem hiding this comment.
사진 저장 경로 하위로 original, thumbnail 폴더를 생성합니다.
원본, 썸네일 이미지 각각 같은 이름으로 나누어 저장합니다.
There was a problem hiding this comment.
BASE_IMAGES_DIR 클라이언트에서 접근하는 기본 경로입니다.
실제 저장 경로와 다릅니다.
| 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); | ||
| } |
There was a problem hiding this comment.
FileStorage 파일 삭제 API를 추가했습니다.
|
|
||
| public Double getLatitude() { | ||
| if (Objects.isNull(location)) { | ||
| return null; | ||
| } | ||
| return location.getX(); | ||
| } | ||
|
|
||
| public Double getLongitude() { | ||
| if (Objects.isNull(location)) { | ||
| return null; | ||
| } | ||
| return location.getY(); | ||
| } |
There was a problem hiding this comment.
위치가 존재하지 않을 경우 npe 가능성이 충분해서 캡슐화했습니다.
| @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()); | ||
| } |
There was a problem hiding this comment.
사진 삭제 시 실제 이미지도 함께 삭제합니다.
| alter table photos | ||
| add column thumbnail_path text not null |
There was a problem hiding this comment.
photos 테이블에 썸네일 경로 컬럼을 추가했습니다.
| photo.getThumbnailPath(), | ||
| photo.getLongitude(), | ||
| photo.getLatitude() |
There was a problem hiding this comment.
사진조회 응답 필드로 썸네일 경로를 추가했습니다.
There was a problem hiding this comment.
A
현재 지도 사진 마커 조회 API 에서 filePath (원본 이미지 파일), thumbnailPath (리사이징된 이미지 파일) 을 모두 반환하고 있네요.
클라이언트에서 지도 사진 마커 조회를 요청했을 때는 썸네일 이미지만 반환해주고,
클라이언트가 썸네일 이미지를 클릭하면 그 때 원본 이미지를 반환해주는 것은 어떻게 생각하시나요?
어차피 이미지 파일 URL 만 보내주는 것이라 큰 상관은 없을 것이라 생각되지만 고민이 되는 부분이네요:)
There was a problem hiding this comment.
클라이언트가 썸네일 이미지를 클릭하고 원본 이미지를 반환 받기 위해 사진 마커 조회 API에서 썸네일 이미지 url을 같이 반환하는 것이 적절하다고 생각했습니다.
chanrhan
left a comment
There was a problem hiding this comment.
수고하셨습니다! 몇 가지 코멘트 확인해주세요:)
| photo.getThumbnailPath(), | ||
| photo.getLongitude(), | ||
| photo.getLatitude() |
There was a problem hiding this comment.
A
현재 지도 사진 마커 조회 API 에서 filePath (원본 이미지 파일), thumbnailPath (리사이징된 이미지 파일) 을 모두 반환하고 있네요.
클라이언트에서 지도 사진 마커 조회를 요청했을 때는 썸네일 이미지만 반환해주고,
클라이언트가 썸네일 이미지를 클릭하면 그 때 원본 이미지를 반환해주는 것은 어떻게 생각하시나요?
어차피 이미지 파일 URL 만 보내주는 것이라 큰 상관은 없을 것이라 생각되지만 고민이 되는 부분이네요:)
| 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, "파일 삭제 중 오류가 발생했습니다.") | ||
| ; |
There was a problem hiding this comment.
A
디테일한 오류 코드 정의는 정말 명확하고 좋네요:)
📌 ISSUE 번호
📄 작업 내용 요약
📢 참고 사항
✅ 체크리스트