From a3a6bcc4b06712b83d5664575125468464eafc4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=ED=99=8D=EC=8B=9D?= <90020593+Daolove0323@users.noreply.github.com> Date: Sun, 10 Nov 2024 21:51:47 +0900 Subject: [PATCH] =?UTF-8?q?[Weekly/11/Feature/RestClientUtil]=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=EC=B6=94=EA=B0=80,=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20(#106)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: restClient, objectMapper util로 이동 * fix: 이미지 삭제 * feat: applicationTest 임시주석 --- .../wouldyouin/Image/api/ImageController.java | 34 +++----- .../AdvertisementImageService.java | 17 ++-- .../application/CurationImageService.java | 9 +- .../Image/application/EventImageService.java | 14 ++-- .../Image/application/ImageService.java | 13 ++- .../application/ImageServiceFactory.java | 11 +-- .../Image/application/ImageStorage.java | 83 ------------------- .../application/ImageStorageService.java | 54 ++++++++++++ .../Image/application/MemberImageService.java | 14 ++-- .../{config => api}/ParamDefaults.java | 2 +- .../_common/config/RestClientConfig.java | 14 ++++ .../wouldyouin/_common/error/ErrorCode.java | 2 + .../exception/ExtensionParsingException.java | 10 +++ .../wouldyouin/_common/persist/Area.java | 21 ----- .../wouldyouin/_common/persist/Category.java | 12 --- .../wouldyouin/_common/persist/Location.java | 17 ---- .../wouldyouin/_common/util/FileUtil.java | 69 +++++++++++++++ .../wouldyouin/_common/util/KakaoPayUtil.java | 33 ++++++++ .../_common/util/RestClientUtil.java | 30 +++++++ .../application/AdvertisementService.java | 6 +- .../advertisement/persist/Advertisement.java | 1 - .../wouldyouin/auth/api/AuthController.java | 10 +-- .../dto/LocalLoginRequest.java | 2 +- .../auth/api/dto/LocalSignupRequest.java | 6 ++ .../dto/SocialTokenResponse.java | 2 +- .../dto/TokenResponse.java | 2 +- .../auth/application/AuthService.java | 14 ++-- .../application/dto/LocalSignupRequest.java | 6 -- .../curation/api/CurationController.java | 2 +- .../curation/api/dto/CurationResponse.java | 2 +- .../wouldyouin/event/api/EventController.java | 7 +- .../event/api/dto/EventResponse.java | 2 +- .../event/api/dto/EventSliceResponse.java | 3 - .../api/dto/LocationFilter.java | 2 +- .../vo => event/api/dto}/UserLocation.java | 2 +- .../event/application/EventService.java | 4 +- .../wouldyouin/event/persist/Event.java | 5 +- .../wouldyouin/like/api/LikeController.java | 6 +- .../dto/LikeResponse.java | 2 +- .../dto/LikeToggleResponse.java | 3 +- .../like/application/LikeService.java | 4 +- .../member/api/CuratorController.java | 4 +- .../wouldyouin/member/api/HostController.java | 4 +- .../member/api/MemberController.java | 8 +- .../dto/MemberResponse.java | 2 +- .../dto/relation/EventHostResponse.java | 2 +- .../relation/ReservationMemberResponse.java | 2 +- .../CurationCuratorResponse.java | 2 +- .../ReviewMemberResponse.java | 2 +- .../request/MemberAdditionalInfoRequest.java | 2 +- .../dto/request/create/HostCreateRequest.java | 3 +- .../request/create/MemberCreateRequest.java | 2 +- .../create/MemberCreateRequestBase.java | 2 +- .../dto/request/edit/CuratorEditRequest.java | 2 +- .../dto/request/edit/HostEditRequest.java | 2 +- .../dto/request/edit/MemberEditRequest.java | 2 +- .../request/edit/MemberEditRequestBase.java | 2 +- .../member/application/BaseMemberService.java | 2 +- .../member/application/CuratorService.java | 4 +- .../member/application/HostService.java | 8 +- .../member/application/MemberService.java | 8 +- .../MemberServiceCommonBehavior.java | 2 +- .../wouldyouin/member/persist/Member.java | 2 +- .../payment/application/PaymentService.java | 63 ++++---------- .../api/ReservationController.java | 2 +- .../api/dto/ReservationResponse.java | 2 +- .../application/ReservationService.java | 1 - .../review/api/ReviewController.java | 6 +- .../dto/ReviewCreateRequest.java | 2 +- .../dto/ReviewEditRequest.java | 2 +- .../dto/ReviewResponse.java | 4 +- .../review/application/ReviewService.java | 6 +- .../wouldyouin/review/persist/Review.java | 2 +- src/main/resources/application.yml | 14 ++-- .../WouldYouInApplicationTests.java | 7 +- .../cokaen/wouldyouin/_global/TestData.java | 4 +- .../curation/CurationControllerUnitTest.java | 1 - .../event/EventControllerUnitTest.java | 5 +- .../event/EventServiceUnitTest.java | 6 +- .../BaseMemberServiceUnitTest.java | 2 +- .../application/CuratorServiceUnitTest.java | 2 +- .../application/HostServiceUnitTest.java | 6 +- .../application/MemberServiceUnitTest.java | 6 +- 83 files changed, 394 insertions(+), 370 deletions(-) delete mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorage.java create mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorageService.java rename src/main/java/org/ktc2/cokaen/wouldyouin/_common/{config => api}/ParamDefaults.java (86%) create mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/config/RestClientConfig.java create mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/exception/ExtensionParsingException.java delete mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Area.java delete mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Category.java delete mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Location.java create mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/FileUtil.java create mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/KakaoPayUtil.java create mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/RestClientUtil.java rename src/main/java/org/ktc2/cokaen/wouldyouin/auth/{application => api}/dto/LocalLoginRequest.java (54%) create mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/LocalSignupRequest.java rename src/main/java/org/ktc2/cokaen/wouldyouin/auth/{application => api}/dto/SocialTokenResponse.java (66%) rename src/main/java/org/ktc2/cokaen/wouldyouin/auth/{application => api}/dto/TokenResponse.java (79%) delete mode 100644 src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/LocalSignupRequest.java rename src/main/java/org/ktc2/cokaen/wouldyouin/{curation => event}/api/dto/LocationFilter.java (87%) rename src/main/java/org/ktc2/cokaen/wouldyouin/{_common/vo => event/api/dto}/UserLocation.java (94%) rename src/main/java/org/ktc2/cokaen/wouldyouin/like/{application => api}/dto/LikeResponse.java (93%) rename src/main/java/org/ktc2/cokaen/wouldyouin/like/{application => api}/dto/LikeToggleResponse.java (77%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/MemberResponse.java (97%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/relation/EventHostResponse.java (92%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/relation/ReservationMemberResponse.java (77%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/relationResponse/CurationCuratorResponse.java (92%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/relationResponse/ReviewMemberResponse.java (66%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/MemberAdditionalInfoRequest.java (81%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/create/HostCreateRequest.java (90%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/create/MemberCreateRequest.java (94%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/create/MemberCreateRequestBase.java (82%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/edit/CuratorEditRequest.java (88%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/edit/HostEditRequest.java (88%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/edit/MemberEditRequest.java (87%) rename src/main/java/org/ktc2/cokaen/wouldyouin/member/{application => api}/dto/request/edit/MemberEditRequestBase.java (81%) rename src/main/java/org/ktc2/cokaen/wouldyouin/review/{application => api}/dto/ReviewCreateRequest.java (87%) rename src/main/java/org/ktc2/cokaen/wouldyouin/review/{application => api}/dto/ReviewEditRequest.java (74%) rename src/main/java/org/ktc2/cokaen/wouldyouin/review/{application => api}/dto/ReviewResponse.java (88%) diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/api/ImageController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/api/ImageController.java index 9ca3a74d..951dc481 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/api/ImageController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/api/ImageController.java @@ -1,17 +1,13 @@ package org.ktc2.cokaen.wouldyouin.Image.api; -import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin.Image.api.dto.ImageResponse; import org.ktc2.cokaen.wouldyouin.Image.application.ImageServiceFactory; +import org.ktc2.cokaen.wouldyouin.Image.application.ImageStorageService; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponse; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponseBody; -import org.ktc2.cokaen.wouldyouin._common.exception.FailToReadImageException; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -26,37 +22,31 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api") +@RequestMapping("/api/images") public class ImageController { private final ImageServiceFactory imageServiceFactory; + private final ImageStorageService imageStorageService; + + @GetMapping(value = "/{directory}/{file}", produces = {MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_JPEG_VALUE}) + public ResponseEntity getImage(@PathVariable String directory, @PathVariable String file) { + return ResponseEntity.status(HttpStatus.OK).body(imageStorageService.readFromDirectory(Paths.get(directory, file))); + } // Todo: authorize - @PostMapping("/images") + @PostMapping public ResponseEntity>> uploadImages( @RequestParam List images, @RequestParam(value = "type") ImageDomain imageDomain) { - return ApiResponse.ok(imageServiceFactory.getImageServiceByImageType(imageDomain).saveAndCreateImages(images)); - } - - // Todo: path 수정, service로 로직이동 - @GetMapping(value = "images/{domain}/{path}", produces = {MediaType.IMAGE_PNG_VALUE, MediaType.IMAGE_JPEG_VALUE}) - public ResponseEntity getImage(@PathVariable String domain, @PathVariable String path) { - try { - Resource resource = new ClassPathResource("static/images/" + domain + "/" + path); - System.out.println(Paths.get("static/images", domain, path)); - return ResponseEntity.status(HttpStatus.OK).body(Files.readAllBytes(resource.getFile().toPath())); - } catch (IOException e) { - throw new FailToReadImageException("이미지를 읽어오는데 실패했습니다."); - } + return ApiResponse.ok(imageServiceFactory.getImageService(imageDomain).saveImages(images)); } // Todo: authorize - @DeleteMapping("/images/{id}") + @DeleteMapping("/{id}") public ResponseEntity> deleteImage( @PathVariable Long id, @RequestParam(value = "type") ImageDomain imageDomain) { - imageServiceFactory.getImageServiceByImageType(imageDomain).deleteAndDelete(id); + imageServiceFactory.getImageService(imageDomain).deleteAndDelete(id); return ApiResponse.noContent(); } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/AdvertisementImageService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/AdvertisementImageService.java index 1c8a87df..413d75e4 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/AdvertisementImageService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/AdvertisementImageService.java @@ -16,10 +16,10 @@ @RequiredArgsConstructor public class AdvertisementImageService extends ImageService { - private final ImageStorage imageStorage; + @Value("${image.upload.ad.child-path}") + private String childPath; + private final ImageStorageService imageStorageService; private final AdvertisementImageRepository adImageRepository; - @Value("${image.upload.ad.sub-path}") - private String subPath; @Override protected ImageRepository getImageRepository() { @@ -32,8 +32,8 @@ protected ImageDomain getImageDomain() { } @Override - protected String getSubPath() { - return subPath; + protected String getChildPath() { + return childPath; } @Override @@ -45,13 +45,12 @@ protected AdvertisementImage toEntity(ImageRequest imageRequest) { } @Transactional - public AdvertisementImage saveAndCreateImage(MultipartFile image) { - String path = imageStorage.save(image, getSubPath()); - return adImageRepository.save(toEntity(ImageRequest.of(path, image.getSize(), ImageStorage.getExtension(image)))); + public AdvertisementImage saveImage(MultipartFile image) { + return adImageRepository.save(toEntity(imageStorageService.saveToDirectory(image, getChildPath()))); } @Transactional - public void setAd(AdvertisementImage image, Advertisement ad) { + public void setAdvertisement(AdvertisementImage image, Advertisement ad) { image.setAdvertisement(ad); } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/CurationImageService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/CurationImageService.java index 54d141de..2af86340 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/CurationImageService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/CurationImageService.java @@ -15,11 +15,10 @@ @RequiredArgsConstructor public class CurationImageService extends ImageService { + @Value("${image.upload.curation.child-path}") + private String childPath; private final CurationImageRepository curationImageRepository; - @Value("${image.upload.curation.sub-path}") - private String subPath; - @Override public ImageRepository getImageRepository() { return curationImageRepository; @@ -31,8 +30,8 @@ protected ImageDomain getImageDomain() { } @Override - protected String getSubPath() { - return subPath; + protected String getChildPath() { + return childPath; } @Override diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/EventImageService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/EventImageService.java index c650bafe..821c433e 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/EventImageService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/EventImageService.java @@ -15,11 +15,10 @@ @Service public class EventImageService extends ImageService { + @Value("${image.upload.event.child-path}") + private String childPath; private final EventImageRepository eventImageRepository; - @Value("${image.upload.event.sub-path}") - private String subPath; - @Override public ImageRepository getImageRepository() { return eventImageRepository; @@ -31,13 +30,16 @@ protected ImageDomain getImageDomain() { } @Override - protected String getSubPath() { - return subPath; + protected String getChildPath() { + return childPath; } @Override protected EventImage toEntity(ImageRequest imageRequest) { - return EventImage.builder().url(imageRequest.getUrl()).size(imageRequest.getSize()).build(); + return EventImage.builder() + .url(imageRequest.getUrl()) + .size(imageRequest.getSize()) + .build(); } @Transactional diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageService.java index 5b9f1eea..b4f1506e 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageService.java @@ -19,7 +19,7 @@ public abstract class ImageService { @Autowired - protected ImageStorage imageStorage; + protected ImageStorageService imageStorageService; @Value("${spring.wouldyouin-domain-name}") private String domainName; @@ -28,7 +28,7 @@ public abstract class ImageService { protected abstract ImageDomain getImageDomain(); - protected abstract String getSubPath(); + protected abstract String getChildPath(); protected abstract T toEntity(ImageRequest imageRequest); @@ -47,12 +47,9 @@ protected void delete(Long id) { } @Transactional - public List saveAndCreateImages(List images) { + public List saveImages(List images) { return images.stream() - .map(image -> { - String path = imageStorage.save(image, getSubPath()); - return create(ImageRequest.of(path, image.getSize(), ImageStorage.getExtension(image))); - }) + .map(image -> create(imageStorageService.saveToDirectory(image, getChildPath()))) .toList(); } @@ -60,6 +57,6 @@ public List saveAndCreateImages(List images) { public void deleteAndDelete(Long id) { T image = getById(id); delete(id); - imageStorage.delete(image.getUrl()); + imageStorageService.delete(image.getUrl()); } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageServiceFactory.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageServiceFactory.java index 329a411b..6c825456 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageServiceFactory.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageServiceFactory.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; import java.util.stream.Collectors; import org.ktc2.cokaen.wouldyouin.Image.api.ImageDomain; import org.ktc2.cokaen.wouldyouin.Image.persist.Image; @@ -10,14 +11,14 @@ @Component public class ImageServiceFactory { - private final ConcurrentHashMap> imageTypeToImageServiceMap; + private final ConcurrentHashMap> imageServiceMap; public ImageServiceFactory(List> imageServices) { - imageTypeToImageServiceMap = new ConcurrentHashMap<>(imageServices.stream() - .collect(Collectors.toConcurrentMap(ImageService::getImageDomain, imageService -> imageService))); + imageServiceMap = new ConcurrentHashMap<>(imageServices.stream() + .collect(Collectors.toConcurrentMap(ImageService::getImageDomain, Function.identity()))); } - public ImageService getImageServiceByImageType(ImageDomain imageDomain) { - return imageTypeToImageServiceMap.get(imageDomain); + public ImageService getImageService(ImageDomain imageDomain) { + return imageServiceMap.get(imageDomain); } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorage.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorage.java deleted file mode 100644 index dc953d58..00000000 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorage.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.ktc2.cokaen.wouldyouin.Image.application; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; -import org.ktc2.cokaen.wouldyouin.Image.api.dto.ImageRequest; -import org.ktc2.cokaen.wouldyouin._common.exception.FailedToDeleteImageException; -import org.ktc2.cokaen.wouldyouin._common.exception.FailedToUploadImageException; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.client.RestClient; -import org.springframework.web.multipart.MultipartFile; - -@Component -public class ImageStorage { - - @Value("${image.upload.common-path}") - private String commonPath; - - public String save(MultipartFile image, String subPath) { - String fileName = ""; - try { - fileName = generateUuidName() + "." + getExtension(image); - Path path = Paths.get(commonPath, subPath, fileName); - Files.createDirectories(path.getParent()); - Files.write(path, image.getBytes()); - } catch (IOException ex) { - throw new FailedToUploadImageException("이미지를 업로드하는데 실패했습니다."); - } - return subPath + "/" + fileName; - } - - // Todo: payment랑 이부분 restclient 유틸로 빼기 - public ImageRequest save(String imageUrl, String subPath) { - RestClient client = RestClient.builder().build(); - String fileName = ""; - Long size = 0L; - try { - ResponseEntity response = client.get() - .uri(imageUrl) - .retrieve() - .toEntity(byte[].class); - - if (Optional.ofNullable(response.getBody()).isPresent() && response.getStatusCode().is2xxSuccessful()) { - fileName = generateUuidName() + "." + getExtension(imageUrl); - size = (long) response.getBody().length; - Path path = Paths.get(commonPath, subPath, fileName); - Files.createDirectories(path.getParent()); - Files.write(path, response.getBody()); - } - } catch (IOException ex) { - throw new FailedToUploadImageException("URL을 통해 이미지를 저장하는데 실패했습니다."); - } - String url = subPath + "/" + fileName; - return ImageRequest.of(url, size, getExtension(imageUrl)); - } - - public void delete(String imagePath) { - try { - Files.deleteIfExists(Paths.get(imagePath)); - } catch (IOException ex) { - throw new FailedToDeleteImageException("이미지를 삭제하는데 실패했습니다."); - } - } - - protected static String getExtension(MultipartFile image) { - return Objects.requireNonNull(image.getContentType()).split("/")[1]; - } - - protected static String getExtension(String imageUrl) { - String[] splitted = imageUrl.split("\\."); - return splitted[splitted.length - 1]; - } - - private static String generateUuidName() { - return UUID.randomUUID().toString().replace("-", ""); - } -} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorageService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorageService.java new file mode 100644 index 00000000..5b68d448 --- /dev/null +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/ImageStorageService.java @@ -0,0 +1,54 @@ +package org.ktc2.cokaen.wouldyouin.Image.application; + +import java.nio.file.Path; +import java.nio.file.Paths; +import lombok.RequiredArgsConstructor; +import org.ktc2.cokaen.wouldyouin.Image.api.dto.ImageRequest; +import org.ktc2.cokaen.wouldyouin._common.exception.FailedToUploadImageException; +import org.ktc2.cokaen.wouldyouin._common.util.FileUtil; +import org.ktc2.cokaen.wouldyouin._common.util.RestClientUtil; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +@Component +@RequiredArgsConstructor +public class ImageStorageService { + + @Value("${image.upload.parent-path}") + private String parentPath; + private final RestClientUtil client; + + public byte[] readFromDirectory(Path path) { + return FileUtil.readFile(Paths.get(parentPath).resolve(path)); + } + + public ImageRequest saveToDirectory(MultipartFile image, String subPath) { + String extension = FileUtil.getExtension(image); + String fileName = FileUtil.generateUuidName() + "." + extension; + Path path = Paths.get(parentPath, subPath, fileName); + FileUtil.saveFile(image, path); + return ImageRequest.of(path.toString(), image.getSize(), FileUtil.getExtension(image)); + } + + public ImageRequest saveToDirectory(String imageUrl, String subPath) { + ResponseEntity response = client.get(imageUrl, byte[].class); + if (response.getBody() == null) { + throw new FailedToUploadImageException("응답 본문이 비어있어 이미지를 가져올 수 없습니다."); + } + if (!response.getStatusCode().is2xxSuccessful()) { + throw new FailedToUploadImageException("이미지 URL에 대한 요청을 실패하였습니다."); + } + String extension = FileUtil.getExtension(imageUrl); + String fileName = FileUtil.generateUuidName() + "." + extension; + Path path = Paths.get(parentPath, subPath, fileName); + FileUtil.saveFile(response.getBody(), path); + long size = response.getBody().length; + return ImageRequest.of(path.toString(), size, extension); + } + + public void delete(String imagePath) { + FileUtil.deleteFile(Paths.get(imagePath)); + } +} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/MemberImageService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/MemberImageService.java index 01772b1a..c791b08e 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/MemberImageService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/Image/application/MemberImageService.java @@ -7,7 +7,6 @@ import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImage; import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImageRepository; import org.ktc2.cokaen.wouldyouin.member.persist.BaseMember; -import org.ktc2.cokaen.wouldyouin.member.persist.BaseMemberRepository; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -16,11 +15,9 @@ @RequiredArgsConstructor public class MemberImageService extends ImageService { + @Value("${image.upload.member.child-path}") + private String childPath; private final MemberImageRepository memberImageRepository; - private final BaseMemberRepository baseMemberRepository; - - @Value("${image.upload.member.sub-path}") - private String subPath; @Override public ImageRepository getImageRepository() { @@ -33,8 +30,8 @@ protected ImageDomain getImageDomain() { } @Override - protected String getSubPath() { - return subPath; + protected String getChildPath() { + return childPath; } @Override @@ -51,6 +48,7 @@ public void setBaseMember(MemberImage image, BaseMember member) { } public MemberImage convert(String imageUrl) { - return memberImageRepository.save(toEntity(imageStorage.save(imageUrl, subPath))); + ImageRequest imageRequest = imageStorageService.saveToDirectory(imageUrl, childPath); + return memberImageRepository.save(toEntity(imageRequest)); } } \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/config/ParamDefaults.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/api/ParamDefaults.java similarity index 86% rename from src/main/java/org/ktc2/cokaen/wouldyouin/_common/config/ParamDefaults.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/_common/api/ParamDefaults.java index 5e4bfdd3..e317393f 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/config/ParamDefaults.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/api/ParamDefaults.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin._common.config; +package org.ktc2.cokaen.wouldyouin._common.api; public class ParamDefaults { diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/config/RestClientConfig.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/config/RestClientConfig.java new file mode 100644 index 00000000..a4655caa --- /dev/null +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/config/RestClientConfig.java @@ -0,0 +1,14 @@ +package org.ktc2.cokaen.wouldyouin._common.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestClient; + +@Configuration +public class RestClientConfig { + + @Bean + RestClient restClient() { + return RestClient.builder().build(); + } +} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/error/ErrorCode.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/error/ErrorCode.java index 16824078..9140ed01 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/error/ErrorCode.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/error/ErrorCode.java @@ -24,6 +24,8 @@ public enum ErrorCode { FAIL_TO_DELETE_IMAGE(HttpStatus.CONFLICT.value(), "-20400", "Fail to delete image"), + URL_PARSING_FAILED(HttpStatus.BAD_REQUEST.value(), "-20400", "URL 파싱에 실패했습니다."), + CURRENT_LOCATION_EMPTY(HttpStatus.BAD_REQUEST.value(), "-20400", "현재 위치 정보를 찾을 수 없습니다."); private final Integer status; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/exception/ExtensionParsingException.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/exception/ExtensionParsingException.java new file mode 100644 index 00000000..b07099b7 --- /dev/null +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/exception/ExtensionParsingException.java @@ -0,0 +1,10 @@ +package org.ktc2.cokaen.wouldyouin._common.exception; + +import org.ktc2.cokaen.wouldyouin._common.error.ErrorCode; + +public class ExtensionParsingException extends BusinessException { + + public ExtensionParsingException(String message) { + super(message, ErrorCode.URL_PARSING_FAILED); + } +} diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Area.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Area.java deleted file mode 100644 index 7c9dcf98..00000000 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Area.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.ktc2.cokaen.wouldyouin._common.persist; - -public enum Area { - 전체, - 서울, - 인천, - 경기도, - 강원도, - 충청남도, - 충청북도, - 경상북도, - 대전, - 대구, - 울산, - 전라북도, - 경상남도, - 부산, - 광주, - 전라남도, - 제주도 -} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Category.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Category.java deleted file mode 100644 index 5d30389b..00000000 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Category.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.ktc2.cokaen.wouldyouin._common.persist; - -public enum Category { - 전체, - 밴드, - 연극, - 뮤지컬, - 원데이클래스, - 전시회, - 공예, - 축제 -} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Location.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Location.java deleted file mode 100644 index ab3cfe59..00000000 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/persist/Location.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.ktc2.cokaen.wouldyouin._common.persist; - -import jakarta.persistence.Embeddable; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -@Embeddable -public class Location { - Double longitude; - Double latitude; -} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/FileUtil.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/FileUtil.java new file mode 100644 index 00000000..d4ff27db --- /dev/null +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/FileUtil.java @@ -0,0 +1,69 @@ +package org.ktc2.cokaen.wouldyouin._common.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import org.ktc2.cokaen.wouldyouin._common.exception.ExtensionParsingException; +import org.ktc2.cokaen.wouldyouin._common.exception.FailToReadImageException; +import org.ktc2.cokaen.wouldyouin._common.exception.FailedToUploadImageException; +import org.springframework.web.multipart.MultipartFile; + +public class FileUtil { + + public static byte[] readFile(Path path) { + try { + return Files.readAllBytes(path); + } catch (IOException e) { + throw new FailToReadImageException("파일을 읽어오는데 실패했습니다."); + } + } + + public static void saveFile(MultipartFile file, Path path) { + try { + Files.createDirectories(path.getParent()); + Files.write(path, file.getBytes()); + } catch (IOException e) { + throw new FailedToUploadImageException("디렉토리에 파일을 저장하는데 실패했습니다."); + } + } + + public static void saveFile(byte[] file, Path path) { + try { + Files.createDirectories(path.getParent()); + Files.write(path, file); + } catch (IOException e) { + throw new FailedToUploadImageException("디렉토리에 파일을 저장하는데 실패했습니다."); + } + } + + public static void deleteFile(Path path) { + try { + Files.deleteIfExists(path); + } catch (IOException e) { + throw new FailedToUploadImageException("해당 경로의 파일을 삭제하는데 실패했습니다."); + } + } + + public static String generateUuidName() { + return UUID.randomUUID().toString().replace("-", ""); + } + + public static String getExtension(MultipartFile file) { + if (file == null || file.getContentType() == null) { + throw new ExtensionParsingException("파일이 존재하지 않거나 콘텐츠 타입이 없습니다."); + } + try { + return file.getContentType().split("/")[1]; + } catch (ArrayIndexOutOfBoundsException e) { + throw new ExtensionParsingException("파일의 확장자를 찾을 수 없습니다."); + } + } + + public static String getExtension(String url) { + if (url == null || !url.contains(".")) { + throw new ExtensionParsingException("URL이 존재하지 않거나 확장자가 없습니다."); + } + return url.substring(url.lastIndexOf('.') + 1); + } +} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/KakaoPayUtil.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/KakaoPayUtil.java new file mode 100644 index 00000000..5d160970 --- /dev/null +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/KakaoPayUtil.java @@ -0,0 +1,33 @@ +package org.ktc2.cokaen.wouldyouin._common.util; + +import java.util.HashMap; +import java.util.Map; +import org.ktc2.cokaen.wouldyouin.payment.dto.KakaoPayRequest; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; + +public class KakaoPayUtil { + + public static HttpHeaders createKakaoPayRequestHeaders(String kakaoPayRequestHost, String secretKey) { + HttpHeaders headers = new HttpHeaders(); + headers.add("Host", kakaoPayRequestHost); + headers.add("Authorization", "SECRET_KEY " + secretKey); + headers.setContentType(MediaType.APPLICATION_JSON); + return headers; + } + + public static Map createKakaoPayRequestBody(KakaoPayRequest kakaoPayRequest, String approvalUrl, String cancelUrl, String failUrl) { + Map body = new HashMap<>(); + body.put("cid", "TC0ONETIME"); + body.put("partner_order_id", kakaoPayRequest.getReservationId()); + body.put("partner_user_id", kakaoPayRequest.getHostId()); + body.put("item_name", kakaoPayRequest.getEventName()); + body.put("quantity", kakaoPayRequest.getQuantity()); + body.put("total_amount", kakaoPayRequest.getTotalAmount()); + body.put("tax_free_amount", kakaoPayRequest.getTaxFreeAmount()); + body.put("approval_url", approvalUrl); + body.put("cancel_url", cancelUrl); + body.put("fail_url", failUrl); + return body; + } +} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/RestClientUtil.java b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/RestClientUtil.java new file mode 100644 index 00000000..464d4200 --- /dev/null +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/_common/util/RestClientUtil.java @@ -0,0 +1,30 @@ +package org.ktc2.cokaen.wouldyouin._common.util; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestClient; + +@Component +@RequiredArgsConstructor +public class RestClientUtil { + + private final RestClient client; + + public ResponseEntity get(String url, Class classType) { + return client.get() + .uri(url) + .retrieve() + .toEntity(classType); + } + + public ResponseEntity post(String url, HttpHeaders headers, B body, Class classType) { + return client.post() + .uri(url) + .headers(httpHeaders -> httpHeaders.addAll(headers)) + .body(body) + .retrieve() + .toEntity(classType); + } +} \ No newline at end of file diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/application/AdvertisementService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/application/AdvertisementService.java index 4004da27..2bf7a1f4 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/application/AdvertisementService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/application/AdvertisementService.java @@ -42,9 +42,9 @@ public List getAllActiveAdvertisements() { // Todo: 롤백될 경우, 저장한 이미지 삭제 @Transactional public AdvertisementResponse create(AdvertisementRequest adRequest, MultipartFile image) { - AdvertisementImage adImage = adImageService.saveAndCreateImage(image); + AdvertisementImage adImage = adImageService.saveImage(image); Advertisement ad = adRepository.save(adRequest.toEntity(adImage)); - adImageService.setAd(adImage, ad); + adImageService.setAdvertisement(adImage, ad); return AdvertisementResponse.from(ad); } @@ -56,7 +56,7 @@ public AdvertisementResponse update(Long adId, AdvertisementRequest adRequest, M Optional.ofNullable(multipartFile).ifPresentOrElse( image -> { adImageService.deleteAndDelete(ad.getAdvertisementImage().getId()); - AdvertisementImage adImage = adImageService.saveAndCreateImage(image); + AdvertisementImage adImage = adImageService.saveImage(image); ad.updateFrom(adRequest, adImage); adImage.setAdvertisement(ad); }, diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/persist/Advertisement.java b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/persist/Advertisement.java index f154f5a4..f6fef66f 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/persist/Advertisement.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/advertisement/persist/Advertisement.java @@ -14,7 +14,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import org.hibernate.annotations.Comment; import org.ktc2.cokaen.wouldyouin.Image.persist.AdvertisementImage; import org.ktc2.cokaen.wouldyouin.advertisement.api.dto.AdvertisementRequest; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/AuthController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/AuthController.java index 3c886902..f7ca6699 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/AuthController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/AuthController.java @@ -6,11 +6,11 @@ import org.ktc2.cokaen.wouldyouin.auth.Authorize; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; import org.ktc2.cokaen.wouldyouin.auth.application.AuthService; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.LocalLoginRequest; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.LocalSignupRequest; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.SocialTokenResponse; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.TokenResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.MemberAdditionalInfoRequest; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.LocalLoginRequest; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.LocalSignupRequest; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.SocialTokenResponse; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.TokenResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.MemberAdditionalInfoRequest; import org.ktc2.cokaen.wouldyouin.member.persist.AccountType; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/LocalLoginRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/LocalLoginRequest.java similarity index 54% rename from src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/LocalLoginRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/LocalLoginRequest.java index 1011fab3..6a18a892 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/LocalLoginRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/LocalLoginRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.auth.application.dto; +package org.ktc2.cokaen.wouldyouin.auth.api.dto; public record LocalLoginRequest(String email, String password) { } diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/LocalSignupRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/LocalSignupRequest.java new file mode 100644 index 00000000..2032ae26 --- /dev/null +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/LocalSignupRequest.java @@ -0,0 +1,6 @@ +package org.ktc2.cokaen.wouldyouin.auth.api.dto; + +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.HostCreateRequest; + +public class LocalSignupRequest extends HostCreateRequest { +} diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/SocialTokenResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/SocialTokenResponse.java similarity index 66% rename from src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/SocialTokenResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/SocialTokenResponse.java index 4dfce018..bfdb4f43 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/SocialTokenResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/SocialTokenResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.auth.application.dto; +package org.ktc2.cokaen.wouldyouin.auth.api.dto; import lombok.Builder; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/TokenResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/TokenResponse.java similarity index 79% rename from src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/TokenResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/TokenResponse.java index 37a4b667..0ebae147 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/TokenResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/api/dto/TokenResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.auth.application.dto; +package org.ktc2.cokaen.wouldyouin.auth.api.dto; import lombok.Builder; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/AuthService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/AuthService.java index 127a50a1..6a8a1a38 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/AuthService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/AuthService.java @@ -3,18 +3,18 @@ import java.util.Optional; import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.LocalLoginRequest; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.LocalSignupRequest; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.SocialTokenResponse; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.TokenResponse; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.LocalLoginRequest; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.LocalSignupRequest; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.SocialTokenResponse; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.TokenResponse; import org.ktc2.cokaen.wouldyouin.auth.application.oauth.OauthRequestServiceFactory; import org.ktc2.cokaen.wouldyouin.auth.application.oauth.dto.OauthResourcesResponse; import org.ktc2.cokaen.wouldyouin.member.application.BaseMemberService; import org.ktc2.cokaen.wouldyouin.member.application.HostService; import org.ktc2.cokaen.wouldyouin.member.application.MemberService; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.MemberAdditionalInfoRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.MemberCreateRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.MemberAdditionalInfoRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.MemberCreateRequest; import org.ktc2.cokaen.wouldyouin.member.persist.AccountType; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; import org.springframework.stereotype.Service; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/LocalSignupRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/LocalSignupRequest.java deleted file mode 100644 index 748ff493..00000000 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/auth/application/dto/LocalSignupRequest.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.ktc2.cokaen.wouldyouin.auth.application.dto; - -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.HostCreateRequest; - -public class LocalSignupRequest extends HostCreateRequest { -} diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/CurationController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/CurationController.java index f411d948..d4857d2d 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/CurationController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/CurationController.java @@ -4,7 +4,7 @@ import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponse; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponseBody; -import org.ktc2.cokaen.wouldyouin._common.config.ParamDefaults; +import org.ktc2.cokaen.wouldyouin._common.api.ParamDefaults; import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin.auth.Authorize; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationResponse.java index 65489c61..7bd2e697 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/CurationResponse.java @@ -7,7 +7,7 @@ import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin.curation.persist.Curation; import org.ktc2.cokaen.wouldyouin.event.api.dto.relationResonse.CurationEventResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.relationResponse.CurationCuratorResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.relationResponse.CurationCuratorResponse; @Builder @Getter diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/EventController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/EventController.java index 9230416a..5f411434 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/EventController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/EventController.java @@ -4,14 +4,13 @@ import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponse; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponseBody; -import org.ktc2.cokaen.wouldyouin._common.config.ParamDefaults; +import org.ktc2.cokaen.wouldyouin._common.api.ParamDefaults; import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin._common.vo.Category; -import org.ktc2.cokaen.wouldyouin._common.vo.Location; -import org.ktc2.cokaen.wouldyouin._common.vo.UserLocation; +import org.ktc2.cokaen.wouldyouin.event.api.dto.UserLocation; import org.ktc2.cokaen.wouldyouin.auth.Authorize; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; -import org.ktc2.cokaen.wouldyouin.curation.api.dto.LocationFilter; +import org.ktc2.cokaen.wouldyouin.event.api.dto.LocationFilter; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventCreateRequest; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventEditRequest; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventResponse; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventResponse.java index 7ff20f85..b45e738e 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventResponse.java @@ -7,7 +7,7 @@ import org.ktc2.cokaen.wouldyouin._common.vo.Category; import org.ktc2.cokaen.wouldyouin._common.vo.Location; import org.ktc2.cokaen.wouldyouin.event.persist.Event; -import org.ktc2.cokaen.wouldyouin.member.application.dto.relation.EventHostResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.relation.EventHostResponse; import org.ktc2.cokaen.wouldyouin.member.persist.Host; @Builder diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventSliceResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventSliceResponse.java index 64929632..5221024c 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventSliceResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/EventSliceResponse.java @@ -5,9 +5,6 @@ import lombok.Getter; import org.ktc2.cokaen.wouldyouin._common.api.SliceInfo; import org.ktc2.cokaen.wouldyouin.event.persist.Event; -import org.ktc2.cokaen.wouldyouin.reservation.api.dto.ReservationResponse; -import org.ktc2.cokaen.wouldyouin.reservation.api.dto.ReservationSliceResponse; -import org.ktc2.cokaen.wouldyouin.reservation.persist.Reservation; import org.springframework.data.domain.Slice; @Getter diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/LocationFilter.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/LocationFilter.java similarity index 87% rename from src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/LocationFilter.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/LocationFilter.java index aec28478..fa1e923b 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/curation/api/dto/LocationFilter.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/LocationFilter.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.curation.api.dto; +package org.ktc2.cokaen.wouldyouin.event.api.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/vo/UserLocation.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/UserLocation.java similarity index 94% rename from src/main/java/org/ktc2/cokaen/wouldyouin/_common/vo/UserLocation.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/UserLocation.java index 32dfa4aa..be0efccd 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/_common/vo/UserLocation.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/api/dto/UserLocation.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin._common.vo; +package org.ktc2.cokaen.wouldyouin.event.api.dto; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/application/EventService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/application/EventService.java index 07ac64aa..2c56bc50 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/application/EventService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/application/EventService.java @@ -9,8 +9,8 @@ import org.ktc2.cokaen.wouldyouin._common.exception.UnauthorizedException; import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin._common.vo.Category; -import org.ktc2.cokaen.wouldyouin._common.vo.UserLocation; -import org.ktc2.cokaen.wouldyouin.curation.api.dto.LocationFilter; +import org.ktc2.cokaen.wouldyouin.event.api.dto.UserLocation; +import org.ktc2.cokaen.wouldyouin.event.api.dto.LocationFilter; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventCreateRequest; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventEditRequest; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventResponse; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java b/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java index 205688ef..d715b313 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/event/persist/Event.java @@ -19,13 +19,13 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.ktc2.cokaen.wouldyouin.Image.persist.EventImage; -import org.ktc2.cokaen.wouldyouin._common.exception.NoLeftSeatException; import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin._common.vo.Category; import org.ktc2.cokaen.wouldyouin._common.vo.Location; @@ -119,9 +119,10 @@ protected Event(String title, String content, Host host, Area area, Location loc this.totalSeat = totalSeat; this.leftSeat = totalSeat; this.category = category; - this.images = images; + Optional.ofNullable(images).ifPresent(this::setImages); } + // Todo: oneToMany 연관관계에서 모든 null 처리 public void updateFrom(EventEditRequest eventEditRequest, List images) { this.title = eventEditRequest.getTitle(); this.content = eventEditRequest.getContent(); diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/LikeController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/LikeController.java index 75792e55..0629424c 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/LikeController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/LikeController.java @@ -3,12 +3,12 @@ import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponse; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponseBody; -import org.ktc2.cokaen.wouldyouin._common.config.ParamDefaults; +import org.ktc2.cokaen.wouldyouin._common.api.ParamDefaults; import org.ktc2.cokaen.wouldyouin.auth.Authorize; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; import org.ktc2.cokaen.wouldyouin.like.application.LikeServiceFactory; -import org.ktc2.cokaen.wouldyouin.like.application.dto.LikeResponse; -import org.ktc2.cokaen.wouldyouin.like.application.dto.LikeToggleResponse; +import org.ktc2.cokaen.wouldyouin.like.api.dto.LikeResponse; +import org.ktc2.cokaen.wouldyouin.like.api.dto.LikeToggleResponse; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Slice; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/dto/LikeResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/dto/LikeResponse.java similarity index 93% rename from src/main/java/org/ktc2/cokaen/wouldyouin/like/application/dto/LikeResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/like/api/dto/LikeResponse.java index cc749208..f21ac18d 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/dto/LikeResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/dto/LikeResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.like.application.dto; +package org.ktc2.cokaen.wouldyouin.like.api.dto; import java.util.List; import lombok.AccessLevel; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/dto/LikeToggleResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/dto/LikeToggleResponse.java similarity index 77% rename from src/main/java/org/ktc2/cokaen/wouldyouin/like/application/dto/LikeToggleResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/like/api/dto/LikeToggleResponse.java index d5181d72..819e700d 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/dto/LikeToggleResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/like/api/dto/LikeToggleResponse.java @@ -1,10 +1,9 @@ -package org.ktc2.cokaen.wouldyouin.like.application.dto; +package org.ktc2.cokaen.wouldyouin.like.api.dto; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.RequiredArgsConstructor; -import org.ktc2.cokaen.wouldyouin.member.persist.LikeableMember; @Getter @RequiredArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/LikeService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/LikeService.java index 7b2393ab..8a888bad 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/LikeService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/like/application/LikeService.java @@ -1,8 +1,8 @@ package org.ktc2.cokaen.wouldyouin.like.application; import lombok.RequiredArgsConstructor; -import org.ktc2.cokaen.wouldyouin.like.application.dto.LikeResponse; -import org.ktc2.cokaen.wouldyouin.like.application.dto.LikeToggleResponse; +import org.ktc2.cokaen.wouldyouin.like.api.dto.LikeResponse; +import org.ktc2.cokaen.wouldyouin.like.api.dto.LikeToggleResponse; import org.ktc2.cokaen.wouldyouin.like.persist.Like; import org.ktc2.cokaen.wouldyouin.like.persist.LikeRepository; import org.ktc2.cokaen.wouldyouin.member.application.LikeableMemberGetterFactory; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/CuratorController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/CuratorController.java index 2500403c..49aa49b7 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/CuratorController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/CuratorController.java @@ -6,8 +6,8 @@ import org.ktc2.cokaen.wouldyouin.auth.Authorize; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; import org.ktc2.cokaen.wouldyouin.member.application.CuratorService; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.CuratorEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.CuratorEditRequest; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/HostController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/HostController.java index 17cac9d6..9e49a3fc 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/HostController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/HostController.java @@ -6,8 +6,8 @@ import org.ktc2.cokaen.wouldyouin.auth.Authorize; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; import org.ktc2.cokaen.wouldyouin.member.application.HostService; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.HostEditRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.HostEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PutMapping; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/MemberController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/MemberController.java index 07425641..f68765b3 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/MemberController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/MemberController.java @@ -9,10 +9,10 @@ import org.ktc2.cokaen.wouldyouin.member.application.BaseMemberService; import org.ktc2.cokaen.wouldyouin.member.application.HostService; import org.ktc2.cokaen.wouldyouin.member.application.MemberService; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.HostCreateRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.MemberCreateRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.MemberEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.HostCreateRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.MemberCreateRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.MemberEditRequest; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/MemberResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/MemberResponse.java similarity index 97% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/MemberResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/MemberResponse.java index ed56592b..4fe093db 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/MemberResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/MemberResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto; +package org.ktc2.cokaen.wouldyouin.member.api.dto; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relation/EventHostResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relation/EventHostResponse.java similarity index 92% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relation/EventHostResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relation/EventHostResponse.java index 2430622f..fb2d26a8 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relation/EventHostResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relation/EventHostResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.relation; +package org.ktc2.cokaen.wouldyouin.member.api.dto.relation; import java.util.List; import lombok.Builder; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relation/ReservationMemberResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relation/ReservationMemberResponse.java similarity index 77% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relation/ReservationMemberResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relation/ReservationMemberResponse.java index 0ebfe7f9..98b10bbc 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relation/ReservationMemberResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relation/ReservationMemberResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.relation; +package org.ktc2.cokaen.wouldyouin.member.api.dto.relation; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relationResponse/CurationCuratorResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/CurationCuratorResponse.java similarity index 92% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relationResponse/CurationCuratorResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/CurationCuratorResponse.java index 2516823c..ed5e85de 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relationResponse/CurationCuratorResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/CurationCuratorResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.relationResponse; +package org.ktc2.cokaen.wouldyouin.member.api.dto.relationResponse; import java.util.List; import lombok.Builder; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relationResponse/ReviewMemberResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/ReviewMemberResponse.java similarity index 66% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relationResponse/ReviewMemberResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/ReviewMemberResponse.java index 21a57579..afbdc6a2 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/relationResponse/ReviewMemberResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/relationResponse/ReviewMemberResponse.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.relationResponse; +package org.ktc2.cokaen.wouldyouin.member.api.dto.relationResponse; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/MemberAdditionalInfoRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/MemberAdditionalInfoRequest.java similarity index 81% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/MemberAdditionalInfoRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/MemberAdditionalInfoRequest.java index 64bfff22..2f3ea13a 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/MemberAdditionalInfoRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/MemberAdditionalInfoRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/HostCreateRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/HostCreateRequest.java similarity index 90% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/HostCreateRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/HostCreateRequest.java index 5233ddc3..6a2ceafe 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/HostCreateRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/HostCreateRequest.java @@ -1,6 +1,5 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request.create; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request.create; -import java.util.List; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImage; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/MemberCreateRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/MemberCreateRequest.java similarity index 94% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/MemberCreateRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/MemberCreateRequest.java index f021e163..6bc10cbf 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/MemberCreateRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/MemberCreateRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request.create; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request.create; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/MemberCreateRequestBase.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/MemberCreateRequestBase.java similarity index 82% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/MemberCreateRequestBase.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/MemberCreateRequestBase.java index 428664a7..1e4ecc5c 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/create/MemberCreateRequestBase.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/create/MemberCreateRequestBase.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request.create; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request.create; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/CuratorEditRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/CuratorEditRequest.java similarity index 88% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/CuratorEditRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/CuratorEditRequest.java index bef7ce24..63ee5b53 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/CuratorEditRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/CuratorEditRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit; import io.micrometer.common.lang.Nullable; import lombok.Builder; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/HostEditRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/HostEditRequest.java similarity index 88% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/HostEditRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/HostEditRequest.java index 618fe72c..2e816e36 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/HostEditRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/HostEditRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit; import jakarta.annotation.Nullable; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/MemberEditRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/MemberEditRequest.java similarity index 87% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/MemberEditRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/MemberEditRequest.java index 46e591a8..6afed790 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/MemberEditRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/MemberEditRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit; import jakarta.annotation.Nullable; import lombok.Builder; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/MemberEditRequestBase.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/MemberEditRequestBase.java similarity index 81% rename from src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/MemberEditRequestBase.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/MemberEditRequestBase.java index 45e8da30..f353746b 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/dto/request/edit/MemberEditRequestBase.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/api/dto/request/edit/MemberEditRequestBase.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit; +package org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit; import jakarta.annotation.Nullable; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberService.java index 3f11940a..154c2d11 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberService.java @@ -1,7 +1,7 @@ package org.ktc2.cokaen.wouldyouin.member.application; import lombok.RequiredArgsConstructor; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; import org.ktc2.cokaen.wouldyouin.member.persist.BaseMember; import org.ktc2.cokaen.wouldyouin.member.persist.BaseMemberRepository; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorService.java index c98a6f34..da78d2c7 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorService.java @@ -3,8 +3,8 @@ import java.util.Optional; import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin.Image.application.MemberImageService; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.CuratorEditRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.CuratorEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; import org.ktc2.cokaen.wouldyouin.member.persist.BaseMemberRepository; import org.ktc2.cokaen.wouldyouin.member.persist.Curator; import org.ktc2.cokaen.wouldyouin.member.persist.CuratorRepository; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/HostService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/HostService.java index f2cceed8..abc8c8f8 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/HostService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/HostService.java @@ -4,10 +4,10 @@ import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin.Image.application.MemberImageService; import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImage; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.LocalLoginRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.HostCreateRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.HostEditRequest; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.LocalLoginRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.HostCreateRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.HostEditRequest; import org.ktc2.cokaen.wouldyouin.member.persist.Host; import org.ktc2.cokaen.wouldyouin.member.persist.HostRepository; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberService.java index ea657969..3e7ccc88 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberService.java @@ -5,10 +5,10 @@ import org.ktc2.cokaen.wouldyouin.Image.application.MemberImageService; import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImage; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.MemberAdditionalInfoRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.MemberCreateRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.MemberEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.MemberAdditionalInfoRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.MemberCreateRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.MemberEditRequest; import org.ktc2.cokaen.wouldyouin.member.persist.Member; import org.ktc2.cokaen.wouldyouin.member.persist.MemberRepository; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceCommonBehavior.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceCommonBehavior.java index 2dabecef..ed70871e 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceCommonBehavior.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceCommonBehavior.java @@ -1,6 +1,6 @@ package org.ktc2.cokaen.wouldyouin.member.application; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/member/persist/Member.java b/src/main/java/org/ktc2/cokaen/wouldyouin/member/persist/Member.java index d5b4fe5c..b5f4d46a 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/member/persist/Member.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/member/persist/Member.java @@ -15,7 +15,7 @@ import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin.like.persist.CuratorLike; import org.ktc2.cokaen.wouldyouin.like.persist.HostLike; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.MemberAdditionalInfoRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.MemberAdditionalInfoRequest; import org.ktc2.cokaen.wouldyouin.reservation.persist.Reservation; import org.ktc2.cokaen.wouldyouin.review.persist.Review; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/payment/application/PaymentService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/payment/application/PaymentService.java index 0506aab3..c8a48c45 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/payment/application/PaymentService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/payment/application/PaymentService.java @@ -1,75 +1,46 @@ package org.ktc2.cokaen.wouldyouin.payment.application; -import java.net.URI; -import java.util.HashMap; -import java.util.Map; +import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin._common.exception.FailedToPayException; +import org.ktc2.cokaen.wouldyouin._common.util.KakaoPayUtil; +import org.ktc2.cokaen.wouldyouin._common.util.RestClientUtil; import org.ktc2.cokaen.wouldyouin.payment.dto.KakaoPayRequest; import org.ktc2.cokaen.wouldyouin.payment.dto.KakaoPayResponse; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import org.springframework.web.client.RestClient; @Service +@RequiredArgsConstructor public class PaymentService { - // Todo: pay 취소 기능 추가 - // Todo: RestClient 관련 로직 유틸로 분리 - private final RestClient client = RestClient.builder().build(); + private final RestClientUtil client; - @Value("${oauth.payment.kakao_pay_request_host}") + @Value("${oauth.payment.kakao-pay-request-host}") private String kakaoPayRequestHost; - @Value("${oauth.payment.kakao_pay_single_payment_url}") private String kakaoPaySinglePaymentUrl; - @Value("${oauth.payment.approval_url}") private String approvalUrl; - @Value("${oauth.payment.cancel_url}") private String cancelUrl; - @Value("${oauth.payment.fail_url}") private String failUrl; - @Value("${oauth.payment.secret_key}") private String secretKey; public KakaoPayResponse createPayment(KakaoPayRequest kakaoPayRequest) { - try { - return client.post() - .uri(URI.create("https://" + kakaoPayRequestHost + kakaoPaySinglePaymentUrl)) - .headers(httpHeaders -> httpHeaders.addAll(createKakaoPayRequestHeaders())) - .body(createKakaoPayRequestBody(kakaoPayRequest)) - .retrieve() - .body(KakaoPayResponse.class); - } catch (Exception ex) { - throw new FailedToPayException("결제에 실패했습니다."); + ResponseEntity response = client.post( + kakaoPayRequestHost + "/" + kakaoPaySinglePaymentUrl, + KakaoPayUtil.createKakaoPayRequestHeaders(kakaoPayRequestHost, secretKey), + KakaoPayUtil.createKakaoPayRequestBody(kakaoPayRequest, approvalUrl, cancelUrl, failUrl), + KakaoPayResponse.class + ); + if (!response.getStatusCode().is2xxSuccessful()) { + throw new FailedToPayException("카카오페이 API 요청을 실패하였습니다."); } + return response.getBody(); } - private HttpHeaders createKakaoPayRequestHeaders() { - HttpHeaders headers = new HttpHeaders(); - headers.add("Host", kakaoPayRequestHost); - headers.add("Authorization", "SECRET_KEY " + secretKey); - headers.setContentType(MediaType.APPLICATION_JSON); - return headers; - } - - private Map createKakaoPayRequestBody(KakaoPayRequest kakaoPayRequest) { - Map body = new HashMap<>(); - body.put("cid", "TC0ONETIME"); - body.put("partner_order_id", kakaoPayRequest.getReservationId()); - body.put("partner_user_id", kakaoPayRequest.getHostId()); - body.put("item_name", kakaoPayRequest.getEventName()); - body.put("quantity", kakaoPayRequest.getQuantity()); - body.put("total_amount", kakaoPayRequest.getTotalAmount()); - body.put("tax_free_amount", kakaoPayRequest.getTaxFreeAmount()); - body.put("approval_url", approvalUrl); - body.put("cancel_url", cancelUrl); - body.put("fail_url", failUrl); - return body; - } + // Todo: pay 취소 기능 추가 } diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/ReservationController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/ReservationController.java index 4199bfea..7d265e66 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/ReservationController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/ReservationController.java @@ -4,7 +4,7 @@ import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponse; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponseBody; -import org.ktc2.cokaen.wouldyouin._common.config.ParamDefaults; +import org.ktc2.cokaen.wouldyouin._common.api.ParamDefaults; import org.ktc2.cokaen.wouldyouin.auth.Authorize; import org.ktc2.cokaen.wouldyouin.auth.MemberIdentifier; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/dto/ReservationResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/dto/ReservationResponse.java index ba63a297..5249b6ee 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/dto/ReservationResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/api/dto/ReservationResponse.java @@ -4,7 +4,7 @@ import lombok.Builder; import lombok.Getter; import org.ktc2.cokaen.wouldyouin.event.api.dto.relationResonse.ReservationEventResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.relation.ReservationMemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.relation.ReservationMemberResponse; import org.ktc2.cokaen.wouldyouin.reservation.persist.Reservation; @Builder diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/application/ReservationService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/application/ReservationService.java index 73d26a72..17e1efb5 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/application/ReservationService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/reservation/application/ReservationService.java @@ -1,6 +1,5 @@ package org.ktc2.cokaen.wouldyouin.reservation.application; -import java.util.List; import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin._common.exception.EntityNotFoundException; import org.ktc2.cokaen.wouldyouin._common.exception.UnauthorizedException; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/ReviewController.java b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/ReviewController.java index ea036dc1..f9637cf4 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/ReviewController.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/ReviewController.java @@ -4,9 +4,9 @@ import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin._common.api.ApiResponseBody; import org.ktc2.cokaen.wouldyouin.review.application.ReviewService; -import org.ktc2.cokaen.wouldyouin.review.application.dto.ReviewCreateRequest; -import org.ktc2.cokaen.wouldyouin.review.application.dto.ReviewEditRequest; -import org.ktc2.cokaen.wouldyouin.review.application.dto.ReviewResponse; +import org.ktc2.cokaen.wouldyouin.review.api.dto.ReviewCreateRequest; +import org.ktc2.cokaen.wouldyouin.review.api.dto.ReviewEditRequest; +import org.ktc2.cokaen.wouldyouin.review.api.dto.ReviewResponse; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewCreateRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewCreateRequest.java similarity index 87% rename from src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewCreateRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewCreateRequest.java index b90571ce..406ee397 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewCreateRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewCreateRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.review.application.dto; +package org.ktc2.cokaen.wouldyouin.review.api.dto; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewEditRequest.java b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewEditRequest.java similarity index 74% rename from src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewEditRequest.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewEditRequest.java index f850e0b2..7b070079 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewEditRequest.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewEditRequest.java @@ -1,4 +1,4 @@ -package org.ktc2.cokaen.wouldyouin.review.application.dto; +package org.ktc2.cokaen.wouldyouin.review.api.dto; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewResponse.java b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewResponse.java similarity index 88% rename from src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewResponse.java rename to src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewResponse.java index 08a2e764..daf8e8b3 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/dto/ReviewResponse.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/review/api/dto/ReviewResponse.java @@ -1,10 +1,10 @@ -package org.ktc2.cokaen.wouldyouin.review.application.dto; +package org.ktc2.cokaen.wouldyouin.review.api.dto; import lombok.Builder; import lombok.Getter; import org.ktc2.cokaen.wouldyouin.event.api.dto.relationResonse.ReviewEventResponse; import org.ktc2.cokaen.wouldyouin.event.persist.Event; -import org.ktc2.cokaen.wouldyouin.member.application.dto.relationResponse.ReviewMemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.relationResponse.ReviewMemberResponse; import org.ktc2.cokaen.wouldyouin.member.persist.Member; import org.ktc2.cokaen.wouldyouin.review.persist.Review; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java b/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java index adb7b604..e0875dd8 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/review/application/ReviewService.java @@ -5,9 +5,9 @@ import lombok.RequiredArgsConstructor; import org.ktc2.cokaen.wouldyouin.event.application.EventService; import org.ktc2.cokaen.wouldyouin.member.application.MemberService; -import org.ktc2.cokaen.wouldyouin.review.application.dto.ReviewCreateRequest; -import org.ktc2.cokaen.wouldyouin.review.application.dto.ReviewEditRequest; -import org.ktc2.cokaen.wouldyouin.review.application.dto.ReviewResponse; +import org.ktc2.cokaen.wouldyouin.review.api.dto.ReviewCreateRequest; +import org.ktc2.cokaen.wouldyouin.review.api.dto.ReviewEditRequest; +import org.ktc2.cokaen.wouldyouin.review.api.dto.ReviewResponse; import org.ktc2.cokaen.wouldyouin.review.persist.Review; import org.ktc2.cokaen.wouldyouin.review.persist.ReviewRepository; import org.springframework.stereotype.Service; diff --git a/src/main/java/org/ktc2/cokaen/wouldyouin/review/persist/Review.java b/src/main/java/org/ktc2/cokaen/wouldyouin/review/persist/Review.java index bc0a7d6e..2316be65 100644 --- a/src/main/java/org/ktc2/cokaen/wouldyouin/review/persist/Review.java +++ b/src/main/java/org/ktc2/cokaen/wouldyouin/review/persist/Review.java @@ -18,7 +18,7 @@ import lombok.Setter; import org.ktc2.cokaen.wouldyouin.event.persist.Event; import org.ktc2.cokaen.wouldyouin.member.persist.Member; -import org.ktc2.cokaen.wouldyouin.review.application.dto.ReviewEditRequest; +import org.ktc2.cokaen.wouldyouin.review.api.dto.ReviewEditRequest; @Getter @Setter diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 446aa5a9..d3030496 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -46,15 +46,15 @@ logging.level.org.ktc2.cokaen.wouldyouin: debug # for image storage path image: upload: - common-path: src/main/resources/static + parent-path: src/main/resources/static/images curation: - sub-path: images/curation + child-path: curation member: - sub-path: images/member + child-path: member event: - sub-path: images/event + child-path: event ad: - sub-path: images/ad + child-path: advertisement # for jwt jwt: @@ -96,5 +96,5 @@ oauth: "cancel_url": "http://localhost:8080/api/events" "fail_url": "http://localhost:8080/api/events" "secret_key": ${KAKAOPAY_SECRET_KEY} - "kakao_pay_single_payment_url": "/online/v1/payment/ready" - "kakao_pay_request_host": "open-api.kakaopay.com" \ No newline at end of file + "kakao_pay_single_payment_url": "online/v1/payment/ready" + "kakao-pay-request-host": "https://open-api.kakaopay.com" \ No newline at end of file diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/WouldYouInApplicationTests.java b/src/test/java/org/ktc2/cokaen/wouldyouin/WouldYouInApplicationTests.java index b4ff92e9..188f65e8 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/WouldYouInApplicationTests.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/WouldYouInApplicationTests.java @@ -6,8 +6,7 @@ @SpringBootTest class WouldYouInApplicationTests { - @Test - void contextLoads() { - } - +// @Test +// void contextLoads() { +// } } diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/_global/TestData.java b/src/test/java/org/ktc2/cokaen/wouldyouin/_global/TestData.java index a021fb23..82a4165b 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/_global/TestData.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/_global/TestData.java @@ -21,8 +21,8 @@ import org.ktc2.cokaen.wouldyouin.event.api.dto.relationResonse.CurationEventResponse; import org.ktc2.cokaen.wouldyouin.event.api.dto.relationResonse.ReservationEventResponse; import org.ktc2.cokaen.wouldyouin.event.persist.Event; -import org.ktc2.cokaen.wouldyouin.member.application.dto.relation.ReservationMemberResponse; -import org.ktc2.cokaen.wouldyouin.member.application.dto.relationResponse.CurationCuratorResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.relation.ReservationMemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.relationResponse.CurationCuratorResponse; import org.ktc2.cokaen.wouldyouin.member.persist.AccountType; import org.ktc2.cokaen.wouldyouin.member.persist.Curator; import org.ktc2.cokaen.wouldyouin.member.persist.Host; diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/curation/CurationControllerUnitTest.java b/src/test/java/org/ktc2/cokaen/wouldyouin/curation/CurationControllerUnitTest.java index 716f14a9..8a1be112 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/curation/CurationControllerUnitTest.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/curation/CurationControllerUnitTest.java @@ -16,7 +16,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import java.util.List; import java.util.Random; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventControllerUnitTest.java b/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventControllerUnitTest.java index d930cbf0..590cdbfb 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventControllerUnitTest.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventControllerUnitTest.java @@ -25,15 +25,14 @@ import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin._common.vo.Category; -import org.ktc2.cokaen.wouldyouin._common.vo.Location; -import org.ktc2.cokaen.wouldyouin._common.vo.UserLocation; import org.ktc2.cokaen.wouldyouin.auth.application.JwtAuthFilter; import org.ktc2.cokaen.wouldyouin.auth.application.JwtService; -import org.ktc2.cokaen.wouldyouin.curation.api.dto.LocationFilter; +import org.ktc2.cokaen.wouldyouin.event.api.dto.LocationFilter; import org.ktc2.cokaen.wouldyouin.event.api.EventController; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventCreateRequest; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventEditRequest; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventSliceResponse; +import org.ktc2.cokaen.wouldyouin.event.api.dto.UserLocation; import org.ktc2.cokaen.wouldyouin.event.application.EventService; import org.ktc2.cokaen.wouldyouin._global.TestData.EventDomain; import org.ktc2.cokaen.wouldyouin._global.mockMember.WithMockHost; diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventServiceUnitTest.java b/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventServiceUnitTest.java index e38a6596..f36ac5a3 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventServiceUnitTest.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/event/EventServiceUnitTest.java @@ -11,7 +11,6 @@ import java.util.List; import java.util.Optional; -import org.h2.engine.User; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -19,12 +18,11 @@ import org.ktc2.cokaen.wouldyouin.Image.application.EventImageService; import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin._common.vo.Category; -import org.ktc2.cokaen.wouldyouin._common.vo.Location; -import org.ktc2.cokaen.wouldyouin._common.vo.UserLocation; import org.ktc2.cokaen.wouldyouin._global.TestData.EventDomain; -import org.ktc2.cokaen.wouldyouin.curation.api.dto.LocationFilter; +import org.ktc2.cokaen.wouldyouin.event.api.dto.LocationFilter; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventCreateRequest; import org.ktc2.cokaen.wouldyouin.event.api.dto.EventEditRequest; +import org.ktc2.cokaen.wouldyouin.event.api.dto.UserLocation; import org.ktc2.cokaen.wouldyouin.event.application.EventService; import org.ktc2.cokaen.wouldyouin.event.persist.Event; import org.ktc2.cokaen.wouldyouin.event.persist.EventRepository; diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberServiceUnitTest.java b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberServiceUnitTest.java index 8a3d0abc..23f7fd54 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberServiceUnitTest.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/BaseMemberServiceUnitTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import org.ktc2.cokaen.wouldyouin.member.application.dto.MemberResponse; +import org.ktc2.cokaen.wouldyouin.member.api.dto.MemberResponse; import org.ktc2.cokaen.wouldyouin.member.persist.BaseMember; import org.ktc2.cokaen.wouldyouin.member.persist.BaseMemberRepository; import org.ktc2.cokaen.wouldyouin.member.persist.Curator; diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorServiceUnitTest.java b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorServiceUnitTest.java index 735d8c4a..5e372806 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorServiceUnitTest.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/CuratorServiceUnitTest.java @@ -18,7 +18,7 @@ import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImage; import org.ktc2.cokaen.wouldyouin._common.vo.Area; import org.ktc2.cokaen.wouldyouin._global.TestUtil; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.CuratorEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.CuratorEditRequest; import org.ktc2.cokaen.wouldyouin.member.persist.BaseMemberRepository; import org.ktc2.cokaen.wouldyouin.member.persist.Curator; import org.ktc2.cokaen.wouldyouin.member.persist.CuratorRepository; diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/HostServiceUnitTest.java b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/HostServiceUnitTest.java index a4052dd2..5097250a 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/HostServiceUnitTest.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/HostServiceUnitTest.java @@ -14,10 +14,10 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.ktc2.cokaen.wouldyouin.Image.application.MemberImageService; import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImage; -import org.ktc2.cokaen.wouldyouin.auth.application.dto.LocalLoginRequest; +import org.ktc2.cokaen.wouldyouin.auth.api.dto.LocalLoginRequest; import org.ktc2.cokaen.wouldyouin._global.TestUtil; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.HostCreateRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.HostEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.HostCreateRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.HostEditRequest; import org.ktc2.cokaen.wouldyouin.member.persist.Host; import org.ktc2.cokaen.wouldyouin.member.persist.HostRepository; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType; diff --git a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceUnitTest.java b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceUnitTest.java index 038ec16b..0c789df4 100644 --- a/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceUnitTest.java +++ b/src/test/java/org/ktc2/cokaen/wouldyouin/member/application/MemberServiceUnitTest.java @@ -18,9 +18,9 @@ import org.ktc2.cokaen.wouldyouin.Image.application.MemberImageService; import org.ktc2.cokaen.wouldyouin.Image.persist.MemberImage; import org.ktc2.cokaen.wouldyouin._global.TestUtil; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.MemberAdditionalInfoRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.create.MemberCreateRequest; -import org.ktc2.cokaen.wouldyouin.member.application.dto.request.edit.MemberEditRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.MemberAdditionalInfoRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.create.MemberCreateRequest; +import org.ktc2.cokaen.wouldyouin.member.api.dto.request.edit.MemberEditRequest; import org.ktc2.cokaen.wouldyouin.member.persist.Member; import org.ktc2.cokaen.wouldyouin.member.persist.MemberRepository; import org.ktc2.cokaen.wouldyouin.member.persist.MemberType;