Skip to content

Commit

Permalink
refactor: 파일 클래스 이름 변경
Browse files Browse the repository at this point in the history
- 파사드 패턴 적용에 따라 FileService와 FileManager의 이름을 서로 변경
  • Loading branch information
SSung023 committed Aug 14, 2024
1 parent 5ef6720 commit 68f356c
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +22,7 @@
@Slf4j
@Transactional
public class InstanceFacadeService implements InstanceFacade {
private final FilesService filesService;
private final FilesManager filesManager;
private final InstanceService instanceService;

// 인스턴스 생성
Expand Down Expand Up @@ -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);
}
Expand All @@ -75,7 +75,7 @@ public Page<InstancePagingResponse> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<InstanceSearchResponse> searchInstancesByKeywordAndProgress(InstanceSearchRequest instanceSearchRequest,
Expand All @@ -54,7 +54,7 @@ public Slice<HomeInstanceResponse> 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())
Expand All @@ -72,7 +72,7 @@ private List<HomeInstanceResponse> convertToHomeInstanceResponseList(List<Instan
}

private HomeInstanceResponse mapToHomeInstanceResponse(Instance instance) {
FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles());
FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles());
return HomeInstanceResponse.createByEntity(instance, fileResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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 java.time.LocalDate;
import org.kohsuke.github.GitHub;
Expand All @@ -27,17 +27,17 @@
public class InstanceDetailFacadeService implements InstanceDetailFacade {

private final InstanceService instanceService;
private final FilesService filesService;
private final FilesManager filesManager;
private final ParticipantService participantService;
private final LikesService likesService;
private final UserService userService;
private final GithubService githubService;

public InstanceDetailFacadeService(InstanceService instanceService, FilesService filesService,
public InstanceDetailFacadeService(InstanceService instanceService, FilesManager filesManager,
ParticipantService participantService, LikesService likesService,
UserService userService, GithubService githubService) {
this.instanceService = instanceService;
this.filesService = filesService;
this.filesManager = filesManager;
this.participantService = participantService;
this.likesService = likesService;
this.userService = userService;
Expand All @@ -51,7 +51,7 @@ public InstanceResponse getInstanceDetailInformation(User user, Long instanceId)
Instance instance = instanceService.findInstanceById(instanceId);

// 파일 객체 생성
FileResponse fileResponse = filesService.convertToFileResponse(instance.getFiles());
FileResponse fileResponse = filesManager.convertToFileResponse(instance.getFiles());

// 좋아요 정보
LikesInfo likesInfo = likesService.getLikesInfo(user.getId(), instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.genius.gitget.challenge.instance.dto.crud.InstanceUpdateDTO;
import com.genius.gitget.challenge.instance.repository.InstanceRepository;
import com.genius.gitget.global.file.domain.Files;
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.global.util.exception.ErrorCode;
import com.genius.gitget.topic.domain.Topic;
Expand All @@ -28,7 +28,7 @@
public class InstanceService {
private final InstanceRepository instanceRepository;
private final TopicRepository topicRepository;
private final FilesService filesService;
private final FilesManager filesManager;

@NotNull
private String getUuid() {
Expand Down Expand Up @@ -82,7 +82,7 @@ public void removeInstance(Long id) {
Long filesId = files != null ? files.getId() : null;

if (filesId != null) {
filesService.deleteFile(filesId);
filesManager.deleteFile(filesId);
instance.setFiles(null);
}
instanceRepository.delete(instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.genius.gitget.challenge.likes.service.LikesService;
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.LinkedList;
import java.util.List;
import org.springframework.data.domain.Page;
Expand All @@ -19,11 +19,11 @@
public class LikesFacadeService implements LikesFacade {

LikesService likesService;
FilesService filesService;
FilesManager filesManager;

public LikesFacadeService(LikesService likesService, FilesService filesService) {
public LikesFacadeService(LikesService likesService, FilesManager filesManager) {
this.likesService = likesService;
this.filesService = filesService;
this.filesManager = filesManager;
}

@Override
Expand All @@ -34,7 +34,7 @@ public Page<UserLikesResponse> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -47,7 +47,7 @@ public List<PreActivityResponse> 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);
Expand All @@ -64,7 +64,7 @@ public List<ActivatedResponse> 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);

Expand All @@ -88,7 +88,7 @@ public List<DoneResponse> 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);

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SingleResponse<FileResponse>> 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)
Expand All @@ -51,8 +51,8 @@ public ResponseEntity<SingleResponse<FileResponse>> 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(
Expand All @@ -64,8 +64,8 @@ public ResponseEntity<SingleResponse<FileResponse>> upload(
public ResponseEntity<SingleResponse<FileResponse>> 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(
Expand All @@ -79,10 +79,10 @@ public ResponseEntity<SingleResponse<FileResponse>> 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(
Expand All @@ -94,7 +94,7 @@ public ResponseEntity<SingleResponse<FileResponse>> copy(
public ResponseEntity<CommonResponse> delete(
@PathVariable Long fileId
) {
filesService.deleteFile(fileId);
filesManager.deleteFile(fileId);

return ResponseEntity.ok().body(
new CommonResponse(SUCCESS.getStatus(), SUCCESS.getMessage())
Expand Down
Loading

0 comments on commit 68f356c

Please sign in to comment.