From c3269d61eea4e357cb77890986cbb8c4f91204a7 Mon Sep 17 00:00:00 2001 From: HEY <50323157+SSung023@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:52:51 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=ED=8C=8C=EC=9D=BC=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?(#244)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 파사드 패턴 적용에 따라 FileService와 FileManager의 이름을 서로 변경 --- .../service/CertificationFacadeService.java | 8 +++--- .../facade/InstanceFacadeService.java | 8 +++--- .../facade/InstanceHomeFacadeService.java | 8 +++--- .../service/InstanceDetailFacadeService.java | 10 +++---- .../instance/service/InstanceService.java | 6 ++-- .../likes/facade/LikesFacadeService.java | 10 +++---- .../facade/MyChallengeFacadeService.java | 12 ++++---- .../challenge/user/service/UserService.java | 6 ++-- .../file/controller/FileTestController.java | 28 +++++++++---------- .../file/controller/FilesController.java | 12 ++++---- .../{FileManager.java => FileService.java} | 2 +- .../{FilesService.java => FilesManager.java} | 20 ++++++------- ...FileManager.java => LocalFileService.java} | 4 +-- ...{S3FileManager.java => S3FileService.java} | 6 ++-- .../gitget/global/util/config/AppConfig.java | 12 ++++---- .../profile/service/ProfileFacadeService.java | 14 +++++----- .../topic/facade/TopicFacadeService.java | 8 +++--- .../controller/InstanceControllerTest.java | 4 +-- .../instance/service/InstanceFacadeTest.java | 4 +-- .../likes/controller/LikesControllerTest.java | 4 +-- .../global/file/service/FileUtilTest.java | 2 +- .../controller/PaymentControllerTest.java | 4 +-- .../controller/ProfileControllerTest.java | 4 +-- .../topic/controller/TopicControllerTest.java | 4 +-- 24 files changed, 100 insertions(+), 100 deletions(-) rename src/main/java/com/genius/gitget/global/file/service/{FileManager.java => FileService.java} (99%) rename src/main/java/com/genius/gitget/global/file/service/{FilesService.java => FilesManager.java} (88%) rename src/main/java/com/genius/gitget/global/file/service/{LocalFileManager.java => LocalFileService.java} (97%) rename src/main/java/com/genius/gitget/global/file/service/{S3FileManager.java => S3FileService.java} (96%) diff --git a/src/main/java/com/genius/gitget/challenge/certification/service/CertificationFacadeService.java b/src/main/java/com/genius/gitget/challenge/certification/service/CertificationFacadeService.java index 8583ab85..022d9149 100644 --- a/src/main/java/com/genius/gitget/challenge/certification/service/CertificationFacadeService.java +++ b/src/main/java/com/genius/gitget/challenge/certification/service/CertificationFacadeService.java @@ -23,7 +23,7 @@ import com.genius.gitget.challenge.user.dto.UserProfileInfo; import com.genius.gitget.challenge.user.service.UserService; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import java.time.LocalDate; import java.util.ArrayList; import java.util.HashMap; @@ -42,7 +42,7 @@ @Transactional(readOnly = true) @RequiredArgsConstructor public class CertificationFacadeService implements CertificationFacade { - private final FilesService filesService; + private final FilesManager filesManager; private final UserService userService; private final InstanceService instanceService; @@ -167,7 +167,7 @@ public ActivatedResponse passCertification(Long userId, CertificationRequest cer certification.updateToPass(targetDate); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); return ActivatedResponse.of(instance, certification.getCertificationStatus(), 0, participant.getRepositoryName(), fileResponse); } @@ -206,7 +206,7 @@ public CertificationResponse updateCertification(User user, CertificationRequest @Override public InstancePreviewResponse getInstancePreview(Long instanceId) { Instance instance = instanceService.findInstanceById(instanceId); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); return InstancePreviewResponse.createByEntity(instance, fileResponse); } diff --git a/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceFacadeService.java b/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceFacadeService.java index e491d45c..ad3e907c 100644 --- a/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceFacadeService.java +++ b/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceFacadeService.java @@ -8,7 +8,7 @@ import com.genius.gitget.challenge.instance.dto.crud.InstanceUpdateRequest; import com.genius.gitget.challenge.instance.service.InstanceService; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import java.time.LocalDate; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -22,7 +22,7 @@ @Slf4j @Transactional public class InstanceFacadeService implements InstanceFacade { - private final FilesService filesService; + private final FilesManager filesManager; private final InstanceService instanceService; // 인스턴스 생성 @@ -56,7 +56,7 @@ public void removeInstance(Long id) { @Override public InstanceDetailResponse findOne(Long id) { Instance instance = instanceService.findInstanceById(id); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); return InstanceDetailResponse.of(instance, fileResponse); } @@ -75,7 +75,7 @@ public Page getAllInstancesOfSpecificTopic(Pageable page } private InstancePagingResponse mapToInstancePagingResponse(Instance instance) { - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); return InstancePagingResponse.of(instance, fileResponse); } } diff --git a/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceHomeFacadeService.java b/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceHomeFacadeService.java index 9f039b98..f614ac9c 100644 --- a/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceHomeFacadeService.java +++ b/src/main/java/com/genius/gitget/challenge/instance/facade/InstanceHomeFacadeService.java @@ -9,7 +9,7 @@ import com.genius.gitget.challenge.instance.service.InstanceSearchService; import com.genius.gitget.challenge.user.domain.User; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -29,7 +29,7 @@ public class InstanceHomeFacadeService implements InstanceHomeFacade { private final InstanceRecommendationService instanceRecommendationService; private final InstanceSearchService instanceSearchService; - private final FilesService filesService; + private final FilesManager filesManager; @Override public Page searchInstancesByKeywordAndProgress(InstanceSearchRequest instanceSearchRequest, @@ -54,7 +54,7 @@ public Slice findInstancesByCondition(Pageable pageable) { } private InstanceSearchResponse convertToSearchResponse(Instance instance) { - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); return InstanceSearchResponse.builder() .topicId(instance.getTopic().getId()) .instanceId(instance.getId()) @@ -72,7 +72,7 @@ private List convertToHomeInstanceResponseList(List getLikesList(User user, Pageable pageable) { for (Likes like : likesList) { Instance instance = like.getInstance(); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); UserLikesResponse userLikesResponse = getUserLikesResponse(like, instance, fileResponse); userLikesResponses.addFirst(userLikesResponse); } diff --git a/src/main/java/com/genius/gitget/challenge/myChallenge/facade/MyChallengeFacadeService.java b/src/main/java/com/genius/gitget/challenge/myChallenge/facade/MyChallengeFacadeService.java index cc4ef7a7..8af025e5 100644 --- a/src/main/java/com/genius/gitget/challenge/myChallenge/facade/MyChallengeFacadeService.java +++ b/src/main/java/com/genius/gitget/challenge/myChallenge/facade/MyChallengeFacadeService.java @@ -18,7 +18,7 @@ import com.genius.gitget.challenge.participant.service.ParticipantService; import com.genius.gitget.challenge.user.domain.User; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.store.item.domain.Item; import com.genius.gitget.store.item.service.ItemService; import com.genius.gitget.store.item.service.OrdersService; @@ -33,7 +33,7 @@ @Transactional(readOnly = true) @RequiredArgsConstructor public class MyChallengeFacadeService implements MyChallengeFacade { - private final FilesService filesService; + private final FilesManager filesManager; private final ParticipantService participantService; private final CertificationService certificationService; private final ItemService itemService; @@ -47,7 +47,7 @@ public List getPreActivityInstances(User user, LocalDate ta for (Participant participant : participants) { Instance instance = participant.getInstance(); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); int remainDays = DateUtil.getRemainDaysToStart(participant.getStartedDate(), targetDate); PreActivityResponse preActivityResponse = PreActivityResponse.of(instance, remainDays, fileResponse); @@ -64,7 +64,7 @@ public List getActivatedInstances(User user, LocalDate target for (Participant participant : participants) { Instance instance = participant.getInstance(); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); Certification certification = certificationService.findOrSave(participant, NOT_YET, targetDate); @@ -88,7 +88,7 @@ public List getDoneInstances(User user, LocalDate targetDate) { for (Participant participant : participants) { Instance instance = participant.getInstance(); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); double achievementRate = certificationService.getAchievementRate(instance, participant.getId(), targetDate); @@ -120,7 +120,7 @@ public DoneResponse getRewards(RewardRequest rewardRequest) { ); Instance instance = participant.getInstance(); - FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles()); int rewardPoints = instance.getPointPerPerson(); participantService.getRewards(participant, rewardPoints); diff --git a/src/main/java/com/genius/gitget/challenge/user/service/UserService.java b/src/main/java/com/genius/gitget/challenge/user/service/UserService.java index c6498440..67f1804b 100644 --- a/src/main/java/com/genius/gitget/challenge/user/service/UserService.java +++ b/src/main/java/com/genius/gitget/challenge/user/service/UserService.java @@ -12,7 +12,7 @@ import com.genius.gitget.challenge.user.dto.UserProfileInfo; import com.genius.gitget.challenge.user.repository.UserRepository; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.global.security.dto.AuthResponse; import com.genius.gitget.global.util.exception.BusinessException; import com.genius.gitget.global.util.exception.ErrorCode; @@ -34,7 +34,7 @@ public class UserService { private final UserRepository userRepository; private final OrdersService ordersService; - private final FilesService filesService; + private final FilesManager filesManager; private final EncryptUtil encryptUtil; private final SignoutRepository signoutRepository; @@ -126,7 +126,7 @@ public AuthResponse getUserAuthInfo(String identifier) { public UserProfileInfo getUserProfileInfo(User user) { Long frameId = ordersService.getUsingFrameItem(user.getId()).getId(); - FileResponse fileResponse = filesService.convertToFileResponse(user.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(user.getFiles()); return UserProfileInfo.createByEntity(user, frameId, fileResponse); } diff --git a/src/main/java/com/genius/gitget/global/file/controller/FileTestController.java b/src/main/java/com/genius/gitget/global/file/controller/FileTestController.java index 8c7e2089..35c9919a 100644 --- a/src/main/java/com/genius/gitget/global/file/controller/FileTestController.java +++ b/src/main/java/com/genius/gitget/global/file/controller/FileTestController.java @@ -5,8 +5,8 @@ import com.genius.gitget.global.file.domain.FileType; import com.genius.gitget.global.file.domain.Files; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FileManager; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FileService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.global.util.response.dto.CommonResponse; import com.genius.gitget.global.util.response.dto.SingleResponse; import java.util.Optional; @@ -29,16 +29,16 @@ @RequiredArgsConstructor @RequestMapping("/api/file/test") public class FileTestController { - private final FilesService filesService; - private final FileManager fileManager; + private final FilesManager filesManager; + private final FileService fileService; @GetMapping("/{fileId}") public ResponseEntity> download( @PathVariable Long fileId ) { - Files files = filesService.findById(fileId); - FileResponse fileResponse = filesService.convertToFileResponse(Optional.ofNullable(files)); + Files files = filesManager.findById(fileId); + FileResponse fileResponse = filesManager.convertToFileResponse(Optional.ofNullable(files)); return ResponseEntity.ok().body( new SingleResponse<>(SUCCESS.getStatus(), SUCCESS.getMessage(), fileResponse) @@ -51,8 +51,8 @@ public ResponseEntity> upload( @RequestParam("type") String type ) { FileType fileType = FileType.findType(type); - Files files = filesService.uploadFile(multipartFile, fileType); - String encodedImage = fileManager.getEncodedImage(files); + Files files = filesManager.uploadFile(multipartFile, fileType); + String encodedImage = fileService.getEncodedImage(files); FileResponse fileResponse = FileResponse.createExistFile(files.getId(), encodedImage); return ResponseEntity.ok().body( @@ -64,8 +64,8 @@ public ResponseEntity> upload( public ResponseEntity> update( @PathVariable Long fileId, @RequestParam("files") MultipartFile multipartFile) { - Files files = filesService.updateFile(fileId, multipartFile); - String encodedImage = fileManager.getEncodedImage(files); + Files files = filesManager.updateFile(fileId, multipartFile); + String encodedImage = fileService.getEncodedImage(files); FileResponse fileResponse = FileResponse.createExistFile(files.getId(), encodedImage); return ResponseEntity.ok().body( @@ -79,10 +79,10 @@ public ResponseEntity> copy( @RequestParam("type") String type) { FileType fileType = FileType.findType(type); - Files files = filesService.findById(fileId); - Files copiedFile = filesService.copyFile(files, fileType); + Files files = filesManager.findById(fileId); + Files copiedFile = filesManager.copyFile(files, fileType); - String encodedImage = fileManager.getEncodedImage(copiedFile); + String encodedImage = fileService.getEncodedImage(copiedFile); FileResponse fileResponse = FileResponse.createExistFile(copiedFile.getId(), encodedImage); return ResponseEntity.ok().body( @@ -94,7 +94,7 @@ public ResponseEntity> copy( public ResponseEntity delete( @PathVariable Long fileId ) { - filesService.deleteFile(fileId); + filesManager.deleteFile(fileId); return ResponseEntity.ok().body( new CommonResponse(SUCCESS.getStatus(), SUCCESS.getMessage()) diff --git a/src/main/java/com/genius/gitget/global/file/controller/FilesController.java b/src/main/java/com/genius/gitget/global/file/controller/FilesController.java index 3a3adc48..2605d665 100644 --- a/src/main/java/com/genius/gitget/global/file/controller/FilesController.java +++ b/src/main/java/com/genius/gitget/global/file/controller/FilesController.java @@ -7,7 +7,7 @@ import com.genius.gitget.global.file.domain.Files; import com.genius.gitget.global.file.dto.FileResponse; import com.genius.gitget.global.file.service.FileHolderFinder; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.global.util.response.dto.SingleResponse; import java.util.Optional; import lombok.RequiredArgsConstructor; @@ -27,7 +27,7 @@ @RequestMapping("/api/file") public class FilesController { private final FileHolderFinder finder; - private final FilesService filesService; + private final FilesManager filesManager; @PostMapping("/{id}") @@ -40,8 +40,8 @@ public ResponseEntity> uploadFile( FileHolder fileHolder = finder.findByInfo(id, fileType); Files files; - files = filesService.uploadFile(fileHolder, multipartFile, fileType); - FileResponse fileResponse = filesService.convertToFileResponse(Optional.ofNullable(files)); + files = filesManager.uploadFile(fileHolder, multipartFile, fileType); + FileResponse fileResponse = filesManager.convertToFileResponse(Optional.ofNullable(files)); return ResponseEntity.ok().body( new SingleResponse<>(SUCCESS.getStatus(), SUCCESS.getMessage(), fileResponse) @@ -56,8 +56,8 @@ public ResponseEntity> updateFile( ) { FileType fileType = FileType.findType(type); FileHolder fileHolder = finder.findByInfo(id, fileType); - Files files = filesService.updateFile(fileHolder.getFiles(), multipartFile); - FileResponse fileResponse = filesService.convertToFileResponse(Optional.ofNullable(files)); + Files files = filesManager.updateFile(fileHolder.getFiles(), multipartFile); + FileResponse fileResponse = filesManager.convertToFileResponse(Optional.ofNullable(files)); return ResponseEntity.ok().body( new SingleResponse<>(SUCCESS.getStatus(), SUCCESS.getMessage(), fileResponse) diff --git a/src/main/java/com/genius/gitget/global/file/service/FileManager.java b/src/main/java/com/genius/gitget/global/file/service/FileService.java similarity index 99% rename from src/main/java/com/genius/gitget/global/file/service/FileManager.java rename to src/main/java/com/genius/gitget/global/file/service/FileService.java index 90263563..7b6c5687 100644 --- a/src/main/java/com/genius/gitget/global/file/service/FileManager.java +++ b/src/main/java/com/genius/gitget/global/file/service/FileService.java @@ -11,7 +11,7 @@ @Service @Transactional(readOnly = true) -public interface FileManager { +public interface FileService { /** * Files 내에 저장된 값들을 통해 UrlResource 등으로 다운받은 후, base64로 인코딩한 결과 반환 diff --git a/src/main/java/com/genius/gitget/global/file/service/FilesService.java b/src/main/java/com/genius/gitget/global/file/service/FilesManager.java similarity index 88% rename from src/main/java/com/genius/gitget/global/file/service/FilesService.java rename to src/main/java/com/genius/gitget/global/file/service/FilesManager.java index 2b044a56..91cd459a 100644 --- a/src/main/java/com/genius/gitget/global/file/service/FilesService.java +++ b/src/main/java/com/genius/gitget/global/file/service/FilesManager.java @@ -22,14 +22,14 @@ @Service @Transactional(readOnly = true) @RequiredArgsConstructor -public class FilesService { - private final FileManager fileManager; +public class FilesManager { + private final FileService fileService; private final FilesRepository filesRepository; @Transactional public Files uploadFile(MultipartFile multipartFile, FileType fileType) { - FileDTO fileDTO = fileManager.upload(multipartFile, fileType); + FileDTO fileDTO = fileService.upload(multipartFile, fileType); Files file = Files.builder() .originalFilename(fileDTO.originalFilename()) @@ -45,7 +45,7 @@ public Files uploadFile(FileHolder fileHolder, MultipartFile multipartFile, File if (multipartFile == null) { throw new BusinessException(MULTIPART_FILE_NOT_EXIST); } - FileDTO fileDTO = fileManager.upload(multipartFile, fileType); + FileDTO fileDTO = fileService.upload(multipartFile, fileType); Files file = Files.builder() .originalFilename(fileDTO.originalFilename()) @@ -59,7 +59,7 @@ public Files uploadFile(FileHolder fileHolder, MultipartFile multipartFile, File @Transactional public Files copyFile(Files files, FileType fileType) { - FileDTO fileDTO = fileManager.copy(files, fileType); + FileDTO fileDTO = fileService.copy(files, fileType); Files copyFiles = Files.create(fileDTO); return filesRepository.save(copyFiles); @@ -74,7 +74,7 @@ public Files updateFile(Long fileId, MultipartFile multipartFile) { return files; } - UpdateDTO updateDTO = fileManager.update(files, multipartFile); + UpdateDTO updateDTO = fileService.update(files, multipartFile); files.updateFiles(updateDTO); return files; } @@ -86,7 +86,7 @@ public Files updateFile(Optional optionalFiles, MultipartFile multipartFi return files; } - UpdateDTO updateDTO = fileManager.update(files, multipartFile); + UpdateDTO updateDTO = fileService.update(files, multipartFile); files.updateFiles(updateDTO); return files; } @@ -101,7 +101,7 @@ public void deleteFile(Long fileId) { Files files = filesRepository.findById(fileId) .orElseThrow(() -> new BusinessException(FILE_NOT_EXIST)); - fileManager.deleteInStorage(files); + fileService.deleteInStorage(files); filesRepository.delete(files); } @@ -112,7 +112,7 @@ public void deleteFile(Optional optionalFiles) { } Files files = optionalFiles.get(); - fileManager.deleteInStorage(files); + fileService.deleteInStorage(files); filesRepository.delete(files); } @@ -124,7 +124,7 @@ public Files findById(Long fileId) { public FileResponse convertToFileResponse(Optional optionalFiles) { return optionalFiles .map(files -> { - String encodedImage = fileManager.getEncodedImage(files); + String encodedImage = fileService.getEncodedImage(files); return FileResponse.createExistFile(files.getId(), encodedImage); }) .orElseGet(FileResponse::createNotExistFile); diff --git a/src/main/java/com/genius/gitget/global/file/service/LocalFileManager.java b/src/main/java/com/genius/gitget/global/file/service/LocalFileService.java similarity index 97% rename from src/main/java/com/genius/gitget/global/file/service/LocalFileManager.java rename to src/main/java/com/genius/gitget/global/file/service/LocalFileService.java index e249ff3f..e3f57e18 100644 --- a/src/main/java/com/genius/gitget/global/file/service/LocalFileManager.java +++ b/src/main/java/com/genius/gitget/global/file/service/LocalFileService.java @@ -20,12 +20,12 @@ import org.springframework.core.io.UrlResource; import org.springframework.web.multipart.MultipartFile; -public class LocalFileManager implements FileManager { +public class LocalFileService implements FileService { private final String UPLOAD_PATH; private final FileUtil fileUtil; - public LocalFileManager(FileUtil fileUtil, @Value("${file.upload.path}") String UPLOAD_PATH) { + public LocalFileService(FileUtil fileUtil, @Value("${file.upload.path}") String UPLOAD_PATH) { this.fileUtil = fileUtil; this.UPLOAD_PATH = UPLOAD_PATH; } diff --git a/src/main/java/com/genius/gitget/global/file/service/S3FileManager.java b/src/main/java/com/genius/gitget/global/file/service/S3FileService.java similarity index 96% rename from src/main/java/com/genius/gitget/global/file/service/S3FileManager.java rename to src/main/java/com/genius/gitget/global/file/service/S3FileService.java index 5fc5c069..c895522a 100644 --- a/src/main/java/com/genius/gitget/global/file/service/S3FileManager.java +++ b/src/main/java/com/genius/gitget/global/file/service/S3FileService.java @@ -18,12 +18,12 @@ import org.springframework.core.io.UrlResource; import org.springframework.web.multipart.MultipartFile; -public class S3FileManager implements FileManager { +public class S3FileService implements FileService { private final AmazonS3 amazonS3; private final FileUtil fileUtil; private final String bucket; - public S3FileManager(AmazonS3 amazonS3, FileUtil fileUtil, String bucket) { + public S3FileService(AmazonS3 amazonS3, FileUtil fileUtil, String bucket) { this.amazonS3 = amazonS3; this.fileUtil = fileUtil; this.bucket = bucket; @@ -61,7 +61,7 @@ public FileDTO upload(MultipartFile multipartFile, FileType fileType) { @Override public FileDTO copy(Files files, FileType fileType) { validateFileExist(files); - + CopyDTO copyDTO = fileUtil.getCopyInfo(files, fileType, ""); CopyObjectRequest copyObjectRequest = new CopyObjectRequest( diff --git a/src/main/java/com/genius/gitget/global/util/config/AppConfig.java b/src/main/java/com/genius/gitget/global/util/config/AppConfig.java index 03461aac..fd90402b 100644 --- a/src/main/java/com/genius/gitget/global/util/config/AppConfig.java +++ b/src/main/java/com/genius/gitget/global/util/config/AppConfig.java @@ -1,9 +1,9 @@ package com.genius.gitget.global.util.config; -import com.genius.gitget.global.file.service.FileManager; +import com.genius.gitget.global.file.service.FileService; import com.genius.gitget.global.file.service.FileUtil; -import com.genius.gitget.global.file.service.LocalFileManager; -import com.genius.gitget.global.file.service.S3FileManager; +import com.genius.gitget.global.file.service.LocalFileService; +import com.genius.gitget.global.file.service.S3FileService; import com.genius.gitget.global.util.formatter.LocalDateFormatter; import com.genius.gitget.global.util.formatter.LocalDateTimeFormatter; import lombok.RequiredArgsConstructor; @@ -25,17 +25,17 @@ public FileUtil fileUtil() { } @Bean - public FileManager fileManager() { + public FileService fileManager() { final String fileMode = env.getProperty("file.mode"); assert fileMode != null; if (fileMode.equals("local")) { final String UPLOAD_PATH = env.getProperty("file.upload.path"); - return new LocalFileManager(fileUtil(), UPLOAD_PATH); + return new LocalFileService(fileUtil(), UPLOAD_PATH); } final String bucket = env.getProperty("cloud.aws.s3.bucket"); - return new S3FileManager(s3Config.amazonS3Client(), fileUtil(), bucket); + return new S3FileService(s3Config.amazonS3Client(), fileUtil(), bucket); } @Bean diff --git a/src/main/java/com/genius/gitget/profile/service/ProfileFacadeService.java b/src/main/java/com/genius/gitget/profile/service/ProfileFacadeService.java index d019a424..f3376061 100644 --- a/src/main/java/com/genius/gitget/profile/service/ProfileFacadeService.java +++ b/src/main/java/com/genius/gitget/profile/service/ProfileFacadeService.java @@ -11,7 +11,7 @@ import com.genius.gitget.challenge.user.domain.User; import com.genius.gitget.challenge.user.service.UserService; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.global.util.exception.BusinessException; import com.genius.gitget.profile.dto.UserChallengeResultResponse; import com.genius.gitget.profile.dto.UserDetailsInformationResponse; @@ -31,13 +31,13 @@ public class ProfileFacadeService implements ProfileFacade { private final UserService userService; private final OrdersService ordersService; - private final FilesService filesService; + private final FilesManager filesManager; public ProfileFacadeService(UserService userService, OrdersService ordersService, - FilesService filesService) { + FilesManager filesManager) { this.userService = userService; this.ordersService = ordersService; - this.filesService = filesService; + this.filesManager = filesManager; } @Override @@ -53,7 +53,7 @@ public UserPointResponse getUserPoint(User user) { public UserInformationResponse getUserInformation(Long userId) { User findUser = userService.findUserById(userId); Long frameId = ordersService.getUsingFrameItem(userId).getId(); - FileResponse fileResponse = filesService.convertToFileResponse(findUser.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(findUser.getFiles()); return UserInformationResponse.createByEntity(findUser, frameId, fileResponse); } @@ -70,7 +70,7 @@ public UserDetailsInformationResponse getUserDetailsInformation(User user) { participantCount = (joinResult == SUCCESS) ? participantCount + 1 : participantCount - 1; } } - FileResponse fileResponse = filesService.convertToFileResponse(findUser.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(findUser.getFiles()); return UserDetailsInformationResponse.createByEntity(findUser, participantCount, fileResponse); } @@ -88,7 +88,7 @@ public Long updateUserInformation(User user, UserInformationUpdateRequest userIn public void deleteUserInformation(User user, String reason) { User findUser = userService.findUserByIdentifier(user.getIdentifier()); - filesService.deleteFile(findUser.getFiles()); + filesManager.deleteFile(findUser.getFiles()); findUser.setFiles(null); findUser.deleteLikesList(); diff --git a/src/main/java/com/genius/gitget/topic/facade/TopicFacadeService.java b/src/main/java/com/genius/gitget/topic/facade/TopicFacadeService.java index 45a31007..b58254a0 100644 --- a/src/main/java/com/genius/gitget/topic/facade/TopicFacadeService.java +++ b/src/main/java/com/genius/gitget/topic/facade/TopicFacadeService.java @@ -1,7 +1,7 @@ package com.genius.gitget.topic.facade; import com.genius.gitget.global.file.dto.FileResponse; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.topic.domain.Topic; import com.genius.gitget.topic.dto.TopicCreateRequest; import com.genius.gitget.topic.dto.TopicDetailResponse; @@ -19,7 +19,7 @@ @Transactional public class TopicFacadeService implements TopicFacade { - private final FilesService filesService; + private final FilesManager filesManager; private final TopicService topicService; @@ -32,7 +32,7 @@ public Page findTopics(Pageable pageable) { @Override public TopicDetailResponse findOne(Long id) { Topic findTopic = topicService.findOne(id); - FileResponse fileResponse = filesService.convertToFileResponse(findTopic.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(findTopic.getFiles()); return TopicDetailResponse.of(findTopic, fileResponse); } @@ -62,7 +62,7 @@ public void delete(Long id) { } private TopicPagingResponse convertToTopicPagingResponseDto(Topic topic) { - FileResponse fileResponse = filesService.convertToFileResponse(topic.getFiles()); + FileResponse fileResponse = filesManager.convertToFileResponse(topic.getFiles()); return TopicPagingResponse.of(topic, fileResponse); } } diff --git a/src/test/java/com/genius/gitget/challenge/instance/controller/InstanceControllerTest.java b/src/test/java/com/genius/gitget/challenge/instance/controller/InstanceControllerTest.java index 59a209eb..346ca66a 100644 --- a/src/test/java/com/genius/gitget/challenge/instance/controller/InstanceControllerTest.java +++ b/src/test/java/com/genius/gitget/challenge/instance/controller/InstanceControllerTest.java @@ -12,7 +12,7 @@ import com.genius.gitget.challenge.instance.domain.Progress; import com.genius.gitget.challenge.instance.repository.InstanceRepository; import com.genius.gitget.challenge.user.domain.Role; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.topic.domain.Topic; import com.genius.gitget.topic.repository.TopicRepository; import com.genius.gitget.util.security.TokenTestUtil; @@ -44,7 +44,7 @@ public class InstanceControllerTest { @Autowired InstanceRepository instanceRepository; @Autowired - FilesService filesService; + FilesManager filesManager; @BeforeEach public void setup() { diff --git a/src/test/java/com/genius/gitget/challenge/instance/service/InstanceFacadeTest.java b/src/test/java/com/genius/gitget/challenge/instance/service/InstanceFacadeTest.java index 7757ebe6..f1eac0c3 100644 --- a/src/test/java/com/genius/gitget/challenge/instance/service/InstanceFacadeTest.java +++ b/src/test/java/com/genius/gitget/challenge/instance/service/InstanceFacadeTest.java @@ -16,7 +16,7 @@ import com.genius.gitget.global.file.domain.FileType; import com.genius.gitget.global.file.domain.Files; import com.genius.gitget.global.file.repository.FilesRepository; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.global.util.exception.BusinessException; import com.genius.gitget.topic.domain.Topic; import com.genius.gitget.topic.repository.TopicRepository; @@ -45,7 +45,7 @@ public class InstanceFacadeTest { @Autowired TopicRepository topicRepository; @Autowired - FilesService filesService; + FilesManager filesManager; @Autowired FilesRepository filesRepository; @Autowired diff --git a/src/test/java/com/genius/gitget/challenge/likes/controller/LikesControllerTest.java b/src/test/java/com/genius/gitget/challenge/likes/controller/LikesControllerTest.java index 9e106dc4..f5e0417f 100644 --- a/src/test/java/com/genius/gitget/challenge/likes/controller/LikesControllerTest.java +++ b/src/test/java/com/genius/gitget/challenge/likes/controller/LikesControllerTest.java @@ -19,7 +19,7 @@ import com.genius.gitget.challenge.user.domain.Role; import com.genius.gitget.challenge.user.domain.User; import com.genius.gitget.challenge.user.repository.UserRepository; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.global.security.constants.ProviderInfo; import com.genius.gitget.topic.domain.Topic; import com.genius.gitget.topic.repository.TopicRepository; @@ -54,7 +54,7 @@ public class LikesControllerTest { @Autowired InstanceRepository instanceRepository; @Autowired - FilesService filesService; + FilesManager filesManager; @Autowired LikesService likesService; @Autowired diff --git a/src/test/java/com/genius/gitget/global/file/service/FileUtilTest.java b/src/test/java/com/genius/gitget/global/file/service/FileUtilTest.java index 339a4a98..195217f9 100644 --- a/src/test/java/com/genius/gitget/global/file/service/FileUtilTest.java +++ b/src/test/java/com/genius/gitget/global/file/service/FileUtilTest.java @@ -33,7 +33,7 @@ class FileUtilTest { @Autowired private FileUtil fileUtil; @Autowired - private FilesService filesService; + private FilesManager filesManager; @Value("${file.upload.path}") private String UPLOAD_PATH; diff --git a/src/test/java/com/genius/gitget/payment/controller/PaymentControllerTest.java b/src/test/java/com/genius/gitget/payment/controller/PaymentControllerTest.java index fa7b9f97..493d4520 100644 --- a/src/test/java/com/genius/gitget/payment/controller/PaymentControllerTest.java +++ b/src/test/java/com/genius/gitget/payment/controller/PaymentControllerTest.java @@ -7,7 +7,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.fasterxml.jackson.databind.ObjectMapper; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.topic.repository.TopicRepository; import com.genius.gitget.util.security.TokenTestUtil; import com.genius.gitget.util.security.WithMockCustomUser; @@ -38,7 +38,7 @@ public class PaymentControllerTest { @Autowired TopicRepository topicRepository; @Autowired - FilesService filesService; + FilesManager filesManager; @Autowired private ObjectMapper objectMapper; diff --git a/src/test/java/com/genius/gitget/profile/controller/ProfileControllerTest.java b/src/test/java/com/genius/gitget/profile/controller/ProfileControllerTest.java index fbfa2751..44bc56ec 100644 --- a/src/test/java/com/genius/gitget/profile/controller/ProfileControllerTest.java +++ b/src/test/java/com/genius/gitget/profile/controller/ProfileControllerTest.java @@ -17,7 +17,7 @@ import com.genius.gitget.challenge.user.domain.Role; import com.genius.gitget.challenge.user.domain.User; import com.genius.gitget.challenge.user.repository.UserRepository; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.global.security.constants.ProviderInfo; import com.genius.gitget.topic.domain.Topic; import com.genius.gitget.topic.repository.TopicRepository; @@ -57,7 +57,7 @@ public class ProfileControllerTest { @Autowired InstanceRepository instanceRepository; @Autowired - FilesService filesService; + FilesManager filesManager; @Autowired LikesService likesService; @Autowired diff --git a/src/test/java/com/genius/gitget/topic/controller/TopicControllerTest.java b/src/test/java/com/genius/gitget/topic/controller/TopicControllerTest.java index 3f4193df..d190e3a2 100644 --- a/src/test/java/com/genius/gitget/topic/controller/TopicControllerTest.java +++ b/src/test/java/com/genius/gitget/topic/controller/TopicControllerTest.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.genius.gitget.challenge.user.domain.Role; -import com.genius.gitget.global.file.service.FilesService; +import com.genius.gitget.global.file.service.FilesManager; import com.genius.gitget.topic.domain.Topic; import com.genius.gitget.topic.repository.TopicRepository; import com.genius.gitget.util.security.TokenTestUtil; @@ -38,7 +38,7 @@ public class TopicControllerTest { @Autowired TopicRepository topicRepository; @Autowired - FilesService filesService; + FilesManager filesManager; @Autowired private ObjectMapper objectMapper;