From fbe63abd415e97790a5a295a4cb9c19fbe8f8ed8 Mon Sep 17 00:00:00 2001 From: bflykky Date: Sun, 18 Aug 2024 20:41:46 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=82=AC=EC=A7=84=20=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=8B=9C=20save()=20=EB=8C=80=EC=8B=A0=20saveAll()?= =?UTF-8?q?=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../naoman/domain/photo/service/PhotoServiceImpl.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java b/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java index 7852de5..5bb8495 100644 --- a/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java @@ -170,8 +170,9 @@ public PhotoUploadInfo uploadPhotoList(PhotoUploadRequest request, Member member long startTime = System.currentTimeMillis(); // 사진 URL 리스트를 기반으로 사진 엔티티를 생성하고 DB에 저장 List photoList = request.getPhotoUrlList().stream() - .map(photoUrl -> checkAndSavePhotoInDB(photoUrl, extractPhotoNameFromUrl(photoUrl), shareGroup)) + .map(photoUrl -> checkAndCreatePhoto(photoUrl, extractPhotoNameFromUrl(photoUrl), shareGroup)) .toList(); + photoRepository.saveAll(photoList); long finishTime = System.currentTimeMillis(); log.info("저장한 사진 개수: {} 장", photoList.size()); log.info("해당 사진 목록을 DB에 저장하는 데 걸린 시간: {} ms", finishTime - startTime); @@ -197,7 +198,8 @@ public PhotoUploadInfo uploadPhotoList(PhotoUploadRequest request, Member member } // S3에 객체의 존재 여부 확인 및 DB에 사진을 저장하고 객체를 반환하는 메서드 - private Photo checkAndSavePhotoInDB(String photoUrl, String photoName, ShareGroup shareGroup) { +// private Photo checkAndSavePhotoInDB(String photoUrl, String photoName, ShareGroup shareGroup) { + private Photo checkAndCreatePhoto(String photoUrl, String photoName, ShareGroup shareGroup) { long startTime = System.currentTimeMillis(); if (!amazonS3.doesObjectExist(BUCKET_NAME, RAW_PATH_PREFIX + "/" + photoName)) { throw new BusinessException(PHOTO_NOT_FOUND_S3); @@ -205,8 +207,9 @@ private Photo checkAndSavePhotoInDB(String photoUrl, String photoName, ShareGrou long finishTime = System.currentTimeMillis(); log.info("amazonS3.doesObjectExists() 수행 시간: {} ms", finishTime - startTime); - Photo photo = photoConverter.toEntity(photoUrl, photoName, shareGroup); - return photoRepository.save(photo); // 저장된 Photo 객체 반환 + return photoConverter.toEntity(photoUrl, photoName, shareGroup); +// Photo photo = photoConverter.toEntity(photoUrl, photoName, shareGroup); +// return photoRepository.save(photo); // 저장된 Photo 객체 반환 } // 사진 URL에서 사진 이름을 추출하는 메서드