From 14b9d9cdc91f39f02d4efbe1575c2e4b3413029d Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 07:02:21 +0900 Subject: [PATCH 01/11] =?UTF-8?q?refactor:=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/config/{S3Config.java => AWSConfig.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/coffeemeet/server/common/config/{S3Config.java => AWSConfig.java} (96%) diff --git a/src/main/java/coffeemeet/server/common/config/S3Config.java b/src/main/java/coffeemeet/server/common/config/AWSConfig.java similarity index 96% rename from src/main/java/coffeemeet/server/common/config/S3Config.java rename to src/main/java/coffeemeet/server/common/config/AWSConfig.java index 67f8409a..ce6d6fde 100644 --- a/src/main/java/coffeemeet/server/common/config/S3Config.java +++ b/src/main/java/coffeemeet/server/common/config/AWSConfig.java @@ -9,13 +9,13 @@ import org.springframework.context.annotation.Configuration; @Configuration -public class S3Config { +public class AWSConfig { private final String accessKey; private final String secretKey; private final String region; - public S3Config( + public AWSConfig( @Value("${cloud.aws.credentials.access-key}") String accessKey, @Value("${cloud.aws.credentials.secret-key}") String secretKey, @Value("${cloud.aws.region.static}") String region) { From 3f563964f5a2262d08fa70b7c3fc4e94644b58d7 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 07:02:46 +0900 Subject: [PATCH 02/11] =?UTF-8?q?refactor:=20=EC=9D=B8=EC=A6=9D=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20->=20=EC=BD=94=EB=93=9C=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../certification/controller/CertificationControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java b/src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java index 6b225d3e..125e3b9e 100644 --- a/src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java +++ b/src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java @@ -96,7 +96,7 @@ void registerCompanyInfoTest() throws Exception { } @Test - @DisplayName("이메일을 통해 인증번호를 전송할 수 있다.") + @DisplayName("이메일을 통해 인증코드를 전송할 수 있다.") void sendVerificationCodeByEmailTest() throws Exception { // given String emailDtoRequest = objectMapper.writeValueAsString(emailDtoRequest()); From 8b9ad3b8764a3d6baeb88dc02f44b7f88c366224 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 07:12:18 +0900 Subject: [PATCH 03/11] =?UTF-8?q?refactor:=20=EC=9D=B8=EC=A6=9D=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20->=20=EC=BD=94=EB=93=9C=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/certification/service/cq/EmailVerificationQuery.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java b/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java index 2cfed34f..df641472 100644 --- a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java +++ b/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java @@ -12,7 +12,7 @@ @RequiredArgsConstructor public class EmailVerificationQuery { - private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증 번호를 요청한 기록이 없습니다."; + private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증코드를 요청한 기록이 없습니다."; private final EmailVerificationRepository emailVerificationRepository; From b52bef375fe81c705855479bb320e213ba03d94f Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 07:14:20 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor:=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20OCP=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EmailService -> EmailSender S3MediaManager -> S3MediaService --- .../service/CertificationService.java | 22 +++++++-------- .../{EmailService.java => EmailSender.java} | 4 +-- .../server/common/media/MediaManager.java | 17 +++++++++++ ...3MediaService.java => S3MediaManager.java} | 28 ++++++------------- .../server/user/service/UserService.java | 16 +++++------ .../service/CertificationServiceTest.java | 18 ++++++------ 6 files changed, 56 insertions(+), 49 deletions(-) rename src/main/java/coffeemeet/server/common/media/{EmailService.java => EmailSender.java} (92%) create mode 100644 src/main/java/coffeemeet/server/common/media/MediaManager.java rename src/main/java/coffeemeet/server/common/media/{S3MediaService.java => S3MediaManager.java} (76%) diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index eff6c4e2..1a182c98 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -1,7 +1,7 @@ package coffeemeet.server.certification.service; import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE; -import static coffeemeet.server.common.media.S3MediaService.KeyType.BUSINESS_CARD; +import static coffeemeet.server.common.media.KeyType.BUSINESS_CARD; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; @@ -9,8 +9,8 @@ import coffeemeet.server.certification.service.cq.EmailVerificationCommand; import coffeemeet.server.certification.service.cq.EmailVerificationQuery; import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.common.media.EmailService; -import coffeemeet.server.common.media.S3MediaService; +import coffeemeet.server.common.media.EmailSender; +import coffeemeet.server.common.media.MediaManager; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.service.cq.UserQuery; @@ -26,8 +26,8 @@ public class CertificationService { private static final String WRONG_VERIFICATION_CODE_MESSAGE = "사용자(%s)가 잘못된 인증코드(%s)를 입력했습니다."; private static final RandomGenerator RANDOM_GENERATOR = RandomGenerator.getDefault(); - private final S3MediaService s3MediaService; - private final EmailService emailService; + private final MediaManager mediaManager; + private final EmailSender emailSender; private final UserQuery userQuery; private final CertificationCommand certificationCommand; private final EmailVerificationCommand emailVerificationCommand; @@ -35,11 +35,11 @@ public class CertificationService { public void registerCertification(long userId, String email, String departmentName, File businessCardImage) { - String key = s3MediaService.generateKey(BUSINESS_CARD); + String key = mediaManager.generateKey(BUSINESS_CARD); uploadBusinessCard(userId, key, businessCardImage); CompanyEmail companyEmail = new CompanyEmail(email); - String businessCardUrl = s3MediaService.getUrl(key); + String businessCardUrl = mediaManager.getUrl(key); Department department = Department.valueOf(departmentName); User user = userQuery.getUserById(userId); certificationCommand.createCertification(companyEmail, businessCardUrl, department, user); @@ -47,11 +47,11 @@ public void registerCertification(long userId, String email, String departmentNa private void uploadBusinessCard(long userId, String key, File businessCardUrl) { certificationCommand.applyIfCertifiedUser(userId, certification -> { - String oldKey = s3MediaService.extractKey(certification.getBusinessCardUrl(), BUSINESS_CARD); - s3MediaService.delete(oldKey); + String oldKey = mediaManager.extractKey(certification.getBusinessCardUrl(), BUSINESS_CARD); + mediaManager.delete(oldKey); }); - s3MediaService.upload(key, businessCardUrl); + mediaManager.upload(key, businessCardUrl); FileUtils.delete(businessCardUrl); } @@ -60,7 +60,7 @@ public void sendVerificationMail(Long userId, String email) { certificationCommand.hasDuplicatedCompanyEmail(companyEmail); String verificationCode = generateVerificationCode(); - emailService.sendVerificationCode(companyEmail, verificationCode); + emailSender.sendVerificationCode(companyEmail, verificationCode); emailVerificationCommand.createEmailVerification(userId, companyEmail, verificationCode); } diff --git a/src/main/java/coffeemeet/server/common/media/EmailService.java b/src/main/java/coffeemeet/server/common/media/EmailSender.java similarity index 92% rename from src/main/java/coffeemeet/server/common/media/EmailService.java rename to src/main/java/coffeemeet/server/common/media/EmailSender.java index 35b0f13b..75fa87e0 100644 --- a/src/main/java/coffeemeet/server/common/media/EmailService.java +++ b/src/main/java/coffeemeet/server/common/media/EmailSender.java @@ -7,12 +7,12 @@ import org.springframework.stereotype.Service; @Service -public class EmailService { +public class EmailSender { private final JavaMailSender javaMailSender; private final String sender; - public EmailService(JavaMailSender javaMailSender, + public EmailSender(JavaMailSender javaMailSender, @Value("${spring.mail.username}") String sender) { this.javaMailSender = javaMailSender; this.sender = sender; diff --git a/src/main/java/coffeemeet/server/common/media/MediaManager.java b/src/main/java/coffeemeet/server/common/media/MediaManager.java new file mode 100644 index 00000000..4f94f9b5 --- /dev/null +++ b/src/main/java/coffeemeet/server/common/media/MediaManager.java @@ -0,0 +1,17 @@ +package coffeemeet.server.common.media; + +import java.io.File; + +public interface MediaManager { + + void upload(String key, File file); + + void delete(String key); + + String getUrl(String key); + + String generateKey(KeyType keyType); + + String extractKey(String s3Url, KeyType keyType); + +} diff --git a/src/main/java/coffeemeet/server/common/media/S3MediaService.java b/src/main/java/coffeemeet/server/common/media/S3MediaManager.java similarity index 76% rename from src/main/java/coffeemeet/server/common/media/S3MediaService.java rename to src/main/java/coffeemeet/server/common/media/S3MediaManager.java index b2724760..f0bc5d5d 100644 --- a/src/main/java/coffeemeet/server/common/media/S3MediaService.java +++ b/src/main/java/coffeemeet/server/common/media/S3MediaManager.java @@ -7,18 +7,17 @@ import java.io.File; import java.time.LocalDateTime; import java.util.UUID; -import lombok.Getter; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service -public class S3MediaService { +public class S3MediaManager implements MediaManager { private static final String INVALID_S3_URL_MESSAGE = "올바르지 않은 S3 URL(%s)입니다."; private final AmazonS3 amazonS3; private final String bucketName; - public S3MediaService( + public S3MediaManager( AmazonS3 amazonS3, @Value("${cloud.aws.s3.bucket}") String bucketName ) { @@ -26,25 +25,30 @@ public S3MediaService( this.bucketName = bucketName; } + @Override public void upload(String key, File file) { amazonS3.putObject(bucketName, key, file); } + @Override public void delete(String key) { amazonS3.deleteObject(bucketName, key); } + @Override public String getUrl(String key) { return amazonS3.getUrl(bucketName, key).toExternalForm(); } + @Override public String generateKey(KeyType keyType) { - return String.format("%s-%s-%s", keyType.value, LocalDateTime.now(), + return String.format("%s-%s-%s", keyType.getValue(), LocalDateTime.now(), UUID.randomUUID()); } + @Override public String extractKey(String s3Url, KeyType keyType) { - int startIndex = s3Url.indexOf(keyType.value); + int startIndex = s3Url.indexOf(keyType.getValue()); if (startIndex == -1) { throw new InvalidInputException(INVALID_S3_URL, String.format(INVALID_S3_URL_MESSAGE, s3Url)); @@ -52,18 +56,4 @@ public String extractKey(String s3Url, KeyType keyType) { return s3Url.substring(startIndex); } - @Getter - public enum KeyType { - BUSINESS_CARD("BusinessCard"), - PROFILE_IMAGE("ProfileImage"), - ; - - private final String value; - - KeyType(String value) { - this.value = value; - } - - } - } diff --git a/src/main/java/coffeemeet/server/user/service/UserService.java b/src/main/java/coffeemeet/server/user/service/UserService.java index 231f78fd..08e8717f 100644 --- a/src/main/java/coffeemeet/server/user/service/UserService.java +++ b/src/main/java/coffeemeet/server/user/service/UserService.java @@ -1,12 +1,12 @@ package coffeemeet.server.user.service; -import static coffeemeet.server.common.media.S3MediaService.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.media.KeyType.PROFILE_IMAGE; import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.service.cq.CertificationQuery; -import coffeemeet.server.common.media.S3MediaService; +import coffeemeet.server.common.media.MediaManager; import coffeemeet.server.interest.domain.Keyword; import coffeemeet.server.interest.service.cq.InterestCommand; import coffeemeet.server.interest.service.cq.InterestQuery; @@ -34,7 +34,7 @@ public class UserService { private static final String DEFAULT_IMAGE_URL = "기본 이미지 URL"; - private final S3MediaService s3MediaService; + private final MediaManager mediaManager; private final OAuthService oAuthService; private final CertificationQuery certificationQuery; @@ -92,9 +92,9 @@ public void updateProfileImage(Long userId, File file) { User user = userQuery.getUserById(userId); deleteCurrentProfileImage(user.getProfile().getProfileImageUrl()); - String key = s3MediaService.generateKey(PROFILE_IMAGE); - s3MediaService.upload(key, file); - user.updateProfileImageUrl(s3MediaService.getUrl(key)); + String key = mediaManager.generateKey(PROFILE_IMAGE); + mediaManager.upload(key, file); + user.updateProfileImageUrl(mediaManager.getUrl(key)); userCommand.updateUser(user); } @@ -126,9 +126,9 @@ private String getProfileImageOrDefault(String profileImage) { } private void deleteCurrentProfileImage(String profileImageUrl) { - String currentKey = s3MediaService.extractKey(profileImageUrl, + String currentKey = mediaManager.extractKey(profileImageUrl, PROFILE_IMAGE); - s3MediaService.delete(currentKey); + mediaManager.delete(currentKey); } } diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index a23bb7fb..bd9519c4 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -18,8 +18,8 @@ import coffeemeet.server.certification.service.cq.CertificationCommand; import coffeemeet.server.certification.service.cq.EmailVerificationCommand; import coffeemeet.server.certification.service.cq.EmailVerificationQuery; -import coffeemeet.server.common.media.EmailService; -import coffeemeet.server.common.media.S3MediaService; +import coffeemeet.server.common.media.EmailSender; +import coffeemeet.server.common.media.MediaManager; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.service.cq.UserQuery; @@ -39,9 +39,9 @@ class CertificationServiceTest { @InjectMocks private CertificationService certificationService; @Mock - private S3MediaService s3MediaService; + private MediaManager mediaManager; @Mock - private EmailService emailService; + private EmailSender emailSender; @Mock private UserQuery userQuery; @Mock @@ -64,16 +64,16 @@ void registerCertificationTest() { MockedStatic fileUtils = mockStatic(FileUtils.class); fileUtils.when(() -> FileUtils.delete(file)).then(invocation -> null); - given(s3MediaService.generateKey(any())).willReturn("someKey"); - given(s3MediaService.getUrl(any())).willReturn(businessCardUrl); + given(mediaManager.generateKey(any())).willReturn("someKey"); + given(mediaManager.getUrl(any())).willReturn(businessCardUrl); given(userQuery.getUserById(userId)).willReturn(user); // when certificationService.registerCertification(userId, email, departmentName, file); // then - then(s3MediaService).should().generateKey(any()); - then(s3MediaService).should().upload(any(), any(File.class)); + then(mediaManager).should().generateKey(any()); + then(mediaManager).should().upload(any(), any(File.class)); then(certificationCommand).should().createCertification(any(), any(), any(), any()); fileUtils.close(); @@ -92,7 +92,7 @@ void sendVerificationMailTest() { // then then(certificationCommand).should(only()).hasDuplicatedCompanyEmail(any()); - then(emailService).should(only()).sendVerificationCode(any(), anyString()); + then(emailSender).should(only()).sendVerificationCode(any(), anyString()); then(emailVerificationCommand).should(only()) .createEmailVerification(anyLong(), any(), anyString()); } From ad3ac436f11fe8554f8d5d30195a7bae0760ac5d Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 07:15:01 +0900 Subject: [PATCH 05/11] =?UTF-8?q?refactor:=20KeyType=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/media/KeyType.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/coffeemeet/server/common/media/KeyType.java diff --git a/src/main/java/coffeemeet/server/common/media/KeyType.java b/src/main/java/coffeemeet/server/common/media/KeyType.java new file mode 100644 index 00000000..3aaa7615 --- /dev/null +++ b/src/main/java/coffeemeet/server/common/media/KeyType.java @@ -0,0 +1,18 @@ +package coffeemeet.server.common.media; + +import lombok.Getter; + +@Getter +public enum KeyType { + + BUSINESS_CARD("BusinessCard"), + PROFILE_IMAGE("ProfileImage"), + ; + + private final String value; + + KeyType(String value) { + this.value = value; + } + +} From a5c41ee0ad5ba43c370a1f3e08390631fe1951bf Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 07:15:20 +0900 Subject: [PATCH 06/11] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/common/media/EmailSenderTest.java | 62 ++++++++++ .../common/media/S3MediaManagerTest.java | 107 ++++++++++++++++++ .../server/user/service/UserServiceTest.java | 10 +- 3 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 src/test/java/coffeemeet/server/common/media/EmailSenderTest.java create mode 100644 src/test/java/coffeemeet/server/common/media/S3MediaManagerTest.java diff --git a/src/test/java/coffeemeet/server/common/media/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/media/EmailSenderTest.java new file mode 100644 index 00000000..93ee4ef1 --- /dev/null +++ b/src/test/java/coffeemeet/server/common/media/EmailSenderTest.java @@ -0,0 +1,62 @@ +package coffeemeet.server.common.media; + +import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; +import static coffeemeet.server.common.fixture.entity.CertificationFixture.verificationCode; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.only; + +import coffeemeet.server.certification.domain.CompanyEmail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSender; + +@ExtendWith(MockitoExtension.class) +class EmailSenderTest { + + private EmailSender emailSender; + + @Mock + private JavaMailSender javaMailSender; + + private String sender; + + @Captor + private ArgumentCaptor simpleMailMessage; + + @BeforeEach + void setUp() { + sender = email(); + emailSender = new EmailSender(javaMailSender, sender); + } + + @Test + @DisplayName("인증코드가 포함된 메일을 보낼 수 있다.") + void sendVerificationCodeTest() { + // given + CompanyEmail companyEmail = companyEmail(); + String verificationCode = verificationCode(); + + // when + emailSender.sendVerificationCode(companyEmail, verificationCode); + + // then + then(javaMailSender).should(only()).send(simpleMailMessage.capture()); + + SimpleMailMessage sentMailMessage = simpleMailMessage.getValue(); + assertAll( + () -> assertThat(sentMailMessage.getFrom()).isEqualTo(sender), + () -> assertThat(sentMailMessage.getTo()[0]).isEqualTo(companyEmail.getValue()), + () -> assertThat(sentMailMessage.getText()).contains(verificationCode) + ); + } +} diff --git a/src/test/java/coffeemeet/server/common/media/S3MediaManagerTest.java b/src/test/java/coffeemeet/server/common/media/S3MediaManagerTest.java new file mode 100644 index 00000000..d0c2c713 --- /dev/null +++ b/src/test/java/coffeemeet/server/common/media/S3MediaManagerTest.java @@ -0,0 +1,107 @@ +package coffeemeet.server.common.media; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.then; +import static org.mockito.BDDMockito.willDoNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.only; + +import com.amazonaws.services.s3.AmazonS3; +import java.io.File; +import java.net.URL; +import org.instancio.Instancio; +import org.instancio.internal.generator.net.URLGenerator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class S3MediaManagerTest { + + private S3MediaManager s3MediaManager; + + @Mock + private AmazonS3 amazonS3; + + private String bucketName = Instancio.create(String.class); + + private String validKey; + + private KeyType keyType; + + @BeforeEach + void setUp() { + keyType = Instancio.create(KeyType.class); + validKey = keyType.getValue() + "-" + Instancio.create(String.class); + s3MediaManager = new S3MediaManager(amazonS3, bucketName); + } + + @Test + @DisplayName("파일을 업로드 할 수 있다") + void uploadTest() { + // given + File file = mock(); + + // when + s3MediaManager.upload(validKey, file); + + // then + then(amazonS3).should(only()).putObject(bucketName, validKey, file); + } + + @Test + @DisplayName("파일을 삭제 할 수 있다") + void deleteTest() { + // given + willDoNothing().given(amazonS3).deleteObject(bucketName, validKey); + + // when + s3MediaManager.delete(validKey); + + // then + then(amazonS3).should(only()).deleteObject(bucketName, validKey); + + } + + @Test + @DisplayName("파일 URL을 얻을 수 있다") + void getUrlTest() { + // given + URL url = new URLGenerator().get(); + given(amazonS3.getUrl(bucketName, validKey)).willReturn(url); + + // when + String actualUrl = s3MediaManager.getUrl(validKey); + + // then + assertThat(actualUrl).isEqualTo(url.toExternalForm()); + } + + @Test + @DisplayName("s3 키를 생성할 수 있다") + void generateKey() { + // given + KeyType keyType = Instancio.create(KeyType.class); + + // when + String key = s3MediaManager.generateKey(keyType); + + // then + assertThat(key).contains(keyType.getValue()); + } + + @Test + @DisplayName("URL에서 s3 키를 추출할 수 있다") + void extractKey() { + // given, when + String extractedKey = s3MediaManager.extractKey( + new URLGenerator().get().toExternalForm() + validKey, keyType); + + // then + assertThat(extractedKey).isEqualTo(validKey); + } +} diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index 9e2cd8e2..d4d4a4b7 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -2,7 +2,7 @@ import static coffeemeet.server.certification.domain.Department.IT; import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.media.S3MediaService.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.media.KeyType.PROFILE_IMAGE; import static coffeemeet.server.interest.domain.Keyword.COOK; import static coffeemeet.server.interest.domain.Keyword.GAME; import static coffeemeet.server.user.domain.OAuthProvider.KAKAO; @@ -25,7 +25,7 @@ import coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture; import coffeemeet.server.common.fixture.dto.SignupDtoFixture; import coffeemeet.server.common.fixture.entity.CertificationFixture; -import coffeemeet.server.common.media.S3MediaService; +import coffeemeet.server.common.media.MediaManager; import coffeemeet.server.interest.domain.Keyword; import coffeemeet.server.interest.service.cq.InterestCommand; import coffeemeet.server.interest.service.cq.InterestQuery; @@ -62,7 +62,7 @@ class UserServiceTest { private UserService userService; @Mock - private S3MediaService s3MediaService; + private MediaManager mediaManager; @Mock private OAuthService oAuthService; @@ -224,8 +224,8 @@ void updateProfileImage() throws IOException { File file = File.createTempFile("temp", "png"); given(userQuery.getUserById(userId)).willReturn(user); - given(s3MediaService.generateKey(PROFILE_IMAGE)).willReturn("key"); - given(s3MediaService.getUrl(anyString())).willReturn("newImageUrl"); + given(mediaManager.generateKey(PROFILE_IMAGE)).willReturn("key"); + given(mediaManager.getUrl(anyString())).willReturn("newImageUrl"); // when userService.updateProfileImage(userId, file); From 757d53fbb7734b4305eeb89e87db52543353f432 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 18:53:37 +0900 Subject: [PATCH 07/11] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=20=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20dto=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/domain/AuthTokensGenerator.java | 2 +- .../RefreshTokenRepository.java | 2 +- .../AuthController.java | 4 +- .../server/auth/service/AuthService.java | 2 +- .../auth/service/cq/RefreshTokenCommand.java | 24 --------- .../auth/service/cq/RefreshTokenQuery.java | 28 ----------- .../CertificationRepository.java | 2 +- .../EmailVerificationRepository.java | 2 +- .../CertificationController.java | 8 +-- .../dto/EmailDto.java | 2 +- .../dto/VerificationCodeDto.java | 2 +- .../service/CertificationService.java | 8 +-- .../service/cq/CertificationCommand.java | 48 ------------------ .../service/cq/CertificationQuery.java | 27 ---------- .../service/cq/EmailVerificationCommand.java | 20 -------- .../service/cq/EmailVerificationQuery.java | 27 ---------- .../ChattingErrorCode.java} | 4 +- .../message/domain/ChattingMessage.java | 3 +- .../domain/ChattingRoom.java | 2 +- .../domain/ChattingMessageHistory.java | 5 +- .../room}/domain/UserChattingHistory.java | 3 +- .../server/common/config/AuthWebConfig.java | 4 +- .../{ => resolver}/UserArgumentResolver.java | 6 +-- .../oauth/client/OAuthMemberClient.java | 12 ----- .../config => config/kakao}/KakaoConfig.java | 2 +- .../kakao}/KakaoProperties.java | 2 +- .../oauth/domain/OAuthMemberDetail.java | 35 +++++++++++++ .../server/oauth/dto/OAuthUserInfoDto.java | 38 -------------- .../implement/client/OAuthMemberClient.java | 12 +++++ .../client/OAuthMemberClientComposite.java | 6 +-- .../client/kakao/KakaoMemberClient.java | 31 ++++++++++++ .../provider}/AuthCodeRequestUrlProvider.java | 2 +- .../AuthCodeRequestUrlProviderComposite.java | 2 +- .../KakaoAuthCodeRequestUrlProvider.java | 6 +-- .../KakaoApiClient.java => KakaoClient.java} | 14 +++--- .../kakao/client/KakaoMemberClient.java | 30 ----------- ...erResponse.java => KakaoMemberDetail.java} | 8 +-- .../OAuthController.java | 2 +- .../server/oauth/service/OAuthService.java | 10 +--- .../{interest => user}/domain/Interest.java | 3 +- .../{interest => user}/domain/Keyword.java | 2 +- .../coffeemeet/server/user/domain/User.java | 2 +- .../implement}/InterestCommand.java | 8 +-- .../cq => user/implement}/InterestQuery.java | 8 +-- .../cq => implement}/UserCommand.java | 6 +-- .../{service/cq => implement}/UserQuery.java | 4 +- .../infrastructure}/InterestRepository.java | 4 +- .../UserRepository.java | 2 +- .../UserController.java | 12 ++--- .../dto/AuthInfo.java | 2 +- .../dto/MyProfileHttpDto.java | 4 +- .../dto/SignupHttpDto.java | 4 +- .../dto/UpdateProfileHttpDto.java | 4 +- .../dto/UserProfileHttpDto.java | 4 +- .../server/user/service/UserService.java | 38 +++++++------- .../server/user/service/dto/MyProfileDto.java | 2 +- .../user/service/dto/OAuthUserInfo.java | 28 ----------- .../user/service/dto/UserProfileDto.java | 2 +- .../auth/domain/AuthTokensGeneratorTest.java | 2 +- .../AuthControllerTest.java | 2 +- .../server/auth/service/AuthServiceTest.java | 22 ++++---- .../service/cq/RefreshTokenCommandTest.java | 3 +- .../service/cq/RefreshTokenQueryTest.java | 3 +- .../CertificationRepositoryTest.java | 4 +- .../CertificationControllerTest.java | 2 +- .../service/CertificationServiceTest.java | 14 ++++-- .../service/cq/CertificationCommandTest.java | 3 +- .../service/cq/CertificationQueryTest.java | 3 +- .../cq/EmailVerificationCommandTest.java | 3 +- .../cq/EmailVerificationQueryTest.java | 3 +- .../common/config/ControllerTestConfig.java | 2 +- .../dto/KakaoMemberResponseFixture.java | 6 +-- .../fixture/dto/MyProfileDtoFixture.java | 2 +- .../fixture/dto/OAuthUserInfoDtoFixture.java | 6 +-- .../common/fixture/dto/SignupDtoFixture.java | 6 +-- .../fixture/dto/UpdateProfileDtoFixture.java | 4 +- .../fixture/entity/CertificationFixture.java | 4 +- ...thCodeRequestUrlProviderCompositeTest.java | 2 + .../OAuthMemberClientCompositeTest.java | 8 +-- .../KakaoAuthCodeRequestUrlProviderTest.java | 3 +- ...piClientTest.java => KakaoClientTest.java} | 19 +++---- .../kakao/client/KakaoMemberClientTest.java | 12 +++-- .../OAuthControllerTest.java | 2 +- .../oauth/service/OAuthServiceTest.java | 22 +------- .../UserControllerTest.java | 6 +-- .../server/user/service/UserServiceTest.java | 50 ++++++++----------- 86 files changed, 292 insertions(+), 512 deletions(-) rename src/main/java/coffeemeet/server/auth/{repository => infrastructure}/RefreshTokenRepository.java (80%) rename src/main/java/coffeemeet/server/auth/{controller => presentation}/AuthController.java (91%) delete mode 100644 src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenCommand.java delete mode 100644 src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenQuery.java rename src/main/java/coffeemeet/server/certification/{repository => infrastructure}/CertificationRepository.java (88%) rename src/main/java/coffeemeet/server/certification/{repository => infrastructure}/EmailVerificationRepository.java (80%) rename src/main/java/coffeemeet/server/certification/{controller => presentation}/CertificationController.java (89%) rename src/main/java/coffeemeet/server/certification/{controller => presentation}/dto/EmailDto.java (81%) rename src/main/java/coffeemeet/server/certification/{controller => presentation}/dto/VerificationCodeDto.java (84%) delete mode 100644 src/main/java/coffeemeet/server/certification/service/cq/CertificationCommand.java delete mode 100644 src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java delete mode 100644 src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationCommand.java delete mode 100644 src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java rename src/main/java/coffeemeet/server/chatting/{message/exception/MessageErrorCode.java => exception/ChattingErrorCode.java} (80%) rename src/main/java/coffeemeet/server/chatting/{room => message}/domain/ChattingRoom.java (91%) rename src/main/java/coffeemeet/server/chatting/{message => room}/domain/ChattingMessageHistory.java (88%) rename src/main/java/coffeemeet/server/{user_chatting_history => chatting/room}/domain/UserChattingHistory.java (89%) rename src/main/java/coffeemeet/server/common/{ => resolver}/UserArgumentResolver.java (93%) delete mode 100644 src/main/java/coffeemeet/server/oauth/client/OAuthMemberClient.java rename src/main/java/coffeemeet/server/oauth/{infrastructure/kakao/config => config/kakao}/KakaoConfig.java (80%) rename src/main/java/coffeemeet/server/oauth/{infrastructure/kakao/config => config/kakao}/KakaoProperties.java (85%) create mode 100644 src/main/java/coffeemeet/server/oauth/domain/OAuthMemberDetail.java delete mode 100644 src/main/java/coffeemeet/server/oauth/dto/OAuthUserInfoDto.java create mode 100644 src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberClient.java rename src/main/java/coffeemeet/server/oauth/{ => implement}/client/OAuthMemberClientComposite.java (86%) create mode 100644 src/main/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClient.java rename src/main/java/coffeemeet/server/oauth/{authcode => implement/provider}/AuthCodeRequestUrlProvider.java (75%) rename src/main/java/coffeemeet/server/oauth/{authcode => implement/provider}/AuthCodeRequestUrlProviderComposite.java (96%) rename src/main/java/coffeemeet/server/oauth/{infrastructure => implement/provider}/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java (81%) rename src/main/java/coffeemeet/server/oauth/infrastructure/kakao/{client/KakaoApiClient.java => KakaoClient.java} (83%) delete mode 100644 src/main/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClient.java rename src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/{KakaoMemberResponse.java => KakaoMemberDetail.java} (82%) rename src/main/java/coffeemeet/server/oauth/{controller => presentation}/OAuthController.java (95%) rename src/main/java/coffeemeet/server/{interest => user}/domain/Interest.java (92%) rename src/main/java/coffeemeet/server/{interest => user}/domain/Keyword.java (55%) rename src/main/java/coffeemeet/server/{interest/service/cq => user/implement}/InterestCommand.java (84%) rename src/main/java/coffeemeet/server/{interest/service/cq => user/implement}/InterestQuery.java (74%) rename src/main/java/coffeemeet/server/user/{service/cq => implement}/UserCommand.java (83%) rename src/main/java/coffeemeet/server/user/{service/cq => implement}/UserQuery.java (96%) rename src/main/java/coffeemeet/server/{interest/repository => user/infrastructure}/InterestRepository.java (68%) rename src/main/java/coffeemeet/server/user/{repository => infrastructure}/UserRepository.java (89%) rename src/main/java/coffeemeet/server/user/{controller => presentation}/UserController.java (90%) rename src/main/java/coffeemeet/server/user/{controller => presentation}/dto/AuthInfo.java (56%) rename src/main/java/coffeemeet/server/user/{controller => presentation}/dto/MyProfileHttpDto.java (91%) rename src/main/java/coffeemeet/server/user/{controller => presentation}/dto/SignupHttpDto.java (83%) rename src/main/java/coffeemeet/server/user/{controller => presentation}/dto/UpdateProfileHttpDto.java (75%) rename src/main/java/coffeemeet/server/user/{controller => presentation}/dto/UserProfileHttpDto.java (86%) delete mode 100644 src/main/java/coffeemeet/server/user/service/dto/OAuthUserInfo.java rename src/test/java/coffeemeet/server/auth/{controller => presentation}/AuthControllerTest.java (99%) rename src/test/java/coffeemeet/server/certification/{repository => infrastructure}/CertificationRepositoryTest.java (93%) rename src/test/java/coffeemeet/server/certification/{controller => presentation}/CertificationControllerTest.java (99%) rename src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/{KakaoApiClientTest.java => KakaoClientTest.java} (83%) rename src/test/java/coffeemeet/server/oauth/{controller => presentation}/OAuthControllerTest.java (98%) rename src/test/java/coffeemeet/server/user/{controller => presentation}/UserControllerTest.java (98%) diff --git a/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java b/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java index ec205485..5446d4cc 100644 --- a/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java +++ b/src/main/java/coffeemeet/server/auth/domain/AuthTokensGenerator.java @@ -1,6 +1,6 @@ package coffeemeet.server.auth.domain; -import coffeemeet.server.auth.service.cq.RefreshTokenCommand; +import coffeemeet.server.auth.implement.RefreshTokenCommand; import java.util.Date; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/src/main/java/coffeemeet/server/auth/repository/RefreshTokenRepository.java b/src/main/java/coffeemeet/server/auth/infrastructure/RefreshTokenRepository.java similarity index 80% rename from src/main/java/coffeemeet/server/auth/repository/RefreshTokenRepository.java rename to src/main/java/coffeemeet/server/auth/infrastructure/RefreshTokenRepository.java index 436fca30..8fc81e0c 100644 --- a/src/main/java/coffeemeet/server/auth/repository/RefreshTokenRepository.java +++ b/src/main/java/coffeemeet/server/auth/infrastructure/RefreshTokenRepository.java @@ -1,4 +1,4 @@ -package coffeemeet.server.auth.repository; +package coffeemeet.server.auth.infrastructure; import coffeemeet.server.auth.domain.RefreshToken; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/coffeemeet/server/auth/controller/AuthController.java b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java similarity index 91% rename from src/main/java/coffeemeet/server/auth/controller/AuthController.java rename to src/main/java/coffeemeet/server/auth/presentation/AuthController.java index 75d7ce9c..cdcbb1b5 100644 --- a/src/main/java/coffeemeet/server/auth/controller/AuthController.java +++ b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java @@ -1,9 +1,9 @@ -package coffeemeet.server.auth.controller; +package coffeemeet.server.auth.presentation; import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.service.AuthService; import coffeemeet.server.common.annotation.Login; -import coffeemeet.server.user.controller.dto.AuthInfo; +import coffeemeet.server.user.presentation.dto.AuthInfo; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; diff --git a/src/main/java/coffeemeet/server/auth/service/AuthService.java b/src/main/java/coffeemeet/server/auth/service/AuthService.java index 34ccb68d..151da26c 100644 --- a/src/main/java/coffeemeet/server/auth/service/AuthService.java +++ b/src/main/java/coffeemeet/server/auth/service/AuthService.java @@ -5,7 +5,7 @@ import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.auth.domain.JwtTokenProvider; -import coffeemeet.server.auth.service.cq.RefreshTokenCommand; +import coffeemeet.server.auth.implement.RefreshTokenCommand; import coffeemeet.server.common.execption.InvalidAuthException; import coffeemeet.server.user.service.UserService; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenCommand.java b/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenCommand.java deleted file mode 100644 index 174077b3..00000000 --- a/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package coffeemeet.server.auth.service.cq; - -import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.auth.repository.RefreshTokenRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -@RequiredArgsConstructor -public class RefreshTokenCommand { - - private final RefreshTokenRepository refreshTokenRepository; - - public void createRefreshToken(RefreshToken refreshToken) { - refreshTokenRepository.save(refreshToken); - } - - public void deleteRefreshToken(Long userId) { - refreshTokenRepository.deleteById(userId); - } - -} diff --git a/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenQuery.java b/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenQuery.java deleted file mode 100644 index f3ef300a..00000000 --- a/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenQuery.java +++ /dev/null @@ -1,28 +0,0 @@ -package coffeemeet.server.auth.service.cq; - -import static coffeemeet.server.auth.exception.AuthErrorCode.AUTHENTICATION_FAILED; - -import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.auth.repository.RefreshTokenRepository; -import coffeemeet.server.common.execption.InvalidInputException; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class RefreshTokenQuery { - - private static final String USER_AUTHENTICATION_FAILED_MESSAGE = "사용자(%s)의 재인증(로그인)이 필요합니다."; - - private final RefreshTokenRepository refreshTokenRepository; - - public RefreshToken getRefreshToken(Long userId) { - return refreshTokenRepository.findById(userId) - .orElseThrow(() -> new InvalidInputException( - AUTHENTICATION_FAILED, - String.format(USER_AUTHENTICATION_FAILED_MESSAGE, userId))); - } - -} diff --git a/src/main/java/coffeemeet/server/certification/repository/CertificationRepository.java b/src/main/java/coffeemeet/server/certification/infrastructure/CertificationRepository.java similarity index 88% rename from src/main/java/coffeemeet/server/certification/repository/CertificationRepository.java rename to src/main/java/coffeemeet/server/certification/infrastructure/CertificationRepository.java index 2ee7ca0a..ca44b676 100644 --- a/src/main/java/coffeemeet/server/certification/repository/CertificationRepository.java +++ b/src/main/java/coffeemeet/server/certification/infrastructure/CertificationRepository.java @@ -1,4 +1,4 @@ -package coffeemeet.server.certification.repository; +package coffeemeet.server.certification.infrastructure; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; diff --git a/src/main/java/coffeemeet/server/certification/repository/EmailVerificationRepository.java b/src/main/java/coffeemeet/server/certification/infrastructure/EmailVerificationRepository.java similarity index 80% rename from src/main/java/coffeemeet/server/certification/repository/EmailVerificationRepository.java rename to src/main/java/coffeemeet/server/certification/infrastructure/EmailVerificationRepository.java index d3290459..b236bf43 100644 --- a/src/main/java/coffeemeet/server/certification/repository/EmailVerificationRepository.java +++ b/src/main/java/coffeemeet/server/certification/infrastructure/EmailVerificationRepository.java @@ -1,4 +1,4 @@ -package coffeemeet.server.certification.repository; +package coffeemeet.server.certification.infrastructure; import coffeemeet.server.certification.domain.EmailVerification; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/coffeemeet/server/certification/controller/CertificationController.java b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java similarity index 89% rename from src/main/java/coffeemeet/server/certification/controller/CertificationController.java rename to src/main/java/coffeemeet/server/certification/presentation/CertificationController.java index 62b62ada..7d843ff9 100644 --- a/src/main/java/coffeemeet/server/certification/controller/CertificationController.java +++ b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java @@ -1,11 +1,11 @@ -package coffeemeet.server.certification.controller; +package coffeemeet.server.certification.presentation; -import coffeemeet.server.certification.controller.dto.EmailDto; -import coffeemeet.server.certification.controller.dto.VerificationCodeDto; +import coffeemeet.server.certification.presentation.dto.EmailDto; +import coffeemeet.server.certification.presentation.dto.VerificationCodeDto; import coffeemeet.server.certification.service.CertificationService; import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.util.FileUtils; -import coffeemeet.server.user.controller.dto.AuthInfo; +import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/controller/dto/EmailDto.java b/src/main/java/coffeemeet/server/certification/presentation/dto/EmailDto.java similarity index 81% rename from src/main/java/coffeemeet/server/certification/controller/dto/EmailDto.java rename to src/main/java/coffeemeet/server/certification/presentation/dto/EmailDto.java index 4d04f708..8cc234fc 100644 --- a/src/main/java/coffeemeet/server/certification/controller/dto/EmailDto.java +++ b/src/main/java/coffeemeet/server/certification/presentation/dto/EmailDto.java @@ -1,4 +1,4 @@ -package coffeemeet.server.certification.controller.dto; +package coffeemeet.server.certification.presentation.dto; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/coffeemeet/server/certification/controller/dto/VerificationCodeDto.java b/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeDto.java similarity index 84% rename from src/main/java/coffeemeet/server/certification/controller/dto/VerificationCodeDto.java rename to src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeDto.java index e749309f..6ecbe31e 100644 --- a/src/main/java/coffeemeet/server/certification/controller/dto/VerificationCodeDto.java +++ b/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeDto.java @@ -1,4 +1,4 @@ -package coffeemeet.server.certification.controller.dto; +package coffeemeet.server.certification.presentation.dto; import jakarta.validation.constraints.NotNull; import org.hibernate.validator.constraints.Length; diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 1a182c98..f69f185a 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -5,15 +5,15 @@ import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.service.cq.CertificationCommand; -import coffeemeet.server.certification.service.cq.EmailVerificationCommand; -import coffeemeet.server.certification.service.cq.EmailVerificationQuery; +import coffeemeet.server.certification.implement.CertificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationQuery; import coffeemeet.server.common.execption.InvalidInputException; import coffeemeet.server.common.media.EmailSender; import coffeemeet.server.common.media.MediaManager; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.service.cq.UserQuery; +import coffeemeet.server.user.implement.UserQuery; import java.io.File; import java.util.random.RandomGenerator; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/certification/service/cq/CertificationCommand.java b/src/main/java/coffeemeet/server/certification/service/cq/CertificationCommand.java deleted file mode 100644 index 5b8fc603..00000000 --- a/src/main/java/coffeemeet/server/certification/service/cq/CertificationCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package coffeemeet.server.certification.service.cq; - -import static coffeemeet.server.certification.exception.CertificationErrorCode.EXISTED_COMPANY_EMAIL; - -import coffeemeet.server.certification.domain.Certification; -import coffeemeet.server.certification.domain.CompanyEmail; -import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.repository.CertificationRepository; -import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.user.domain.User; -import java.util.function.Consumer; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional -@RequiredArgsConstructor -public class CertificationCommand { - - private static final String EXISTED_COMPANY_EMAIL_MESSAGE = "이미 사용 중인 회사 이메일(%s) 입니다."; - - private final CertificationRepository certificationRepository; - - public void createCertification(CompanyEmail companyEmail, String businessCardUrl, - Department department, User user) { - certificationRepository.save( - Certification.builder() - .companyEmail(companyEmail) - .businessCardUrl(businessCardUrl) - .department(department) - .user(user) - .build() - ); - } - - public void hasDuplicatedCompanyEmail(CompanyEmail companyEmail) { - if (certificationRepository.existsByCompanyEmail(companyEmail)) { - throw new InvalidInputException(EXISTED_COMPANY_EMAIL, - String.format(EXISTED_COMPANY_EMAIL_MESSAGE, companyEmail.getValue())); - } - } - - public void applyIfCertifiedUser(Long userId, Consumer consumer) { - certificationRepository.findByUserId(userId).ifPresent(consumer); - } - -} diff --git a/src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java b/src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java deleted file mode 100644 index 6f2625b3..00000000 --- a/src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java +++ /dev/null @@ -1,27 +0,0 @@ -package coffeemeet.server.certification.service.cq; - -import static coffeemeet.server.certification.exception.CertificationErrorCode.CERTIFICATION_NOT_FOUND; - -import coffeemeet.server.certification.domain.Certification; -import coffeemeet.server.certification.repository.CertificationRepository; -import coffeemeet.server.common.execption.InvalidInputException; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class CertificationQuery { - - private static final String CERTIFICATION_NOT_FOUND_MESSAGE = "해당 사용자(%s)의 인증정보를 찾을 수 없습니다."; - - private final CertificationRepository certificationRepository; - - public Certification getCertificationByUserId(Long userId) { - return certificationRepository.findByUserId(userId) - .orElseThrow(() -> new InvalidInputException(CERTIFICATION_NOT_FOUND, - String.format(CERTIFICATION_NOT_FOUND_MESSAGE, userId))); - } - -} diff --git a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationCommand.java b/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationCommand.java deleted file mode 100644 index 5412ecc3..00000000 --- a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationCommand.java +++ /dev/null @@ -1,20 +0,0 @@ -package coffeemeet.server.certification.service.cq; - -import coffeemeet.server.certification.domain.CompanyEmail; -import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.repository.EmailVerificationRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class EmailVerificationCommand { - - private final EmailVerificationRepository emailVerificationRepository; - - public void createEmailVerification(Long userId, CompanyEmail companyEmail, - String verificationCode) { - emailVerificationRepository.save(new EmailVerification(userId, companyEmail, verificationCode)); - } - -} diff --git a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java b/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java deleted file mode 100644 index df641472..00000000 --- a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java +++ /dev/null @@ -1,27 +0,0 @@ -package coffeemeet.server.certification.service.cq; - -import static coffeemeet.server.certification.exception.CertificationErrorCode.VERIFICATION_CODE_NOT_FOUND; - -import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.repository.EmailVerificationRepository; -import coffeemeet.server.common.execption.InvalidInputException; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class EmailVerificationQuery { - - private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증코드를 요청한 기록이 없습니다."; - - private final EmailVerificationRepository emailVerificationRepository; - - public String getCodeById(Long userId) { - EmailVerification emailVerification = emailVerificationRepository.findById(userId) - .orElseThrow(() -> new InvalidInputException( - VERIFICATION_CODE_NOT_FOUND, - String.format(VERIFICATION_CODE_NOT_FOUND_MESSAGE, userId))); - return emailVerification.getCode(); - } - -} diff --git a/src/main/java/coffeemeet/server/chatting/message/exception/MessageErrorCode.java b/src/main/java/coffeemeet/server/chatting/exception/ChattingErrorCode.java similarity index 80% rename from src/main/java/coffeemeet/server/chatting/message/exception/MessageErrorCode.java rename to src/main/java/coffeemeet/server/chatting/exception/ChattingErrorCode.java index 70587f3b..c5ed5ca1 100644 --- a/src/main/java/coffeemeet/server/chatting/message/exception/MessageErrorCode.java +++ b/src/main/java/coffeemeet/server/chatting/exception/ChattingErrorCode.java @@ -1,4 +1,4 @@ -package coffeemeet.server.chatting.message.exception; +package coffeemeet.server.chatting.exception; import coffeemeet.server.common.execption.ErrorCode; import lombok.Getter; @@ -6,7 +6,7 @@ @Getter @RequiredArgsConstructor -public enum MessageErrorCode implements ErrorCode { +public enum ChattingErrorCode implements ErrorCode { INVALID_MESSAGE("CM000", "유효하지 않은 메세지 형식입니다."), ; diff --git a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java index d93b98ed..88939f07 100644 --- a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java +++ b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java @@ -1,8 +1,7 @@ package coffeemeet.server.chatting.message.domain; -import static coffeemeet.server.chatting.message.exception.MessageErrorCode.INVALID_MESSAGE; +import static coffeemeet.server.chatting.exception.ChattingErrorCode.INVALID_MESSAGE; -import coffeemeet.server.chatting.room.domain.ChattingRoom; import coffeemeet.server.common.entity.BaseEntity; import coffeemeet.server.common.execption.InvalidInputException; import jakarta.persistence.Column; diff --git a/src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoom.java b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java similarity index 91% rename from src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoom.java rename to src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java index ee0a12ca..f60d59ca 100644 --- a/src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoom.java +++ b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java @@ -1,4 +1,4 @@ -package coffeemeet.server.chatting.room.domain; +package coffeemeet.server.chatting.message.domain; import coffeemeet.server.common.entity.BaseEntity; import jakarta.persistence.Entity; diff --git a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessageHistory.java b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java similarity index 88% rename from src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessageHistory.java rename to src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java index 8ac78084..fb97bada 100644 --- a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessageHistory.java +++ b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java @@ -1,8 +1,7 @@ -package coffeemeet.server.chatting.message.domain; +package coffeemeet.server.chatting.room.domain; -import static coffeemeet.server.chatting.message.exception.MessageErrorCode.INVALID_MESSAGE; +import static coffeemeet.server.chatting.exception.ChattingErrorCode.INVALID_MESSAGE; -import coffeemeet.server.chatting.room.domain.ChattingRoomHistory; import coffeemeet.server.common.entity.BaseEntity; import coffeemeet.server.common.execption.InvalidInputException; import jakarta.persistence.Column; diff --git a/src/main/java/coffeemeet/server/user_chatting_history/domain/UserChattingHistory.java b/src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java similarity index 89% rename from src/main/java/coffeemeet/server/user_chatting_history/domain/UserChattingHistory.java rename to src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java index ca81c79b..37fb1ed6 100644 --- a/src/main/java/coffeemeet/server/user_chatting_history/domain/UserChattingHistory.java +++ b/src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java @@ -1,6 +1,5 @@ -package coffeemeet.server.user_chatting_history.domain; +package coffeemeet.server.chatting.room.domain; -import coffeemeet.server.chatting.room.domain.ChattingRoomHistory; import coffeemeet.server.common.entity.BaseEntity; import coffeemeet.server.user.domain.User; import jakarta.persistence.Entity; diff --git a/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java b/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java index d2534d66..c126facb 100644 --- a/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java +++ b/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java @@ -1,8 +1,8 @@ package coffeemeet.server.common.config; import coffeemeet.server.auth.domain.JwtTokenProvider; -import coffeemeet.server.auth.service.cq.RefreshTokenQuery; -import coffeemeet.server.common.UserArgumentResolver; +import coffeemeet.server.auth.implement.RefreshTokenQuery; +import coffeemeet.server.common.resolver.UserArgumentResolver; import coffeemeet.server.oauth.utils.converter.OAuthProviderConverter; import java.util.List; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/common/UserArgumentResolver.java b/src/main/java/coffeemeet/server/common/resolver/UserArgumentResolver.java similarity index 93% rename from src/main/java/coffeemeet/server/common/UserArgumentResolver.java rename to src/main/java/coffeemeet/server/common/resolver/UserArgumentResolver.java index 947c20b6..73acb2cd 100644 --- a/src/main/java/coffeemeet/server/common/UserArgumentResolver.java +++ b/src/main/java/coffeemeet/server/common/resolver/UserArgumentResolver.java @@ -1,13 +1,13 @@ -package coffeemeet.server.common; +package coffeemeet.server.common.resolver; import static coffeemeet.server.auth.exception.AuthErrorCode.AUTHENTICATION_FAILED; import coffeemeet.server.auth.domain.JwtTokenProvider; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.auth.service.cq.RefreshTokenQuery; +import coffeemeet.server.auth.implement.RefreshTokenQuery; import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.user.controller.dto.AuthInfo; +import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.core.MethodParameter; diff --git a/src/main/java/coffeemeet/server/oauth/client/OAuthMemberClient.java b/src/main/java/coffeemeet/server/oauth/client/OAuthMemberClient.java deleted file mode 100644 index 7a13eeea..00000000 --- a/src/main/java/coffeemeet/server/oauth/client/OAuthMemberClient.java +++ /dev/null @@ -1,12 +0,0 @@ -package coffeemeet.server.oauth.client; - -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; -import coffeemeet.server.user.domain.OAuthProvider; - -public interface OAuthMemberClient { - - OAuthProvider oAuthProvider(); - - OAuthUserInfoDto.Response fetch(String authCode); - -} diff --git a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/config/KakaoConfig.java b/src/main/java/coffeemeet/server/oauth/config/kakao/KakaoConfig.java similarity index 80% rename from src/main/java/coffeemeet/server/oauth/infrastructure/kakao/config/KakaoConfig.java rename to src/main/java/coffeemeet/server/oauth/config/kakao/KakaoConfig.java index 13f71437..c1eeed39 100644 --- a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/config/KakaoConfig.java +++ b/src/main/java/coffeemeet/server/oauth/config/kakao/KakaoConfig.java @@ -1,4 +1,4 @@ -package coffeemeet.server.oauth.infrastructure.kakao.config; +package coffeemeet.server.oauth.config.kakao; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/config/KakaoProperties.java b/src/main/java/coffeemeet/server/oauth/config/kakao/KakaoProperties.java similarity index 85% rename from src/main/java/coffeemeet/server/oauth/infrastructure/kakao/config/KakaoProperties.java rename to src/main/java/coffeemeet/server/oauth/config/kakao/KakaoProperties.java index bcce7b4e..ab3972ae 100644 --- a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/config/KakaoProperties.java +++ b/src/main/java/coffeemeet/server/oauth/config/kakao/KakaoProperties.java @@ -1,4 +1,4 @@ -package coffeemeet.server.oauth.infrastructure.kakao.config; +package coffeemeet.server.oauth.config.kakao; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/oauth/domain/OAuthMemberDetail.java b/src/main/java/coffeemeet/server/oauth/domain/OAuthMemberDetail.java new file mode 100644 index 00000000..53f33c37 --- /dev/null +++ b/src/main/java/coffeemeet/server/oauth/domain/OAuthMemberDetail.java @@ -0,0 +1,35 @@ +package coffeemeet.server.oauth.domain; + +import coffeemeet.server.user.domain.OAuthProvider; + +public record OAuthMemberDetail( + String name, + String profileImage, + String birthYear, + String birthDay, + String email, + OAuthProvider oAuthProvider, + String oAuthProviderId +) { + + public static OAuthMemberDetail of( + String name, + String profileImage, + String birthYear, + String birthDay, + String email, + OAuthProvider oAuthProvider, + String oAuthProviderId + ) { + return new OAuthMemberDetail( + name, + profileImage, + birthYear, + birthDay, + email, + oAuthProvider, + oAuthProviderId + ); + } + +} diff --git a/src/main/java/coffeemeet/server/oauth/dto/OAuthUserInfoDto.java b/src/main/java/coffeemeet/server/oauth/dto/OAuthUserInfoDto.java deleted file mode 100644 index 0a1c1782..00000000 --- a/src/main/java/coffeemeet/server/oauth/dto/OAuthUserInfoDto.java +++ /dev/null @@ -1,38 +0,0 @@ -package coffeemeet.server.oauth.dto; - -import coffeemeet.server.user.domain.OAuthProvider; - -public sealed interface OAuthUserInfoDto permits OAuthUserInfoDto.Response { - - record Response( - String name, - String profileImage, - String birthYear, - String birthDay, - String email, - OAuthProvider oAuthProvider, - String oAuthProviderId - ) implements OAuthUserInfoDto { - - public static OAuthUserInfoDto.Response of( - String name, - String profileImage, - String birthYear, - String birthDay, - String email, - OAuthProvider oAuthProvider, - String oAuthProviderId - ) { - return new OAuthUserInfoDto.Response( - name, - profileImage, - birthYear, - birthDay, - email, - oAuthProvider, - oAuthProviderId - ); - } - } - -} diff --git a/src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberClient.java b/src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberClient.java new file mode 100644 index 00000000..f6763350 --- /dev/null +++ b/src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberClient.java @@ -0,0 +1,12 @@ +package coffeemeet.server.oauth.implement.client; + +import coffeemeet.server.oauth.domain.OAuthMemberDetail; +import coffeemeet.server.user.domain.OAuthProvider; + +public interface OAuthMemberClient { + + OAuthProvider oAuthProvider(); + + OAuthMemberDetail fetch(String authCode); + +} diff --git a/src/main/java/coffeemeet/server/oauth/client/OAuthMemberClientComposite.java b/src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberClientComposite.java similarity index 86% rename from src/main/java/coffeemeet/server/oauth/client/OAuthMemberClientComposite.java rename to src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberClientComposite.java index 21792220..ece1393e 100644 --- a/src/main/java/coffeemeet/server/oauth/client/OAuthMemberClientComposite.java +++ b/src/main/java/coffeemeet/server/oauth/implement/client/OAuthMemberClientComposite.java @@ -1,9 +1,9 @@ -package coffeemeet.server.oauth.client; +package coffeemeet.server.oauth.implement.client; import static coffeemeet.server.auth.exception.AuthErrorCode.INVALID_LOGIN_TYPE; import coffeemeet.server.common.execption.InvalidAuthException; -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; +import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.user.domain.OAuthProvider; import java.util.Map; import java.util.Optional; @@ -24,7 +24,7 @@ public OAuthMemberClientComposite(Set clients) { ); } - public OAuthUserInfoDto.Response fetch(OAuthProvider oAuthProvider, String authCode) { + public OAuthMemberDetail fetch(OAuthProvider oAuthProvider, String authCode) { return getClient(oAuthProvider).fetch(authCode); } diff --git a/src/main/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClient.java b/src/main/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClient.java new file mode 100644 index 00000000..645194e8 --- /dev/null +++ b/src/main/java/coffeemeet/server/oauth/implement/client/kakao/KakaoMemberClient.java @@ -0,0 +1,31 @@ +package coffeemeet.server.oauth.implement.client.kakao; + +import coffeemeet.server.oauth.domain.OAuthMemberDetail; +import coffeemeet.server.oauth.implement.client.OAuthMemberClient; +import coffeemeet.server.oauth.infrastructure.kakao.KakaoClient; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; +import coffeemeet.server.user.domain.OAuthProvider; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class KakaoMemberClient implements OAuthMemberClient { + + private final KakaoClient kakaoClient; + + @Override + public OAuthProvider oAuthProvider() { + return OAuthProvider.KAKAO; + } + + @Override + public OAuthMemberDetail fetch(String authCode) { + KakaoTokens tokenInfo = kakaoClient.fetchToken(authCode); + KakaoMemberDetail response = kakaoClient.fetchMember(tokenInfo.accessToken()); + + return response.toOAuthMemberDetail(); + } + +} diff --git a/src/main/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProvider.java b/src/main/java/coffeemeet/server/oauth/implement/provider/AuthCodeRequestUrlProvider.java similarity index 75% rename from src/main/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProvider.java rename to src/main/java/coffeemeet/server/oauth/implement/provider/AuthCodeRequestUrlProvider.java index c22a7841..63b4fc5f 100644 --- a/src/main/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProvider.java +++ b/src/main/java/coffeemeet/server/oauth/implement/provider/AuthCodeRequestUrlProvider.java @@ -1,4 +1,4 @@ -package coffeemeet.server.oauth.authcode; +package coffeemeet.server.oauth.implement.provider; import coffeemeet.server.user.domain.OAuthProvider; diff --git a/src/main/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProviderComposite.java b/src/main/java/coffeemeet/server/oauth/implement/provider/AuthCodeRequestUrlProviderComposite.java similarity index 96% rename from src/main/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProviderComposite.java rename to src/main/java/coffeemeet/server/oauth/implement/provider/AuthCodeRequestUrlProviderComposite.java index ca79b118..b65f9722 100644 --- a/src/main/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProviderComposite.java +++ b/src/main/java/coffeemeet/server/oauth/implement/provider/AuthCodeRequestUrlProviderComposite.java @@ -1,4 +1,4 @@ -package coffeemeet.server.oauth.authcode; +package coffeemeet.server.oauth.implement.provider; import static coffeemeet.server.auth.exception.AuthErrorCode.INVALID_LOGIN_TYPE; diff --git a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java b/src/main/java/coffeemeet/server/oauth/implement/provider/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java similarity index 81% rename from src/main/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java rename to src/main/java/coffeemeet/server/oauth/implement/provider/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java index 19c563e3..6d8dbf4b 100644 --- a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java +++ b/src/main/java/coffeemeet/server/oauth/implement/provider/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java @@ -1,7 +1,7 @@ -package coffeemeet.server.oauth.infrastructure.kakao.authcode; +package coffeemeet.server.oauth.implement.provider.kakao.authcode; -import coffeemeet.server.oauth.authcode.AuthCodeRequestUrlProvider; -import coffeemeet.server.oauth.infrastructure.kakao.config.KakaoProperties; +import coffeemeet.server.oauth.config.kakao.KakaoProperties; +import coffeemeet.server.oauth.implement.provider.AuthCodeRequestUrlProvider; import coffeemeet.server.user.domain.OAuthProvider; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoApiClient.java b/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoClient.java similarity index 83% rename from src/main/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoApiClient.java rename to src/main/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoClient.java index d0b3bd97..47917f0d 100644 --- a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoApiClient.java +++ b/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/KakaoClient.java @@ -1,7 +1,7 @@ -package coffeemeet.server.oauth.infrastructure.kakao.client; +package coffeemeet.server.oauth.infrastructure.kakao; -import coffeemeet.server.oauth.infrastructure.kakao.config.KakaoProperties; -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberResponse; +import coffeemeet.server.oauth.config.kakao.KakaoProperties; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpEntity; @@ -15,7 +15,7 @@ @Component @RequiredArgsConstructor -public class KakaoApiClient { +public class KakaoClient { private static final String REQUEST_TOKEN_URL = "https://kauth.kakao.com/oauth/token"; private static final String REQUEST_INFO_URL = "https://kapi.kakao.com/v2/user/me"; @@ -45,15 +45,15 @@ public KakaoTokens fetchToken(String authCode) { return response; } - public KakaoMemberResponse fetchMember(String accessToken) { + public KakaoMemberDetail fetchMember(String accessToken) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); httpHeaders.set("Authorization", BEARER_TYPE + accessToken); HttpEntity request = new HttpEntity<>(httpHeaders); - KakaoMemberResponse response = restTemplate.exchange(REQUEST_INFO_URL, HttpMethod.GET, request, - KakaoMemberResponse.class).getBody(); + KakaoMemberDetail response = restTemplate.exchange(REQUEST_INFO_URL, HttpMethod.GET, request, + KakaoMemberDetail.class).getBody(); assert response != null; return response; diff --git a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClient.java b/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClient.java deleted file mode 100644 index d9343906..00000000 --- a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClient.java +++ /dev/null @@ -1,30 +0,0 @@ -package coffeemeet.server.oauth.infrastructure.kakao.client; - -import coffeemeet.server.oauth.client.OAuthMemberClient; -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberResponse; -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; -import coffeemeet.server.user.domain.OAuthProvider; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class KakaoMemberClient implements OAuthMemberClient { - - private final KakaoApiClient kakaoApiClient; - - @Override - public OAuthProvider oAuthProvider() { - return OAuthProvider.KAKAO; - } - - @Override - public OAuthUserInfoDto.Response fetch(String authCode) { - KakaoTokens tokenInfo = kakaoApiClient.fetchToken(authCode); - KakaoMemberResponse response = kakaoApiClient.fetchMember(tokenInfo.accessToken()); - - return response.toOAuthInfoResponse(); - } - -} diff --git a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/KakaoMemberResponse.java b/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/KakaoMemberDetail.java similarity index 82% rename from src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/KakaoMemberResponse.java rename to src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/KakaoMemberDetail.java index 12acbdea..7f644b03 100644 --- a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/KakaoMemberResponse.java +++ b/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/dto/KakaoMemberDetail.java @@ -1,18 +1,18 @@ package coffeemeet.server.oauth.infrastructure.kakao.dto; -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; +import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.user.domain.OAuthProvider; import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; @JsonNaming(SnakeCaseStrategy.class) -public record KakaoMemberResponse( +public record KakaoMemberDetail( Long id, KakaoAccount kakaoAccount ) { - public OAuthUserInfoDto.Response toOAuthInfoResponse() { - return OAuthUserInfoDto.Response.of( + public OAuthMemberDetail toOAuthMemberDetail() { + return OAuthMemberDetail.of( kakaoAccount.name, kakaoAccount.profile.profileImageUrl, kakaoAccount.birthyear, diff --git a/src/main/java/coffeemeet/server/oauth/controller/OAuthController.java b/src/main/java/coffeemeet/server/oauth/presentation/OAuthController.java similarity index 95% rename from src/main/java/coffeemeet/server/oauth/controller/OAuthController.java rename to src/main/java/coffeemeet/server/oauth/presentation/OAuthController.java index e30e06bf..86907a9e 100644 --- a/src/main/java/coffeemeet/server/oauth/controller/OAuthController.java +++ b/src/main/java/coffeemeet/server/oauth/presentation/OAuthController.java @@ -1,4 +1,4 @@ -package coffeemeet.server.oauth.controller; +package coffeemeet.server.oauth.presentation; import coffeemeet.server.oauth.service.OAuthService; import coffeemeet.server.user.domain.OAuthProvider; diff --git a/src/main/java/coffeemeet/server/oauth/service/OAuthService.java b/src/main/java/coffeemeet/server/oauth/service/OAuthService.java index fd9c5221..21cd2d33 100644 --- a/src/main/java/coffeemeet/server/oauth/service/OAuthService.java +++ b/src/main/java/coffeemeet/server/oauth/service/OAuthService.java @@ -1,9 +1,7 @@ package coffeemeet.server.oauth.service; -import coffeemeet.server.oauth.authcode.AuthCodeRequestUrlProviderComposite; -import coffeemeet.server.oauth.client.OAuthMemberClientComposite; +import coffeemeet.server.oauth.implement.provider.AuthCodeRequestUrlProviderComposite; import coffeemeet.server.user.domain.OAuthProvider; -import coffeemeet.server.user.service.dto.OAuthUserInfo; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -12,15 +10,9 @@ public class OAuthService { private final AuthCodeRequestUrlProviderComposite authCodeRequestUrlProviderComposite; - private final OAuthMemberClientComposite oauthMemberClientComposite; public String getAuthCodeRequestUrl(OAuthProvider oAuthProvider) { return authCodeRequestUrlProviderComposite.provide(oAuthProvider); } - public OAuthUserInfo getOAuthUserInfo(OAuthProvider oAuthProvider, String authCode) { - return OAuthUserInfo.from(oauthMemberClientComposite.fetch(oAuthProvider, - authCode)); - } - } diff --git a/src/main/java/coffeemeet/server/interest/domain/Interest.java b/src/main/java/coffeemeet/server/user/domain/Interest.java similarity index 92% rename from src/main/java/coffeemeet/server/interest/domain/Interest.java rename to src/main/java/coffeemeet/server/user/domain/Interest.java index 1a4fd237..aa70280e 100644 --- a/src/main/java/coffeemeet/server/interest/domain/Interest.java +++ b/src/main/java/coffeemeet/server/user/domain/Interest.java @@ -1,7 +1,6 @@ -package coffeemeet.server.interest.domain; +package coffeemeet.server.user.domain; import coffeemeet.server.common.entity.BaseEntity; -import coffeemeet.server.user.domain.User; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; diff --git a/src/main/java/coffeemeet/server/interest/domain/Keyword.java b/src/main/java/coffeemeet/server/user/domain/Keyword.java similarity index 55% rename from src/main/java/coffeemeet/server/interest/domain/Keyword.java rename to src/main/java/coffeemeet/server/user/domain/Keyword.java index 717ad9e5..e6a92fd7 100644 --- a/src/main/java/coffeemeet/server/interest/domain/Keyword.java +++ b/src/main/java/coffeemeet/server/user/domain/Keyword.java @@ -1,4 +1,4 @@ -package coffeemeet.server.interest.domain; +package coffeemeet.server.user.domain; public enum Keyword { COOK, diff --git a/src/main/java/coffeemeet/server/user/domain/User.java b/src/main/java/coffeemeet/server/user/domain/User.java index a156d0a8..0e1d3a60 100644 --- a/src/main/java/coffeemeet/server/user/domain/User.java +++ b/src/main/java/coffeemeet/server/user/domain/User.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.domain; -import coffeemeet.server.chatting.room.domain.ChattingRoom; +import coffeemeet.server.chatting.message.domain.ChattingRoom; import coffeemeet.server.common.entity.AdvancedBaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Embedded; diff --git a/src/main/java/coffeemeet/server/interest/service/cq/InterestCommand.java b/src/main/java/coffeemeet/server/user/implement/InterestCommand.java similarity index 84% rename from src/main/java/coffeemeet/server/interest/service/cq/InterestCommand.java rename to src/main/java/coffeemeet/server/user/implement/InterestCommand.java index f41e7fb0..2fb312ef 100644 --- a/src/main/java/coffeemeet/server/interest/service/cq/InterestCommand.java +++ b/src/main/java/coffeemeet/server/user/implement/InterestCommand.java @@ -1,9 +1,9 @@ -package coffeemeet.server.interest.service.cq; +package coffeemeet.server.user.implement; -import coffeemeet.server.interest.domain.Interest; -import coffeemeet.server.interest.domain.Keyword; -import coffeemeet.server.interest.repository.InterestRepository; +import coffeemeet.server.user.domain.Interest; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.domain.User; +import coffeemeet.server.user.infrastructure.InterestRepository; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/coffeemeet/server/interest/service/cq/InterestQuery.java b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java similarity index 74% rename from src/main/java/coffeemeet/server/interest/service/cq/InterestQuery.java rename to src/main/java/coffeemeet/server/user/implement/InterestQuery.java index 1abe126f..b605c471 100644 --- a/src/main/java/coffeemeet/server/interest/service/cq/InterestQuery.java +++ b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java @@ -1,8 +1,8 @@ -package coffeemeet.server.interest.service.cq; +package coffeemeet.server.user.implement; -import coffeemeet.server.interest.domain.Interest; -import coffeemeet.server.interest.domain.Keyword; -import coffeemeet.server.interest.repository.InterestRepository; +import coffeemeet.server.user.domain.Interest; +import coffeemeet.server.user.domain.Keyword; +import coffeemeet.server.user.infrastructure.InterestRepository; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/coffeemeet/server/user/service/cq/UserCommand.java b/src/main/java/coffeemeet/server/user/implement/UserCommand.java similarity index 83% rename from src/main/java/coffeemeet/server/user/service/cq/UserCommand.java rename to src/main/java/coffeemeet/server/user/implement/UserCommand.java index cc8ffc85..5529abcd 100644 --- a/src/main/java/coffeemeet/server/user/service/cq/UserCommand.java +++ b/src/main/java/coffeemeet/server/user/implement/UserCommand.java @@ -1,8 +1,8 @@ -package coffeemeet.server.user.service.cq; +package coffeemeet.server.user.implement; -import coffeemeet.server.interest.repository.InterestRepository; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.repository.UserRepository; +import coffeemeet.server.user.infrastructure.InterestRepository; +import coffeemeet.server.user.infrastructure.UserRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/coffeemeet/server/user/service/cq/UserQuery.java b/src/main/java/coffeemeet/server/user/implement/UserQuery.java similarity index 96% rename from src/main/java/coffeemeet/server/user/service/cq/UserQuery.java rename to src/main/java/coffeemeet/server/user/implement/UserQuery.java index c318d57f..ada44e53 100644 --- a/src/main/java/coffeemeet/server/user/service/cq/UserQuery.java +++ b/src/main/java/coffeemeet/server/user/implement/UserQuery.java @@ -1,4 +1,4 @@ -package coffeemeet.server.user.service.cq; +package coffeemeet.server.user.implement; import static coffeemeet.server.user.exception.UserErrorCode.ALREADY_EXIST_NICKNAME; import static coffeemeet.server.user.exception.UserErrorCode.ALREADY_EXIST_USER; @@ -9,7 +9,7 @@ import coffeemeet.server.user.domain.OAuthInfo; import coffeemeet.server.user.domain.OAuthProvider; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.repository.UserRepository; +import coffeemeet.server.user.infrastructure.UserRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/coffeemeet/server/interest/repository/InterestRepository.java b/src/main/java/coffeemeet/server/user/infrastructure/InterestRepository.java similarity index 68% rename from src/main/java/coffeemeet/server/interest/repository/InterestRepository.java rename to src/main/java/coffeemeet/server/user/infrastructure/InterestRepository.java index 933d0fcf..14d1070e 100644 --- a/src/main/java/coffeemeet/server/interest/repository/InterestRepository.java +++ b/src/main/java/coffeemeet/server/user/infrastructure/InterestRepository.java @@ -1,6 +1,6 @@ -package coffeemeet.server.interest.repository; +package coffeemeet.server.user.infrastructure; -import coffeemeet.server.interest.domain.Interest; +import coffeemeet.server.user.domain.Interest; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/coffeemeet/server/user/repository/UserRepository.java b/src/main/java/coffeemeet/server/user/infrastructure/UserRepository.java similarity index 89% rename from src/main/java/coffeemeet/server/user/repository/UserRepository.java rename to src/main/java/coffeemeet/server/user/infrastructure/UserRepository.java index 0b86e1ac..3303ac57 100644 --- a/src/main/java/coffeemeet/server/user/repository/UserRepository.java +++ b/src/main/java/coffeemeet/server/user/infrastructure/UserRepository.java @@ -1,4 +1,4 @@ -package coffeemeet.server.user.repository; +package coffeemeet.server.user.infrastructure; import coffeemeet.server.user.domain.OAuthInfo; import coffeemeet.server.user.domain.User; diff --git a/src/main/java/coffeemeet/server/user/controller/UserController.java b/src/main/java/coffeemeet/server/user/presentation/UserController.java similarity index 90% rename from src/main/java/coffeemeet/server/user/controller/UserController.java rename to src/main/java/coffeemeet/server/user/presentation/UserController.java index 73da33c1..b3bfc342 100644 --- a/src/main/java/coffeemeet/server/user/controller/UserController.java +++ b/src/main/java/coffeemeet/server/user/presentation/UserController.java @@ -1,14 +1,14 @@ -package coffeemeet.server.user.controller; +package coffeemeet.server.user.presentation; import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.util.FileUtils; -import coffeemeet.server.user.controller.dto.AuthInfo; -import coffeemeet.server.user.controller.dto.MyProfileHttpDto; -import coffeemeet.server.user.controller.dto.SignupHttpDto; -import coffeemeet.server.user.controller.dto.UpdateProfileHttpDto; -import coffeemeet.server.user.controller.dto.UserProfileHttpDto; import coffeemeet.server.user.domain.OAuthProvider; +import coffeemeet.server.user.presentation.dto.AuthInfo; +import coffeemeet.server.user.presentation.dto.MyProfileHttpDto; +import coffeemeet.server.user.presentation.dto.SignupHttpDto; +import coffeemeet.server.user.presentation.dto.UpdateProfileHttpDto; +import coffeemeet.server.user.presentation.dto.UserProfileHttpDto; import coffeemeet.server.user.service.UserService; import coffeemeet.server.user.service.dto.MyProfileDto; import coffeemeet.server.user.service.dto.UserProfileDto.Response; diff --git a/src/main/java/coffeemeet/server/user/controller/dto/AuthInfo.java b/src/main/java/coffeemeet/server/user/presentation/dto/AuthInfo.java similarity index 56% rename from src/main/java/coffeemeet/server/user/controller/dto/AuthInfo.java rename to src/main/java/coffeemeet/server/user/presentation/dto/AuthInfo.java index b1bbaa20..3d251c2a 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/AuthInfo.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/AuthInfo.java @@ -1,4 +1,4 @@ -package coffeemeet.server.user.controller.dto; +package coffeemeet.server.user.presentation.dto; public record AuthInfo(Long userId, String refreshToken) { diff --git a/src/main/java/coffeemeet/server/user/controller/dto/MyProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHttpDto.java similarity index 91% rename from src/main/java/coffeemeet/server/user/controller/dto/MyProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHttpDto.java index 9ef96f7b..9add67b9 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/MyProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHttpDto.java @@ -1,7 +1,7 @@ -package coffeemeet.server.user.controller.dto; +package coffeemeet.server.user.presentation.dto; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.interest.domain.Keyword; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.service.dto.MyProfileDto; import java.time.LocalDateTime; import java.util.List; diff --git a/src/main/java/coffeemeet/server/user/controller/dto/SignupHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/SignupHttpDto.java similarity index 83% rename from src/main/java/coffeemeet/server/user/controller/dto/SignupHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/SignupHttpDto.java index 27c5fe4b..ef5739e0 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/SignupHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/SignupHttpDto.java @@ -1,6 +1,6 @@ -package coffeemeet.server.user.controller.dto; +package coffeemeet.server.user.presentation.dto; -import coffeemeet.server.interest.domain.Keyword; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.domain.OAuthProvider; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/coffeemeet/server/user/controller/dto/UpdateProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHttpDto.java similarity index 75% rename from src/main/java/coffeemeet/server/user/controller/dto/UpdateProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHttpDto.java index e84ce0e1..e5a596c1 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/UpdateProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHttpDto.java @@ -1,6 +1,6 @@ -package coffeemeet.server.user.controller.dto; +package coffeemeet.server.user.presentation.dto; -import coffeemeet.server.interest.domain.Keyword; +import coffeemeet.server.user.domain.Keyword; import jakarta.validation.constraints.Size; import java.util.List; diff --git a/src/main/java/coffeemeet/server/user/controller/dto/UserProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHttpDto.java similarity index 86% rename from src/main/java/coffeemeet/server/user/controller/dto/UserProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHttpDto.java index 05779cee..c47d566d 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/UserProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHttpDto.java @@ -1,7 +1,7 @@ -package coffeemeet.server.user.controller.dto; +package coffeemeet.server.user.presentation.dto; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.interest.domain.Keyword; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.service.dto.UserProfileDto; import java.util.List; diff --git a/src/main/java/coffeemeet/server/user/service/UserService.java b/src/main/java/coffeemeet/server/user/service/UserService.java index 08e8717f..336c7b64 100644 --- a/src/main/java/coffeemeet/server/user/service/UserService.java +++ b/src/main/java/coffeemeet/server/user/service/UserService.java @@ -5,22 +5,22 @@ import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.certification.domain.Certification; -import coffeemeet.server.certification.service.cq.CertificationQuery; +import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.common.media.MediaManager; -import coffeemeet.server.interest.domain.Keyword; -import coffeemeet.server.interest.service.cq.InterestCommand; -import coffeemeet.server.interest.service.cq.InterestQuery; -import coffeemeet.server.oauth.service.OAuthService; +import coffeemeet.server.oauth.domain.OAuthMemberDetail; +import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; import coffeemeet.server.user.domain.Birth; import coffeemeet.server.user.domain.Email; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.domain.OAuthInfo; import coffeemeet.server.user.domain.OAuthProvider; import coffeemeet.server.user.domain.Profile; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.service.cq.UserCommand; -import coffeemeet.server.user.service.cq.UserQuery; +import coffeemeet.server.user.implement.InterestCommand; +import coffeemeet.server.user.implement.InterestQuery; +import coffeemeet.server.user.implement.UserCommand; +import coffeemeet.server.user.implement.UserQuery; import coffeemeet.server.user.service.dto.MyProfileDto; -import coffeemeet.server.user.service.dto.OAuthUserInfo; import coffeemeet.server.user.service.dto.UserProfileDto; import java.io.File; import java.util.List; @@ -35,7 +35,7 @@ public class UserService { private static final String DEFAULT_IMAGE_URL = "기본 이미지 URL"; private final MediaManager mediaManager; - private final OAuthService oAuthService; + private final OAuthMemberClientComposite oAuthMemberClientComposite; private final CertificationQuery certificationQuery; private final AuthTokensGenerator authTokensGenerator; @@ -47,19 +47,19 @@ public class UserService { public AuthTokens signup(String nickname, List keywords, String authCode, OAuthProvider oAuthProvider) { - OAuthUserInfo response = oAuthService.getOAuthUserInfo(oAuthProvider, + OAuthMemberDetail memberDetail = oAuthMemberClientComposite.fetch(oAuthProvider, authCode); - userQuery.hasDuplicatedUser(response.oAuthProvider(), response.oAuthProviderId()); + userQuery.hasDuplicatedUser(memberDetail.oAuthProvider(), memberDetail.oAuthProviderId()); userQuery.hasDuplicatedNickname(nickname); - String profileImage = getProfileImageOrDefault(response.profileImage()); + String profileImage = getProfileImageOrDefault(memberDetail.profileImage()); - User user = new User(new OAuthInfo(response.oAuthProvider(), - response.oAuthProviderId()), - Profile.builder().name(response.name()).nickname(nickname) - .email(new Email(response.email())) + User user = new User(new OAuthInfo(memberDetail.oAuthProvider(), + memberDetail.oAuthProviderId()), + Profile.builder().name(memberDetail.name()).nickname(nickname) + .email(new Email(memberDetail.email())) .profileImageUrl(profileImage) - .birth(new Birth(response.birthYear(), response.birthDay())).build()); + .birth(new Birth(memberDetail.birthYear(), memberDetail.birthDay())).build()); Long userId = userCommand.saveUser(user); User newUser = userQuery.getUserById(userId); @@ -69,8 +69,8 @@ public AuthTokens signup(String nickname, List keywords, String authCod } public AuthTokens login(OAuthProvider oAuthProvider, String authCode) { - OAuthUserInfo response = oAuthService.getOAuthUserInfo(oAuthProvider, authCode); - User user = userQuery.getUserByOAuthInfo(oAuthProvider, response.oAuthProviderId()); + OAuthMemberDetail memberDetail = oAuthMemberClientComposite.fetch(oAuthProvider, authCode); + User user = userQuery.getUserByOAuthInfo(oAuthProvider, memberDetail.oAuthProviderId()); return authTokensGenerator.generate(user.getId()); } diff --git a/src/main/java/coffeemeet/server/user/service/dto/MyProfileDto.java b/src/main/java/coffeemeet/server/user/service/dto/MyProfileDto.java index c6adc737..338429d8 100644 --- a/src/main/java/coffeemeet/server/user/service/dto/MyProfileDto.java +++ b/src/main/java/coffeemeet/server/user/service/dto/MyProfileDto.java @@ -1,7 +1,7 @@ package coffeemeet.server.user.service.dto; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.interest.domain.Keyword; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.domain.User; import java.time.LocalDateTime; import java.util.List; diff --git a/src/main/java/coffeemeet/server/user/service/dto/OAuthUserInfo.java b/src/main/java/coffeemeet/server/user/service/dto/OAuthUserInfo.java deleted file mode 100644 index cab73f1e..00000000 --- a/src/main/java/coffeemeet/server/user/service/dto/OAuthUserInfo.java +++ /dev/null @@ -1,28 +0,0 @@ -package coffeemeet.server.user.service.dto; - -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; -import coffeemeet.server.user.domain.OAuthProvider; - -public record OAuthUserInfo( - String name, - String profileImage, - String birthYear, - String birthDay, - String email, - OAuthProvider oAuthProvider, - String oAuthProviderId -) { - - public static OAuthUserInfo from(OAuthUserInfoDto.Response response) { - return new OAuthUserInfo( - response.name(), - response.profileImage(), - response.birthYear(), - response.birthDay(), - response.email(), - response.oAuthProvider(), - response.oAuthProviderId() - ); - } - -} diff --git a/src/main/java/coffeemeet/server/user/service/dto/UserProfileDto.java b/src/main/java/coffeemeet/server/user/service/dto/UserProfileDto.java index ea33be88..a8987074 100644 --- a/src/main/java/coffeemeet/server/user/service/dto/UserProfileDto.java +++ b/src/main/java/coffeemeet/server/user/service/dto/UserProfileDto.java @@ -1,7 +1,7 @@ package coffeemeet.server.user.service.dto; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.interest.domain.Keyword; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.domain.User; import java.util.List; diff --git a/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java b/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java index de8d44eb..5537d4dd 100644 --- a/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java +++ b/src/test/java/coffeemeet/server/auth/domain/AuthTokensGeneratorTest.java @@ -6,7 +6,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; -import coffeemeet.server.auth.service.cq.RefreshTokenCommand; +import coffeemeet.server.auth.implement.RefreshTokenCommand; import java.util.Date; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/auth/controller/AuthControllerTest.java b/src/test/java/coffeemeet/server/auth/presentation/AuthControllerTest.java similarity index 99% rename from src/test/java/coffeemeet/server/auth/controller/AuthControllerTest.java rename to src/test/java/coffeemeet/server/auth/presentation/AuthControllerTest.java index 9620969e..068636c4 100644 --- a/src/test/java/coffeemeet/server/auth/controller/AuthControllerTest.java +++ b/src/test/java/coffeemeet/server/auth/presentation/AuthControllerTest.java @@ -1,4 +1,4 @@ -package coffeemeet.server.auth.controller; +package coffeemeet.server.auth.presentation; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; diff --git a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java index 56569f81..d0c3908d 100644 --- a/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java +++ b/src/test/java/coffeemeet/server/auth/service/AuthServiceTest.java @@ -1,6 +1,7 @@ package coffeemeet.server.auth.service; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.BDDMockito.any; import static org.mockito.BDDMockito.anyLong; @@ -10,9 +11,10 @@ import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.auth.domain.JwtTokenProvider; -import coffeemeet.server.auth.service.cq.RefreshTokenCommand; +import coffeemeet.server.auth.implement.RefreshTokenCommand; import coffeemeet.server.common.fixture.dto.AuthTokensFixture; import coffeemeet.server.user.service.UserService; +import org.instancio.Instancio; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -65,27 +67,25 @@ void renewTest() { @Test void logoutTest() { // given + Long userId = Instancio.create(Long.class); willDoNothing().given(refreshTokenCommand).deleteRefreshToken(anyLong()); - // when - authService.logout((long) Math.random()); - - // then - assertThat(true).isTrue(); + // when, then + assertThatCode(() -> authService.logout(userId)) + .doesNotThrowAnyException(); } @DisplayName("회원 탈퇴 시킬 수 있다.") @Test void deleteTest() { // given + Long userId = Instancio.create(Long.class); willDoNothing().given(refreshTokenCommand).deleteRefreshToken(anyLong()); willDoNothing().given(userService).deleteUser(anyLong()); - // when - authService.delete((long) Math.random()); - - // then - assertThat(true).isTrue(); + // when, then + assertThatCode(() -> authService.delete(userId)) + .doesNotThrowAnyException(); } } diff --git a/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenCommandTest.java b/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenCommandTest.java index 2757861d..2d6c281e 100644 --- a/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenCommandTest.java +++ b/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenCommandTest.java @@ -6,7 +6,8 @@ import static org.mockito.Mockito.only; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.auth.repository.RefreshTokenRepository; +import coffeemeet.server.auth.implement.RefreshTokenCommand; +import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenQueryTest.java b/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenQueryTest.java index 7621ab61..57261cd6 100644 --- a/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenQueryTest.java +++ b/src/test/java/coffeemeet/server/auth/service/cq/RefreshTokenQueryTest.java @@ -4,7 +4,8 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.auth.repository.RefreshTokenRepository; +import coffeemeet.server.auth.implement.RefreshTokenQuery; +import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; import coffeemeet.server.common.fixture.dto.RefreshTokenFixture; import java.util.Optional; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/certification/repository/CertificationRepositoryTest.java b/src/test/java/coffeemeet/server/certification/infrastructure/CertificationRepositoryTest.java similarity index 93% rename from src/test/java/coffeemeet/server/certification/repository/CertificationRepositoryTest.java rename to src/test/java/coffeemeet/server/certification/infrastructure/CertificationRepositoryTest.java index ac0cc285..167f53c3 100644 --- a/src/test/java/coffeemeet/server/certification/repository/CertificationRepositoryTest.java +++ b/src/test/java/coffeemeet/server/certification/infrastructure/CertificationRepositoryTest.java @@ -1,4 +1,4 @@ -package coffeemeet.server.certification.repository; +package coffeemeet.server.certification.infrastructure; import static coffeemeet.server.common.fixture.entity.CertificationFixture.certification; import static coffeemeet.server.common.fixture.entity.UserFixture.user; @@ -6,7 +6,7 @@ import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.repository.UserRepository; +import coffeemeet.server.user.infrastructure.UserRepository; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java b/src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java similarity index 99% rename from src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java rename to src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java index 125e3b9e..e218bf94 100644 --- a/src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java +++ b/src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java @@ -1,4 +1,4 @@ -package coffeemeet.server.certification.controller; +package coffeemeet.server.certification.presentation; import static coffeemeet.server.common.fixture.dto.RefreshTokenFixture.refreshToken; import static coffeemeet.server.common.fixture.entity.CertificationFixture.department; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index bd9519c4..f64f85b0 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -15,14 +15,14 @@ import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.only; -import coffeemeet.server.certification.service.cq.CertificationCommand; -import coffeemeet.server.certification.service.cq.EmailVerificationCommand; -import coffeemeet.server.certification.service.cq.EmailVerificationQuery; +import coffeemeet.server.certification.implement.CertificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationQuery; import coffeemeet.server.common.media.EmailSender; import coffeemeet.server.common.media.MediaManager; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.service.cq.UserQuery; +import coffeemeet.server.user.implement.UserQuery; import java.io.File; import org.instancio.Instancio; import org.junit.jupiter.api.DisplayName; @@ -38,16 +38,22 @@ class CertificationServiceTest { @InjectMocks private CertificationService certificationService; + @Mock private MediaManager mediaManager; + @Mock private EmailSender emailSender; + @Mock private UserQuery userQuery; + @Mock private CertificationCommand certificationCommand; + @Mock private EmailVerificationCommand emailVerificationCommand; + @Mock private EmailVerificationQuery emailVerificationQuery; diff --git a/src/test/java/coffeemeet/server/certification/service/cq/CertificationCommandTest.java b/src/test/java/coffeemeet/server/certification/service/cq/CertificationCommandTest.java index d0cd9db2..352a2438 100644 --- a/src/test/java/coffeemeet/server/certification/service/cq/CertificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/service/cq/CertificationCommandTest.java @@ -14,7 +14,8 @@ import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; -import coffeemeet.server.certification.repository.CertificationRepository; +import coffeemeet.server.certification.implement.CertificationCommand; +import coffeemeet.server.certification.infrastructure.CertificationRepository; import coffeemeet.server.common.execption.InvalidInputException; import coffeemeet.server.user.domain.User; import java.util.Optional; diff --git a/src/test/java/coffeemeet/server/certification/service/cq/CertificationQueryTest.java b/src/test/java/coffeemeet/server/certification/service/cq/CertificationQueryTest.java index 7c6b1118..d2f57db3 100644 --- a/src/test/java/coffeemeet/server/certification/service/cq/CertificationQueryTest.java +++ b/src/test/java/coffeemeet/server/certification/service/cq/CertificationQueryTest.java @@ -6,7 +6,8 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.certification.domain.Certification; -import coffeemeet.server.certification.repository.CertificationRepository; +import coffeemeet.server.certification.implement.CertificationQuery; +import coffeemeet.server.certification.infrastructure.CertificationRepository; import coffeemeet.server.user.domain.User; import java.util.Optional; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationCommandTest.java b/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationCommandTest.java index 996bb8a4..52e96fd0 100644 --- a/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationCommandTest.java +++ b/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationCommandTest.java @@ -7,7 +7,8 @@ import static org.mockito.Mockito.only; import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.repository.EmailVerificationRepository; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationQueryTest.java b/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationQueryTest.java index 45a59355..edbac15d 100644 --- a/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationQueryTest.java +++ b/src/test/java/coffeemeet/server/certification/service/cq/EmailVerificationQueryTest.java @@ -5,7 +5,8 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.repository.EmailVerificationRepository; +import coffeemeet.server.certification.implement.EmailVerificationQuery; +import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; import java.util.Optional; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java b/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java index 56ea70d9..1d6a354c 100644 --- a/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java +++ b/src/test/java/coffeemeet/server/common/config/ControllerTestConfig.java @@ -4,7 +4,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import coffeemeet.server.auth.domain.JwtTokenProvider; -import coffeemeet.server.auth.service.cq.RefreshTokenQuery; +import coffeemeet.server.auth.implement.RefreshTokenQuery; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java index e28e0168..92c02541 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/KakaoMemberResponseFixture.java @@ -1,12 +1,12 @@ package coffeemeet.server.common.fixture.dto; -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberResponse; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; import org.instancio.Instancio; public class KakaoMemberResponseFixture { - public static KakaoMemberResponse kakaoMemberResponse() { - return Instancio.of(KakaoMemberResponse.class) + public static KakaoMemberDetail kakaoMemberResponse() { + return Instancio.of(KakaoMemberDetail.class) .create(); } diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java index 93c9ff50..37683f08 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/MyProfileDtoFixture.java @@ -2,7 +2,7 @@ import static org.instancio.Select.field; -import coffeemeet.server.interest.domain.Keyword; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.service.dto.MyProfileDto; import coffeemeet.server.user.service.dto.MyProfileDto.Response; import java.time.LocalDateTime; diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java index 12283c69..dee2c237 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/OAuthUserInfoDtoFixture.java @@ -2,13 +2,13 @@ import static org.instancio.Select.field; -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; +import coffeemeet.server.oauth.domain.OAuthMemberDetail; import org.instancio.Instancio; public class OAuthUserInfoDtoFixture { - public static OAuthUserInfoDto.Response response() { - return Instancio.of(OAuthUserInfoDto.Response.class) + public static OAuthMemberDetail response() { + return Instancio.of(OAuthMemberDetail.class) .generate(field("birthYear"), gen -> gen.ints().range(1000, 9999).asString()) .generate(field("birthDay"), gen -> gen.ints().range(1000, 9999).asString()) .set(field("email"), "test123@gmail.com") diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java index 49b7c288..e378ddf9 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java @@ -2,9 +2,9 @@ import static org.instancio.Select.field; -import coffeemeet.server.interest.domain.Keyword; -import coffeemeet.server.user.controller.dto.SignupHttpDto; -import coffeemeet.server.user.controller.dto.SignupHttpDto.Request; +import coffeemeet.server.user.domain.Keyword; +import coffeemeet.server.user.presentation.dto.SignupHttpDto; +import coffeemeet.server.user.presentation.dto.SignupHttpDto.Request; import java.util.List; import org.instancio.Instancio; diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java index a045adf8..361c8fe2 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java @@ -2,8 +2,8 @@ import static org.instancio.Select.field; -import coffeemeet.server.interest.domain.Keyword; -import coffeemeet.server.user.controller.dto.UpdateProfileHttpDto; +import coffeemeet.server.user.domain.Keyword; +import coffeemeet.server.user.presentation.dto.UpdateProfileHttpDto; import java.util.List; import org.instancio.Instancio; diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java index ee66d5ad..6417c3e4 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java @@ -2,12 +2,12 @@ import static org.instancio.Select.field; -import coffeemeet.server.certification.controller.dto.EmailDto; -import coffeemeet.server.certification.controller.dto.VerificationCodeDto; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; import coffeemeet.server.certification.domain.EmailVerification; +import coffeemeet.server.certification.presentation.dto.EmailDto; +import coffeemeet.server.certification.presentation.dto.VerificationCodeDto; import coffeemeet.server.user.domain.User; import org.instancio.Instancio; import org.instancio.internal.generator.domain.internet.EmailGenerator; diff --git a/src/test/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProviderCompositeTest.java b/src/test/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProviderCompositeTest.java index 86ca825b..2ef7e037 100644 --- a/src/test/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProviderCompositeTest.java +++ b/src/test/java/coffeemeet/server/oauth/authcode/AuthCodeRequestUrlProviderCompositeTest.java @@ -3,6 +3,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import coffeemeet.server.oauth.implement.provider.AuthCodeRequestUrlProvider; +import coffeemeet.server.oauth.implement.provider.AuthCodeRequestUrlProviderComposite; import coffeemeet.server.user.domain.OAuthProvider; import java.util.Collections; import java.util.HashSet; diff --git a/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java b/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java index 96952a18..26accbc0 100644 --- a/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java +++ b/src/test/java/coffeemeet/server/oauth/client/OAuthMemberClientCompositeTest.java @@ -4,7 +4,9 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture; -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; +import coffeemeet.server.oauth.domain.OAuthMemberDetail; +import coffeemeet.server.oauth.implement.client.OAuthMemberClient; +import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; import coffeemeet.server.user.domain.OAuthProvider; import java.util.Collections; import java.util.HashSet; @@ -34,7 +36,7 @@ void fetchTest() { // given String authCode = "authCode"; OAuthProvider oAuthProvider = OAuthProvider.KAKAO; - OAuthUserInfoDto.Response response = OAuthUserInfoDtoFixture.response(); + OAuthMemberDetail response = OAuthUserInfoDtoFixture.response(); given(client.oAuthProvider()).willReturn(OAuthProvider.KAKAO); given(client.fetch(authCode)).willReturn(response); @@ -43,7 +45,7 @@ void fetchTest() { composite = new OAuthMemberClientComposite(clients); // when - OAuthUserInfoDto.Response expectedResponse = composite.fetch(oAuthProvider, authCode); + OAuthMemberDetail expectedResponse = composite.fetch(oAuthProvider, authCode); // then assertThat(response).isEqualTo(expectedResponse); diff --git a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java index 2bdb2fd4..17795595 100644 --- a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java +++ b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java @@ -3,7 +3,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import coffeemeet.server.oauth.infrastructure.kakao.config.KakaoProperties; +import coffeemeet.server.oauth.config.kakao.KakaoProperties; +import coffeemeet.server.oauth.implement.provider.kakao.authcode.KakaoAuthCodeRequestUrlProvider; import coffeemeet.server.user.domain.OAuthProvider; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoApiClientTest.java b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoClientTest.java similarity index 83% rename from src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoApiClientTest.java rename to src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoClientTest.java index 50a774fe..09fd51bd 100644 --- a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoApiClientTest.java +++ b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoClientTest.java @@ -9,8 +9,9 @@ import coffeemeet.server.common.fixture.dto.KakaoMemberResponseFixture; import coffeemeet.server.common.fixture.dto.KakaoTokensFixture; -import coffeemeet.server.oauth.infrastructure.kakao.config.KakaoProperties; -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberResponse; +import coffeemeet.server.oauth.config.kakao.KakaoProperties; +import coffeemeet.server.oauth.infrastructure.kakao.KakaoClient; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -24,7 +25,7 @@ import org.springframework.web.client.RestTemplate; @ExtendWith(MockitoExtension.class) -class KakaoApiClientTest { +class KakaoClientTest { @Mock private RestTemplate restTemplate; @@ -33,7 +34,7 @@ class KakaoApiClientTest { private KakaoProperties kakaoProperties; @InjectMocks - private KakaoApiClient kakaoApiClient; + private KakaoClient kakaoClient; @DisplayName("카카오로부터 인증 토큰을 받을 수 있다.") @Test @@ -52,7 +53,7 @@ void fetchTokenTest() { .willReturn(kakaoTokens); // when - KakaoTokens expectedTokens = kakaoApiClient.fetchToken(authCode); + KakaoTokens expectedTokens = kakaoClient.fetchToken(authCode); // then assertAll( @@ -70,18 +71,18 @@ void fetchTokenTest() { @Test void fetchMemberTest() { // given - KakaoMemberResponse response = KakaoMemberResponseFixture.kakaoMemberResponse(); - ResponseEntity mockResponse = ResponseEntity.ok(response); + KakaoMemberDetail response = KakaoMemberResponseFixture.kakaoMemberResponse(); + ResponseEntity mockResponse = ResponseEntity.ok(response); given(restTemplate.exchange( anyString(), any(HttpMethod.class), any(HttpEntity.class), - eq(KakaoMemberResponse.class))) + eq(KakaoMemberDetail.class))) .willReturn(mockResponse); // when - KakaoMemberResponse result = kakaoApiClient.fetchMember("accessToken"); + KakaoMemberDetail result = kakaoClient.fetchMember("accessToken"); // then assertThat(result).isNotNull(); diff --git a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClientTest.java b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClientTest.java index a6ddf6d2..9ec615fd 100644 --- a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClientTest.java +++ b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/client/KakaoMemberClientTest.java @@ -6,7 +6,9 @@ import coffeemeet.server.common.fixture.dto.KakaoMemberResponseFixture; import coffeemeet.server.common.fixture.dto.KakaoTokensFixture; -import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberResponse; +import coffeemeet.server.oauth.implement.client.kakao.KakaoMemberClient; +import coffeemeet.server.oauth.infrastructure.kakao.KakaoClient; +import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoMemberDetail; import coffeemeet.server.oauth.infrastructure.kakao.dto.KakaoTokens; import coffeemeet.server.user.domain.OAuthProvider; import org.junit.jupiter.api.DisplayName; @@ -23,7 +25,7 @@ class KakaoMemberClientTest { KakaoMemberClient kakaoMemberClient; @Mock - KakaoApiClient kakaoApiClient; + KakaoClient kakaoClient; @DisplayName("카카오 프로바이더를 가져올 수 있다.") @Test @@ -38,10 +40,10 @@ void fetchTest() { // given String authCode = "authCode"; KakaoTokens kakaoTokens = KakaoTokensFixture.kakaoTokens(); - KakaoMemberResponse response = KakaoMemberResponseFixture.kakaoMemberResponse(); + KakaoMemberDetail response = KakaoMemberResponseFixture.kakaoMemberResponse(); - given(kakaoApiClient.fetchToken(any())).willReturn(kakaoTokens); - given(kakaoApiClient.fetchMember(any())).willReturn(response); + given(kakaoClient.fetchToken(any())).willReturn(kakaoTokens); + given(kakaoClient.fetchMember(any())).willReturn(response); // when, then assertThat(kakaoMemberClient.fetch(authCode)).isNotNull(); diff --git a/src/test/java/coffeemeet/server/oauth/controller/OAuthControllerTest.java b/src/test/java/coffeemeet/server/oauth/presentation/OAuthControllerTest.java similarity index 98% rename from src/test/java/coffeemeet/server/oauth/controller/OAuthControllerTest.java rename to src/test/java/coffeemeet/server/oauth/presentation/OAuthControllerTest.java index ef1b7980..efae7862 100644 --- a/src/test/java/coffeemeet/server/oauth/controller/OAuthControllerTest.java +++ b/src/test/java/coffeemeet/server/oauth/presentation/OAuthControllerTest.java @@ -1,4 +1,4 @@ -package coffeemeet.server.oauth.controller; +package coffeemeet.server.oauth.presentation; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.resourceDetails; diff --git a/src/test/java/coffeemeet/server/oauth/service/OAuthServiceTest.java b/src/test/java/coffeemeet/server/oauth/service/OAuthServiceTest.java index df142e28..fcf87897 100644 --- a/src/test/java/coffeemeet/server/oauth/service/OAuthServiceTest.java +++ b/src/test/java/coffeemeet/server/oauth/service/OAuthServiceTest.java @@ -3,12 +3,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; -import coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture; -import coffeemeet.server.oauth.authcode.AuthCodeRequestUrlProviderComposite; -import coffeemeet.server.oauth.client.OAuthMemberClientComposite; -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; +import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; +import coffeemeet.server.oauth.implement.provider.AuthCodeRequestUrlProviderComposite; import coffeemeet.server.user.domain.OAuthProvider; -import coffeemeet.server.user.service.dto.OAuthUserInfo; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -43,19 +40,4 @@ void getAuthCodeRequestUrlTest() { assertThat(result).isEqualTo(expectedUrl); } - @DisplayName("로그인 타입에 맞는 redirect url 을 생성할 수 있다.") - @Test - void getOAuthInfoTest() { - // given - OAuthProvider oAuthProvider = OAuthProvider.KAKAO; - String authCode = "authCode"; - OAuthUserInfoDto.Response oAuthInfoResponse = OAuthUserInfoDtoFixture.response(); - OAuthUserInfo userInfo = OAuthUserInfo.from(oAuthInfoResponse); - - given(oAuthMemberClientComposite.fetch(oAuthProvider, authCode)).willReturn(oAuthInfoResponse); - - // when, then - assertThat(oAuthService.getOAuthUserInfo(oAuthProvider, authCode)).isEqualTo(userInfo); - } - } diff --git a/src/test/java/coffeemeet/server/user/controller/UserControllerTest.java b/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java similarity index 98% rename from src/test/java/coffeemeet/server/user/controller/UserControllerTest.java rename to src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java index 61263245..7f3e6438 100644 --- a/src/test/java/coffeemeet/server/user/controller/UserControllerTest.java +++ b/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java @@ -1,4 +1,4 @@ -package coffeemeet.server.user.controller; +package coffeemeet.server.user.presentation; import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document; @@ -35,10 +35,10 @@ import coffeemeet.server.common.fixture.dto.SignupDtoFixture; import coffeemeet.server.common.fixture.dto.UpdateProfileDtoFixture; import coffeemeet.server.common.fixture.dto.UserProfileDtoFixture; -import coffeemeet.server.user.controller.dto.SignupHttpDto; -import coffeemeet.server.user.controller.dto.UpdateProfileHttpDto.Request; import coffeemeet.server.user.domain.OAuthProvider; import coffeemeet.server.user.domain.User; +import coffeemeet.server.user.presentation.dto.SignupHttpDto; +import coffeemeet.server.user.presentation.dto.UpdateProfileHttpDto.Request; import coffeemeet.server.user.service.UserService; import coffeemeet.server.user.service.dto.MyProfileDto.Response; import coffeemeet.server.user.service.dto.UserProfileDto; diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index d4d4a4b7..bfd232b6 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -3,9 +3,10 @@ import static coffeemeet.server.certification.domain.Department.IT; import static coffeemeet.server.common.fixture.entity.UserFixture.user; import static coffeemeet.server.common.media.KeyType.PROFILE_IMAGE; -import static coffeemeet.server.interest.domain.Keyword.COOK; -import static coffeemeet.server.interest.domain.Keyword.GAME; +import static coffeemeet.server.user.domain.Keyword.COOK; +import static coffeemeet.server.user.domain.Keyword.GAME; import static coffeemeet.server.user.domain.OAuthProvider.KAKAO; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import static org.mockito.ArgumentMatchers.any; @@ -20,27 +21,26 @@ import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.domain.CompanyEmail; -import coffeemeet.server.certification.service.cq.CertificationQuery; +import coffeemeet.server.certification.implement.CertificationQuery; import coffeemeet.server.common.fixture.dto.AuthTokensFixture; import coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture; import coffeemeet.server.common.fixture.dto.SignupDtoFixture; import coffeemeet.server.common.fixture.entity.CertificationFixture; import coffeemeet.server.common.media.MediaManager; -import coffeemeet.server.interest.domain.Keyword; -import coffeemeet.server.interest.service.cq.InterestCommand; -import coffeemeet.server.interest.service.cq.InterestQuery; -import coffeemeet.server.oauth.dto.OAuthUserInfoDto; -import coffeemeet.server.oauth.service.OAuthService; -import coffeemeet.server.user.controller.dto.SignupHttpDto.Request; +import coffeemeet.server.oauth.domain.OAuthMemberDetail; +import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; import coffeemeet.server.user.domain.Birth; import coffeemeet.server.user.domain.Email; +import coffeemeet.server.user.domain.Keyword; import coffeemeet.server.user.domain.OAuthInfo; import coffeemeet.server.user.domain.Profile; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.service.cq.UserCommand; -import coffeemeet.server.user.service.cq.UserQuery; +import coffeemeet.server.user.implement.InterestCommand; +import coffeemeet.server.user.implement.InterestQuery; +import coffeemeet.server.user.implement.UserCommand; +import coffeemeet.server.user.implement.UserQuery; +import coffeemeet.server.user.presentation.dto.SignupHttpDto.Request; import coffeemeet.server.user.service.dto.MyProfileDto; -import coffeemeet.server.user.service.dto.OAuthUserInfo; import coffeemeet.server.user.service.dto.UserProfileDto.Response; import java.io.File; import java.io.IOException; @@ -65,7 +65,7 @@ class UserServiceTest { private MediaManager mediaManager; @Mock - private OAuthService oAuthService; + private OAuthMemberClientComposite oAuthMemberClientComposite; @Mock private AuthTokensGenerator authTokensGenerator; @@ -91,11 +91,10 @@ void signupTest() { // given Request request = SignupDtoFixture.signupDto(); AuthTokens authTokens = AuthTokensFixture.authTokens(); - OAuthUserInfoDto.Response response = OAuthUserInfoDtoFixture.response(); - OAuthUserInfo userInfo = OAuthUserInfo.from(response); + OAuthMemberDetail response = OAuthUserInfoDtoFixture.response(); User user = user(); - given(oAuthService.getOAuthUserInfo(any(), any())).willReturn(userInfo); + given(oAuthMemberClientComposite.fetch(any(), any())).willReturn(response); given(userCommand.saveUser(any(User.class))).willReturn(user.getId()); given(userQuery.getUserById(user.getId())).willReturn(user); willDoNothing().given(interestCommand).saveAll(any(), any()); @@ -118,10 +117,9 @@ void loginTest() { String authCode = "authCode"; AuthTokens authTokens = AuthTokensFixture.authTokens(); - OAuthUserInfoDto.Response response = OAuthUserInfoDtoFixture.response(); - OAuthUserInfo userInfo = OAuthUserInfo.from(response); + OAuthMemberDetail response = OAuthUserInfoDtoFixture.response(); - given(oAuthService.getOAuthUserInfo(any(), any())).willReturn(userInfo); + given(oAuthMemberClientComposite.fetch(any(), any())).willReturn(response); given(userQuery.getUserByOAuthInfo(any(), any())).willReturn(user); given(authTokensGenerator.generate(anyLong())).willReturn(authTokens); @@ -270,11 +268,9 @@ void deleteUser() { willDoNothing().given(userCommand).deleteUser(user.getId()); - // when - userService.deleteUser(user.getId()); - - // then - assertThat(true).isTrue(); + // when, then + assertThatCode(() -> userService.deleteUser(user.getId())) + .doesNotThrowAnyException(); } @DisplayName("닉네임 중복을 검사할 수 있다.") @@ -286,11 +282,9 @@ void checkDuplicatedNickname() { willDoNothing().given(userQuery).hasDuplicatedNickname(nickname); - // when - userService.checkDuplicatedNickname(nickname); - // then - assertThat(true).isTrue(); + assertThatCode(() -> userService.checkDuplicatedNickname(nickname)) + .doesNotThrowAnyException(); } } From c64cc7469f0666d12c1cc4a48792bd93211eb896 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 18:53:57 +0900 Subject: [PATCH 08/11] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=20=EC=A0=95=EB=A6=AC=20=EB=B0=8F=20dto=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/implement/RefreshTokenCommand.java | 24 ++++++++++ .../auth/implement/RefreshTokenQuery.java | 28 +++++++++++ .../implement/CertificationCommand.java | 48 +++++++++++++++++++ .../implement/CertificationQuery.java | 27 +++++++++++ .../implement/EmailVerificationCommand.java | 20 ++++++++ .../implement/EmailVerificationQuery.java | 27 +++++++++++ 6 files changed, 174 insertions(+) create mode 100644 src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java create mode 100644 src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java create mode 100644 src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java diff --git a/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java new file mode 100644 index 00000000..734e8774 --- /dev/null +++ b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java @@ -0,0 +1,24 @@ +package coffeemeet.server.auth.implement; + +import coffeemeet.server.auth.domain.RefreshToken; +import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +@RequiredArgsConstructor +public class RefreshTokenCommand { + + private final RefreshTokenRepository refreshTokenRepository; + + public void createRefreshToken(RefreshToken refreshToken) { + refreshTokenRepository.save(refreshToken); + } + + public void deleteRefreshToken(Long userId) { + refreshTokenRepository.deleteById(userId); + } + +} diff --git a/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java new file mode 100644 index 00000000..b52421ae --- /dev/null +++ b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java @@ -0,0 +1,28 @@ +package coffeemeet.server.auth.implement; + +import static coffeemeet.server.auth.exception.AuthErrorCode.AUTHENTICATION_FAILED; + +import coffeemeet.server.auth.domain.RefreshToken; +import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; +import coffeemeet.server.common.execption.InvalidInputException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class RefreshTokenQuery { + + private static final String USER_AUTHENTICATION_FAILED_MESSAGE = "사용자(%s)의 재인증(로그인)이 필요합니다."; + + private final RefreshTokenRepository refreshTokenRepository; + + public RefreshToken getRefreshToken(Long userId) { + return refreshTokenRepository.findById(userId) + .orElseThrow(() -> new InvalidInputException( + AUTHENTICATION_FAILED, + String.format(USER_AUTHENTICATION_FAILED_MESSAGE, userId))); + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java new file mode 100644 index 00000000..cf254580 --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java @@ -0,0 +1,48 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.certification.exception.CertificationErrorCode.EXISTED_COMPANY_EMAIL; + +import coffeemeet.server.certification.domain.Certification; +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.certification.domain.Department; +import coffeemeet.server.certification.infrastructure.CertificationRepository; +import coffeemeet.server.common.execption.InvalidInputException; +import coffeemeet.server.user.domain.User; +import java.util.function.Consumer; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +@RequiredArgsConstructor +public class CertificationCommand { + + private static final String EXISTED_COMPANY_EMAIL_MESSAGE = "이미 사용 중인 회사 이메일(%s) 입니다."; + + private final CertificationRepository certificationRepository; + + public void createCertification(CompanyEmail companyEmail, String businessCardUrl, + Department department, User user) { + certificationRepository.save( + Certification.builder() + .companyEmail(companyEmail) + .businessCardUrl(businessCardUrl) + .department(department) + .user(user) + .build() + ); + } + + public void hasDuplicatedCompanyEmail(CompanyEmail companyEmail) { + if (certificationRepository.existsByCompanyEmail(companyEmail)) { + throw new InvalidInputException(EXISTED_COMPANY_EMAIL, + String.format(EXISTED_COMPANY_EMAIL_MESSAGE, companyEmail.getValue())); + } + } + + public void applyIfCertifiedUser(Long userId, Consumer consumer) { + certificationRepository.findByUserId(userId).ifPresent(consumer); + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java new file mode 100644 index 00000000..2e7bda1b --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java @@ -0,0 +1,27 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.certification.exception.CertificationErrorCode.CERTIFICATION_NOT_FOUND; + +import coffeemeet.server.certification.domain.Certification; +import coffeemeet.server.certification.infrastructure.CertificationRepository; +import coffeemeet.server.common.execption.InvalidInputException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class CertificationQuery { + + private static final String CERTIFICATION_NOT_FOUND_MESSAGE = "해당 사용자(%s)의 인증정보를 찾을 수 없습니다."; + + private final CertificationRepository certificationRepository; + + public Certification getCertificationByUserId(Long userId) { + return certificationRepository.findByUserId(userId) + .orElseThrow(() -> new InvalidInputException(CERTIFICATION_NOT_FOUND, + String.format(CERTIFICATION_NOT_FOUND_MESSAGE, userId))); + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java new file mode 100644 index 00000000..32fed5fc --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java @@ -0,0 +1,20 @@ +package coffeemeet.server.certification.implement; + +import coffeemeet.server.certification.domain.CompanyEmail; +import coffeemeet.server.certification.domain.EmailVerification; +import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class EmailVerificationCommand { + + private final EmailVerificationRepository emailVerificationRepository; + + public void createEmailVerification(Long userId, CompanyEmail companyEmail, + String verificationCode) { + emailVerificationRepository.save(new EmailVerification(userId, companyEmail, verificationCode)); + } + +} diff --git a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java new file mode 100644 index 00000000..abd86ee4 --- /dev/null +++ b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java @@ -0,0 +1,27 @@ +package coffeemeet.server.certification.implement; + +import static coffeemeet.server.certification.exception.CertificationErrorCode.VERIFICATION_CODE_NOT_FOUND; + +import coffeemeet.server.certification.domain.EmailVerification; +import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; +import coffeemeet.server.common.execption.InvalidInputException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class EmailVerificationQuery { + + private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증코드를 요청한 기록이 없습니다."; + + private final EmailVerificationRepository emailVerificationRepository; + + public String getCodeById(Long userId) { + EmailVerification emailVerification = emailVerificationRepository.findById(userId) + .orElseThrow(() -> new InvalidInputException( + VERIFICATION_CODE_NOT_FOUND, + String.format(VERIFICATION_CODE_NOT_FOUND_MESSAGE, userId))); + return emailVerification.getCode(); + } + +} From efeb37d3a15fb2b33615694b21c506deb0ceab5c Mon Sep 17 00:00:00 2001 From: sangminnim Date: Thu, 2 Nov 2023 22:01:36 +0900 Subject: [PATCH 09/11] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coffeemeet/server/auth/presentation/AuthController.java | 2 +- .../certification/presentation/CertificationController.java | 2 +- .../server/certification/service/CertificationService.java | 6 +++--- .../java/coffeemeet/server/common/config/AuthWebConfig.java | 2 +- .../server/common/{media => implement}/EmailSender.java | 2 +- .../server/common/{media => implement}/KeyType.java | 2 +- .../server/common/{media => implement}/MediaManager.java | 2 +- .../server/common/{media => implement}/S3MediaManager.java | 2 +- .../common/{ => presentation}/advice/ErrorResponse.java | 2 +- .../{ => presentation}/advice/GlobalExceptionHandler.java | 2 +- .../server/common/{ => presentation}/annotation/Login.java | 2 +- .../{ => presentation}/resolver/UserArgumentResolver.java | 4 ++-- .../coffeemeet/server/user/presentation/UserController.java | 2 +- .../java/coffeemeet/server/user/service/UserService.java | 4 ++-- .../certification/service/CertificationServiceTest.java | 4 ++-- .../server/common/{media => implement}/EmailSenderTest.java | 5 +++-- .../common/{media => implement}/S3MediaManagerTest.java | 2 +- .../coffeemeet/server/user/service/UserServiceTest.java | 4 ++-- 18 files changed, 26 insertions(+), 25 deletions(-) rename src/main/java/coffeemeet/server/common/{media => implement}/EmailSender.java (96%) rename src/main/java/coffeemeet/server/common/{media => implement}/KeyType.java (82%) rename src/main/java/coffeemeet/server/common/{media => implement}/MediaManager.java (84%) rename src/main/java/coffeemeet/server/common/{media => implement}/S3MediaManager.java (97%) rename src/main/java/coffeemeet/server/common/{ => presentation}/advice/ErrorResponse.java (98%) rename src/main/java/coffeemeet/server/common/{ => presentation}/advice/GlobalExceptionHandler.java (98%) rename src/main/java/coffeemeet/server/common/{ => presentation}/annotation/Login.java (81%) rename src/main/java/coffeemeet/server/common/{ => presentation}/resolver/UserArgumentResolver.java (94%) rename src/test/java/coffeemeet/server/common/{media => implement}/EmailSenderTest.java (91%) rename src/test/java/coffeemeet/server/common/{media => implement}/S3MediaManagerTest.java (98%) diff --git a/src/main/java/coffeemeet/server/auth/presentation/AuthController.java b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java index cdcbb1b5..686e60c6 100644 --- a/src/main/java/coffeemeet/server/auth/presentation/AuthController.java +++ b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java @@ -2,7 +2,7 @@ import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.service.AuthService; -import coffeemeet.server.common.annotation.Login; +import coffeemeet.server.common.presentation.annotation.Login; import coffeemeet.server.user.presentation.dto.AuthInfo; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java index 7d843ff9..fb8c0535 100644 --- a/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java +++ b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java @@ -3,7 +3,7 @@ import coffeemeet.server.certification.presentation.dto.EmailDto; import coffeemeet.server.certification.presentation.dto.VerificationCodeDto; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.common.annotation.Login; +import coffeemeet.server.common.presentation.annotation.Login; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.validation.Valid; diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index f69f185a..9178ad3f 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -1,7 +1,7 @@ package coffeemeet.server.certification.service; import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE; -import static coffeemeet.server.common.media.KeyType.BUSINESS_CARD; +import static coffeemeet.server.common.implement.KeyType.BUSINESS_CARD; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; @@ -9,8 +9,8 @@ import coffeemeet.server.certification.implement.EmailVerificationCommand; import coffeemeet.server.certification.implement.EmailVerificationQuery; import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.common.media.EmailSender; -import coffeemeet.server.common.media.MediaManager; +import coffeemeet.server.common.implement.EmailSender; +import coffeemeet.server.common.implement.MediaManager; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; diff --git a/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java b/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java index c126facb..bae4b878 100644 --- a/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java +++ b/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java @@ -2,7 +2,7 @@ import coffeemeet.server.auth.domain.JwtTokenProvider; import coffeemeet.server.auth.implement.RefreshTokenQuery; -import coffeemeet.server.common.resolver.UserArgumentResolver; +import coffeemeet.server.common.presentation.resolver.UserArgumentResolver; import coffeemeet.server.oauth.utils.converter.OAuthProviderConverter; import java.util.List; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/coffeemeet/server/common/media/EmailSender.java b/src/main/java/coffeemeet/server/common/implement/EmailSender.java similarity index 96% rename from src/main/java/coffeemeet/server/common/media/EmailSender.java rename to src/main/java/coffeemeet/server/common/implement/EmailSender.java index 75fa87e0..6d6834ad 100644 --- a/src/main/java/coffeemeet/server/common/media/EmailSender.java +++ b/src/main/java/coffeemeet/server/common/implement/EmailSender.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; import coffeemeet.server.certification.domain.CompanyEmail; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/coffeemeet/server/common/media/KeyType.java b/src/main/java/coffeemeet/server/common/implement/KeyType.java similarity index 82% rename from src/main/java/coffeemeet/server/common/media/KeyType.java rename to src/main/java/coffeemeet/server/common/implement/KeyType.java index 3aaa7615..be8a35c8 100644 --- a/src/main/java/coffeemeet/server/common/media/KeyType.java +++ b/src/main/java/coffeemeet/server/common/implement/KeyType.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; import lombok.Getter; diff --git a/src/main/java/coffeemeet/server/common/media/MediaManager.java b/src/main/java/coffeemeet/server/common/implement/MediaManager.java similarity index 84% rename from src/main/java/coffeemeet/server/common/media/MediaManager.java rename to src/main/java/coffeemeet/server/common/implement/MediaManager.java index 4f94f9b5..4744f772 100644 --- a/src/main/java/coffeemeet/server/common/media/MediaManager.java +++ b/src/main/java/coffeemeet/server/common/implement/MediaManager.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; import java.io.File; diff --git a/src/main/java/coffeemeet/server/common/media/S3MediaManager.java b/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java similarity index 97% rename from src/main/java/coffeemeet/server/common/media/S3MediaManager.java rename to src/main/java/coffeemeet/server/common/implement/S3MediaManager.java index f0bc5d5d..ae61cf4b 100644 --- a/src/main/java/coffeemeet/server/common/media/S3MediaManager.java +++ b/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; import static coffeemeet.server.common.execption.GlobalErrorCode.INVALID_S3_URL; diff --git a/src/main/java/coffeemeet/server/common/advice/ErrorResponse.java b/src/main/java/coffeemeet/server/common/presentation/advice/ErrorResponse.java similarity index 98% rename from src/main/java/coffeemeet/server/common/advice/ErrorResponse.java rename to src/main/java/coffeemeet/server/common/presentation/advice/ErrorResponse.java index 6981dd9a..ca3a39f2 100644 --- a/src/main/java/coffeemeet/server/common/advice/ErrorResponse.java +++ b/src/main/java/coffeemeet/server/common/presentation/advice/ErrorResponse.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.advice; +package coffeemeet.server.common.presentation.advice; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; diff --git a/src/main/java/coffeemeet/server/common/advice/GlobalExceptionHandler.java b/src/main/java/coffeemeet/server/common/presentation/advice/GlobalExceptionHandler.java similarity index 98% rename from src/main/java/coffeemeet/server/common/advice/GlobalExceptionHandler.java rename to src/main/java/coffeemeet/server/common/presentation/advice/GlobalExceptionHandler.java index e7e3bb19..a9af6077 100644 --- a/src/main/java/coffeemeet/server/common/advice/GlobalExceptionHandler.java +++ b/src/main/java/coffeemeet/server/common/presentation/advice/GlobalExceptionHandler.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.advice; +package coffeemeet.server.common.presentation.advice; import coffeemeet.server.common.execption.DataLengthExceededException; import coffeemeet.server.common.execption.GlobalErrorCode; diff --git a/src/main/java/coffeemeet/server/common/annotation/Login.java b/src/main/java/coffeemeet/server/common/presentation/annotation/Login.java similarity index 81% rename from src/main/java/coffeemeet/server/common/annotation/Login.java rename to src/main/java/coffeemeet/server/common/presentation/annotation/Login.java index 7acf35b2..62e6bce3 100644 --- a/src/main/java/coffeemeet/server/common/annotation/Login.java +++ b/src/main/java/coffeemeet/server/common/presentation/annotation/Login.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.annotation; +package coffeemeet.server.common.presentation.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/coffeemeet/server/common/resolver/UserArgumentResolver.java b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java similarity index 94% rename from src/main/java/coffeemeet/server/common/resolver/UserArgumentResolver.java rename to src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java index 73acb2cd..a2d8f679 100644 --- a/src/main/java/coffeemeet/server/common/resolver/UserArgumentResolver.java +++ b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java @@ -1,11 +1,11 @@ -package coffeemeet.server.common.resolver; +package coffeemeet.server.common.presentation.resolver; import static coffeemeet.server.auth.exception.AuthErrorCode.AUTHENTICATION_FAILED; import coffeemeet.server.auth.domain.JwtTokenProvider; import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.auth.implement.RefreshTokenQuery; -import coffeemeet.server.common.annotation.Login; +import coffeemeet.server.common.presentation.annotation.Login; import coffeemeet.server.common.execption.InvalidInputException; import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.servlet.http.HttpServletRequest; diff --git a/src/main/java/coffeemeet/server/user/presentation/UserController.java b/src/main/java/coffeemeet/server/user/presentation/UserController.java index b3bfc342..f3fc7058 100644 --- a/src/main/java/coffeemeet/server/user/presentation/UserController.java +++ b/src/main/java/coffeemeet/server/user/presentation/UserController.java @@ -1,7 +1,7 @@ package coffeemeet.server.user.presentation; import coffeemeet.server.auth.domain.AuthTokens; -import coffeemeet.server.common.annotation.Login; +import coffeemeet.server.common.presentation.annotation.Login; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.OAuthProvider; import coffeemeet.server.user.presentation.dto.AuthInfo; diff --git a/src/main/java/coffeemeet/server/user/service/UserService.java b/src/main/java/coffeemeet/server/user/service/UserService.java index 336c7b64..18e80d84 100644 --- a/src/main/java/coffeemeet/server/user/service/UserService.java +++ b/src/main/java/coffeemeet/server/user/service/UserService.java @@ -1,12 +1,12 @@ package coffeemeet.server.user.service; -import static coffeemeet.server.common.media.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.implement.KeyType.PROFILE_IMAGE; import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.domain.AuthTokensGenerator; import coffeemeet.server.certification.domain.Certification; import coffeemeet.server.certification.implement.CertificationQuery; -import coffeemeet.server.common.media.MediaManager; +import coffeemeet.server.common.implement.MediaManager; import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; import coffeemeet.server.user.domain.Birth; diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index f64f85b0..0010e90e 100644 --- a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java +++ b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java @@ -18,8 +18,8 @@ import coffeemeet.server.certification.implement.CertificationCommand; import coffeemeet.server.certification.implement.EmailVerificationCommand; import coffeemeet.server.certification.implement.EmailVerificationQuery; -import coffeemeet.server.common.media.EmailSender; -import coffeemeet.server.common.media.MediaManager; +import coffeemeet.server.common.implement.EmailSender; +import coffeemeet.server.common.implement.MediaManager; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; diff --git a/src/test/java/coffeemeet/server/common/media/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java similarity index 91% rename from src/test/java/coffeemeet/server/common/media/EmailSenderTest.java rename to src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index 93ee4ef1..00bf24c8 100644 --- a/src/test/java/coffeemeet/server/common/media/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; import static coffeemeet.server.common.fixture.entity.CertificationFixture.companyEmail; import static coffeemeet.server.common.fixture.entity.CertificationFixture.email; @@ -9,6 +9,7 @@ import static org.mockito.Mockito.only; import coffeemeet.server.certification.domain.CompanyEmail; +import java.util.Objects; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -55,7 +56,7 @@ void sendVerificationCodeTest() { SimpleMailMessage sentMailMessage = simpleMailMessage.getValue(); assertAll( () -> assertThat(sentMailMessage.getFrom()).isEqualTo(sender), - () -> assertThat(sentMailMessage.getTo()[0]).isEqualTo(companyEmail.getValue()), + () -> assertThat(Objects.requireNonNull(sentMailMessage.getTo())[0]).isEqualTo(companyEmail.getValue()), () -> assertThat(sentMailMessage.getText()).contains(verificationCode) ); } diff --git a/src/test/java/coffeemeet/server/common/media/S3MediaManagerTest.java b/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java similarity index 98% rename from src/test/java/coffeemeet/server/common/media/S3MediaManagerTest.java rename to src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java index d0c2c713..1a8462bf 100644 --- a/src/test/java/coffeemeet/server/common/media/S3MediaManagerTest.java +++ b/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index bfd232b6..7194efaa 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -2,7 +2,7 @@ import static coffeemeet.server.certification.domain.Department.IT; import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.media.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.implement.KeyType.PROFILE_IMAGE; import static coffeemeet.server.user.domain.Keyword.COOK; import static coffeemeet.server.user.domain.Keyword.GAME; import static coffeemeet.server.user.domain.OAuthProvider.KAKAO; @@ -26,7 +26,7 @@ import coffeemeet.server.common.fixture.dto.OAuthUserInfoDtoFixture; import coffeemeet.server.common.fixture.dto.SignupDtoFixture; import coffeemeet.server.common.fixture.entity.CertificationFixture; -import coffeemeet.server.common.media.MediaManager; +import coffeemeet.server.common.implement.MediaManager; import coffeemeet.server.oauth.domain.OAuthMemberDetail; import coffeemeet.server.oauth.implement.client.OAuthMemberClientComposite; import coffeemeet.server.user.domain.Birth; From 1074a47d688bed4e8e0e90bada4a4fb2e64a5f77 Mon Sep 17 00:00:00 2001 From: sangminnim Date: Fri, 3 Nov 2023 00:31:58 +0900 Subject: [PATCH 10/11] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coffeemeet/server/auth/presentation/AuthController.java | 2 +- .../certification/presentation/CertificationController.java | 2 +- .../server/common/{presentation => }/annotation/Login.java | 2 +- .../common/presentation/resolver/UserArgumentResolver.java | 2 +- .../coffeemeet/server/user/presentation/UserController.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/coffeemeet/server/common/{presentation => }/annotation/Login.java (81%) diff --git a/src/main/java/coffeemeet/server/auth/presentation/AuthController.java b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java index 686e60c6..cdcbb1b5 100644 --- a/src/main/java/coffeemeet/server/auth/presentation/AuthController.java +++ b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java @@ -2,7 +2,7 @@ import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.service.AuthService; -import coffeemeet.server.common.presentation.annotation.Login; +import coffeemeet.server.common.annotation.Login; import coffeemeet.server.user.presentation.dto.AuthInfo; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java index fb8c0535..7d843ff9 100644 --- a/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java +++ b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java @@ -3,7 +3,7 @@ import coffeemeet.server.certification.presentation.dto.EmailDto; import coffeemeet.server.certification.presentation.dto.VerificationCodeDto; import coffeemeet.server.certification.service.CertificationService; -import coffeemeet.server.common.presentation.annotation.Login; +import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.validation.Valid; diff --git a/src/main/java/coffeemeet/server/common/presentation/annotation/Login.java b/src/main/java/coffeemeet/server/common/annotation/Login.java similarity index 81% rename from src/main/java/coffeemeet/server/common/presentation/annotation/Login.java rename to src/main/java/coffeemeet/server/common/annotation/Login.java index 62e6bce3..7acf35b2 100644 --- a/src/main/java/coffeemeet/server/common/presentation/annotation/Login.java +++ b/src/main/java/coffeemeet/server/common/annotation/Login.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.presentation.annotation; +package coffeemeet.server.common.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java index a2d8f679..5df96d83 100644 --- a/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java +++ b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java @@ -5,7 +5,7 @@ import coffeemeet.server.auth.domain.JwtTokenProvider; import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.auth.implement.RefreshTokenQuery; -import coffeemeet.server.common.presentation.annotation.Login; +import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.execption.InvalidInputException; import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.servlet.http.HttpServletRequest; diff --git a/src/main/java/coffeemeet/server/user/presentation/UserController.java b/src/main/java/coffeemeet/server/user/presentation/UserController.java index f3fc7058..b3bfc342 100644 --- a/src/main/java/coffeemeet/server/user/presentation/UserController.java +++ b/src/main/java/coffeemeet/server/user/presentation/UserController.java @@ -1,7 +1,7 @@ package coffeemeet.server.user.presentation; import coffeemeet.server.auth.domain.AuthTokens; -import coffeemeet.server.common.presentation.annotation.Login; +import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.OAuthProvider; import coffeemeet.server.user.presentation.dto.AuthInfo; From 91fec77ef5f175f2764245c27ea76f6e3df74b2b Mon Sep 17 00:00:00 2001 From: yumyeonghan Date: Fri, 3 Nov 2023 01:06:48 +0900 Subject: [PATCH 11/11] =?UTF-8?q?style:=20=ED=8C=A8=ED=82=A4=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coffeemeet/server/admin/domain/Admin.java | 2 +- .../auth/implement/RefreshTokenCommand.java | 4 ++-- .../auth/implement/RefreshTokenQuery.java | 4 ++-- .../auth/presentation/AuthController.java | 2 +- .../certification/domain/Certification.java | 2 +- .../implement/CertificationCommand.java | 4 ++-- .../implement/CertificationQuery.java | 4 ++-- .../implement/EmailVerificationCommand.java | 4 ++-- .../implement/EmailVerificationQuery.java | 4 ++-- .../presentation/CertificationController.java | 10 ++++----- .../dto/{EmailDto.java => EmailHTTP.java} | 4 ++-- ...CodeDto.java => VerificationCodeHTTP.java} | 4 ++-- .../service/CertificationService.java | 2 +- .../message/domain/ChattingMessage.java | 2 +- .../chatting/message/domain/ChattingRoom.java | 2 +- .../room/domain/ChattingMessageHistory.java | 2 +- .../room/domain/ChattingRoomHistory.java | 2 +- .../room/domain/UserChattingHistory.java | 2 +- .../AdvancedBaseEntity.java | 2 +- .../dto => common/domain}/AuthInfo.java | 2 +- .../common/{entity => domain}/BaseEntity.java | 2 +- .../common/{implement => domain}/KeyType.java | 2 +- .../server/common/implement/EmailSender.java | 4 ++-- .../server/common/implement/MediaManager.java | 1 + .../common/implement/S3MediaManager.java | 5 +++-- .../resolver/UserArgumentResolver.java | 2 +- .../server/inquiry/domain/Inquiry.java | 2 +- .../KakaoAuthCodeRequestUrlProvider.java | 2 +- .../server/report/domain/Report.java | 2 +- .../server/user/domain/Interest.java | 2 +- .../coffeemeet/server/user/domain/User.java | 2 +- .../user/implement/InterestCommand.java | 4 ++-- .../server/user/implement/InterestQuery.java | 4 ++-- .../server/user/implement/UserCommand.java | 4 ++-- .../server/user/implement/UserQuery.java | 4 ++-- .../user/presentation/UserController.java | 22 +++++++++---------- ...ProfileHttpDto.java => MyProfileHTTP.java} | 4 ++-- .../{SignupHttpDto.java => SignupHTTP.java} | 4 ++-- ...ileHttpDto.java => UpdateProfileHTTP.java} | 4 ++-- ...ofileHttpDto.java => UserProfileHTTP.java} | 4 ++-- .../server/user/service/UserService.java | 2 +- .../common/fixture/dto/SignupDtoFixture.java | 8 +++---- .../fixture/dto/UpdateProfileDtoFixture.java | 8 +++---- .../fixture/entity/CertificationFixture.java | 16 +++++++------- .../common/implement/EmailSenderTest.java | 3 ++- .../common/implement/S3MediaManagerTest.java | 1 + .../KakaoAuthCodeRequestUrlProviderTest.java | 2 +- .../user/presentation/UserControllerTest.java | 6 ++--- .../server/user/service/UserServiceTest.java | 4 ++-- 49 files changed, 99 insertions(+), 95 deletions(-) rename src/main/java/coffeemeet/server/certification/presentation/dto/{EmailDto.java => EmailHTTP.java} (71%) rename src/main/java/coffeemeet/server/certification/presentation/dto/{VerificationCodeDto.java => VerificationCodeHTTP.java} (67%) rename src/main/java/coffeemeet/server/common/{entity => domain}/AdvancedBaseEntity.java (94%) rename src/main/java/coffeemeet/server/{user/presentation/dto => common/domain}/AuthInfo.java (56%) rename src/main/java/coffeemeet/server/common/{entity => domain}/BaseEntity.java (94%) rename src/main/java/coffeemeet/server/common/{implement => domain}/KeyType.java (82%) rename src/main/java/coffeemeet/server/oauth/implement/provider/kakao/{authcode => }/KakaoAuthCodeRequestUrlProvider.java (94%) rename src/main/java/coffeemeet/server/user/presentation/dto/{MyProfileHttpDto.java => MyProfileHTTP.java} (89%) rename src/main/java/coffeemeet/server/user/presentation/dto/{SignupHttpDto.java => SignupHTTP.java} (82%) rename src/main/java/coffeemeet/server/user/presentation/dto/{UpdateProfileHttpDto.java => UpdateProfileHTTP.java} (68%) rename src/main/java/coffeemeet/server/user/presentation/dto/{UserProfileHttpDto.java => UserProfileHTTP.java} (84%) diff --git a/src/main/java/coffeemeet/server/admin/domain/Admin.java b/src/main/java/coffeemeet/server/admin/domain/Admin.java index c5f4341c..97bbdb3b 100644 --- a/src/main/java/coffeemeet/server/admin/domain/Admin.java +++ b/src/main/java/coffeemeet/server/admin/domain/Admin.java @@ -1,6 +1,6 @@ package coffeemeet.server.admin.domain; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; diff --git a/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java index 734e8774..2d5a337e 100644 --- a/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java +++ b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java @@ -3,10 +3,10 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @Transactional @RequiredArgsConstructor public class RefreshTokenCommand { diff --git a/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java index b52421ae..9b999ec7 100644 --- a/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java +++ b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java @@ -6,10 +6,10 @@ import coffeemeet.server.auth.infrastructure.RefreshTokenRepository; import coffeemeet.server.common.execption.InvalidInputException; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @RequiredArgsConstructor @Transactional(readOnly = true) public class RefreshTokenQuery { diff --git a/src/main/java/coffeemeet/server/auth/presentation/AuthController.java b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java index cdcbb1b5..4e394f93 100644 --- a/src/main/java/coffeemeet/server/auth/presentation/AuthController.java +++ b/src/main/java/coffeemeet/server/auth/presentation/AuthController.java @@ -3,7 +3,7 @@ import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.service.AuthService; import coffeemeet.server.common.annotation.Login; -import coffeemeet.server.user.presentation.dto.AuthInfo; +import coffeemeet.server.common.domain.AuthInfo; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; diff --git a/src/main/java/coffeemeet/server/certification/domain/Certification.java b/src/main/java/coffeemeet/server/certification/domain/Certification.java index ad404ddc..29eae232 100644 --- a/src/main/java/coffeemeet/server/certification/domain/Certification.java +++ b/src/main/java/coffeemeet/server/certification/domain/Certification.java @@ -1,6 +1,6 @@ package coffeemeet.server.certification.domain; -import coffeemeet.server.common.entity.AdvancedBaseEntity; +import coffeemeet.server.common.domain.AdvancedBaseEntity; import coffeemeet.server.user.domain.User; import jakarta.persistence.Column; import jakarta.persistence.Embedded; diff --git a/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java index cf254580..1c0d6d3b 100644 --- a/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java @@ -10,10 +10,10 @@ import coffeemeet.server.user.domain.User; import java.util.function.Consumer; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @Transactional @RequiredArgsConstructor public class CertificationCommand { diff --git a/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java index 2e7bda1b..c16bede6 100644 --- a/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java @@ -6,10 +6,10 @@ import coffeemeet.server.certification.infrastructure.CertificationRepository; import coffeemeet.server.common.execption.InvalidInputException; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @RequiredArgsConstructor @Transactional(readOnly = true) public class CertificationQuery { diff --git a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java index 32fed5fc..1b0361f1 100644 --- a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java +++ b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java @@ -4,9 +4,9 @@ import coffeemeet.server.certification.domain.EmailVerification; import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; -@Service +@Component @RequiredArgsConstructor public class EmailVerificationCommand { diff --git a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java index abd86ee4..e168395a 100644 --- a/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java +++ b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java @@ -6,9 +6,9 @@ import coffeemeet.server.certification.infrastructure.EmailVerificationRepository; import coffeemeet.server.common.execption.InvalidInputException; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; -@Service +@Component @RequiredArgsConstructor public class EmailVerificationQuery { diff --git a/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java index 7d843ff9..f4874e96 100644 --- a/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java +++ b/src/main/java/coffeemeet/server/certification/presentation/CertificationController.java @@ -1,11 +1,11 @@ package coffeemeet.server.certification.presentation; -import coffeemeet.server.certification.presentation.dto.EmailDto; -import coffeemeet.server.certification.presentation.dto.VerificationCodeDto; +import coffeemeet.server.certification.presentation.dto.EmailHTTP; +import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; import coffeemeet.server.certification.service.CertificationService; import coffeemeet.server.common.annotation.Login; +import coffeemeet.server.common.domain.AuthInfo; import coffeemeet.server.common.util.FileUtils; -import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; @@ -39,7 +39,7 @@ public ResponseEntity registerCompanyInfo( @PostMapping("/users/me/company-mail") public ResponseEntity sendVerificationCodeByEmail( @Login AuthInfo authInfo, - @Valid @RequestBody EmailDto.Request request + @Valid @RequestBody EmailHTTP.Request request ) { certificationService.sendVerificationMail(authInfo.userId(), request.companyEmail()); return ResponseEntity.ok().build(); @@ -48,7 +48,7 @@ public ResponseEntity sendVerificationCodeByEmail( @PostMapping("/users/me/company-mail/verification") public ResponseEntity verifyEmail( @Login AuthInfo authInfo, - @Valid @RequestBody VerificationCodeDto.Request request + @Valid @RequestBody VerificationCodeHTTP.Request request ) { certificationService.compareCode(authInfo.userId(), request.verificationCode()); return ResponseEntity.ok().build(); diff --git a/src/main/java/coffeemeet/server/certification/presentation/dto/EmailDto.java b/src/main/java/coffeemeet/server/certification/presentation/dto/EmailHTTP.java similarity index 71% rename from src/main/java/coffeemeet/server/certification/presentation/dto/EmailDto.java rename to src/main/java/coffeemeet/server/certification/presentation/dto/EmailHTTP.java index 8cc234fc..bb43735f 100644 --- a/src/main/java/coffeemeet/server/certification/presentation/dto/EmailDto.java +++ b/src/main/java/coffeemeet/server/certification/presentation/dto/EmailHTTP.java @@ -3,12 +3,12 @@ import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotNull; -public sealed interface EmailDto permits EmailDto.Request { +public sealed interface EmailHTTP permits EmailHTTP.Request { record Request( @Email @NotNull String companyEmail - ) implements EmailDto { + ) implements EmailHTTP { } diff --git a/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeDto.java b/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeHTTP.java similarity index 67% rename from src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeDto.java rename to src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeHTTP.java index 6ecbe31e..7455f270 100644 --- a/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeDto.java +++ b/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeHTTP.java @@ -3,12 +3,12 @@ import jakarta.validation.constraints.NotNull; import org.hibernate.validator.constraints.Length; -public sealed interface VerificationCodeDto permits VerificationCodeDto.Request { +public sealed interface VerificationCodeHTTP permits VerificationCodeHTTP.Request { record Request( @NotNull @Length(min = 6, max = 6) String verificationCode - ) implements VerificationCodeDto { + ) implements VerificationCodeHTTP { } diff --git a/src/main/java/coffeemeet/server/certification/service/CertificationService.java b/src/main/java/coffeemeet/server/certification/service/CertificationService.java index 9178ad3f..734e2181 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -1,7 +1,7 @@ package coffeemeet.server.certification.service; import static coffeemeet.server.certification.exception.CertificationErrorCode.INVALID_VERIFICATION_CODE; -import static coffeemeet.server.common.implement.KeyType.BUSINESS_CARD; +import static coffeemeet.server.common.domain.KeyType.BUSINESS_CARD; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; diff --git a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java index 88939f07..a8584b9f 100644 --- a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java +++ b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java @@ -2,7 +2,7 @@ import static coffeemeet.server.chatting.exception.ChattingErrorCode.INVALID_MESSAGE; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import coffeemeet.server.common.execption.InvalidInputException; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java index f60d59ca..71fb719b 100644 --- a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java +++ b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java @@ -1,6 +1,6 @@ package coffeemeet.server.chatting.message.domain; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; diff --git a/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java index fb97bada..22b91af5 100644 --- a/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java +++ b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java @@ -2,7 +2,7 @@ import static coffeemeet.server.chatting.exception.ChattingErrorCode.INVALID_MESSAGE; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import coffeemeet.server.common.execption.InvalidInputException; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoomHistory.java b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoomHistory.java index cb49b645..4a0231d4 100644 --- a/src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoomHistory.java +++ b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoomHistory.java @@ -1,6 +1,6 @@ package coffeemeet.server.chatting.room.domain; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; diff --git a/src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java b/src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java index 37fb1ed6..f157456f 100644 --- a/src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java +++ b/src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java @@ -1,6 +1,6 @@ package coffeemeet.server.chatting.room.domain; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import coffeemeet.server.user.domain.User; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; diff --git a/src/main/java/coffeemeet/server/common/entity/AdvancedBaseEntity.java b/src/main/java/coffeemeet/server/common/domain/AdvancedBaseEntity.java similarity index 94% rename from src/main/java/coffeemeet/server/common/entity/AdvancedBaseEntity.java rename to src/main/java/coffeemeet/server/common/domain/AdvancedBaseEntity.java index c53a48d9..a87f5b6f 100644 --- a/src/main/java/coffeemeet/server/common/entity/AdvancedBaseEntity.java +++ b/src/main/java/coffeemeet/server/common/domain/AdvancedBaseEntity.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.entity; +package coffeemeet.server.common.domain; import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; diff --git a/src/main/java/coffeemeet/server/user/presentation/dto/AuthInfo.java b/src/main/java/coffeemeet/server/common/domain/AuthInfo.java similarity index 56% rename from src/main/java/coffeemeet/server/user/presentation/dto/AuthInfo.java rename to src/main/java/coffeemeet/server/common/domain/AuthInfo.java index 3d251c2a..ef3f2954 100644 --- a/src/main/java/coffeemeet/server/user/presentation/dto/AuthInfo.java +++ b/src/main/java/coffeemeet/server/common/domain/AuthInfo.java @@ -1,4 +1,4 @@ -package coffeemeet.server.user.presentation.dto; +package coffeemeet.server.common.domain; public record AuthInfo(Long userId, String refreshToken) { diff --git a/src/main/java/coffeemeet/server/common/entity/BaseEntity.java b/src/main/java/coffeemeet/server/common/domain/BaseEntity.java similarity index 94% rename from src/main/java/coffeemeet/server/common/entity/BaseEntity.java rename to src/main/java/coffeemeet/server/common/domain/BaseEntity.java index 2be962aa..75c143f5 100644 --- a/src/main/java/coffeemeet/server/common/entity/BaseEntity.java +++ b/src/main/java/coffeemeet/server/common/domain/BaseEntity.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.entity; +package coffeemeet.server.common.domain; import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; diff --git a/src/main/java/coffeemeet/server/common/implement/KeyType.java b/src/main/java/coffeemeet/server/common/domain/KeyType.java similarity index 82% rename from src/main/java/coffeemeet/server/common/implement/KeyType.java rename to src/main/java/coffeemeet/server/common/domain/KeyType.java index be8a35c8..ab42c5df 100644 --- a/src/main/java/coffeemeet/server/common/implement/KeyType.java +++ b/src/main/java/coffeemeet/server/common/domain/KeyType.java @@ -1,4 +1,4 @@ -package coffeemeet.server.common.implement; +package coffeemeet.server.common.domain; import lombok.Getter; diff --git a/src/main/java/coffeemeet/server/common/implement/EmailSender.java b/src/main/java/coffeemeet/server/common/implement/EmailSender.java index 6d6834ad..17a308be 100644 --- a/src/main/java/coffeemeet/server/common/implement/EmailSender.java +++ b/src/main/java/coffeemeet/server/common/implement/EmailSender.java @@ -4,9 +4,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; -@Service +@Component public class EmailSender { private final JavaMailSender javaMailSender; diff --git a/src/main/java/coffeemeet/server/common/implement/MediaManager.java b/src/main/java/coffeemeet/server/common/implement/MediaManager.java index 4744f772..e189139a 100644 --- a/src/main/java/coffeemeet/server/common/implement/MediaManager.java +++ b/src/main/java/coffeemeet/server/common/implement/MediaManager.java @@ -1,5 +1,6 @@ package coffeemeet.server.common.implement; +import coffeemeet.server.common.domain.KeyType; import java.io.File; public interface MediaManager { diff --git a/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java b/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java index ae61cf4b..e362dbec 100644 --- a/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java +++ b/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java @@ -2,15 +2,16 @@ import static coffeemeet.server.common.execption.GlobalErrorCode.INVALID_S3_URL; +import coffeemeet.server.common.domain.KeyType; import coffeemeet.server.common.execption.InvalidInputException; import com.amazonaws.services.s3.AmazonS3; import java.io.File; import java.time.LocalDateTime; import java.util.UUID; import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; -@Service +@Component public class S3MediaManager implements MediaManager { private static final String INVALID_S3_URL_MESSAGE = "올바르지 않은 S3 URL(%s)입니다."; diff --git a/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java index 5df96d83..27188479 100644 --- a/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java +++ b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java @@ -6,8 +6,8 @@ import coffeemeet.server.auth.domain.RefreshToken; import coffeemeet.server.auth.implement.RefreshTokenQuery; import coffeemeet.server.common.annotation.Login; +import coffeemeet.server.common.domain.AuthInfo; import coffeemeet.server.common.execption.InvalidInputException; -import coffeemeet.server.user.presentation.dto.AuthInfo; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.core.MethodParameter; diff --git a/src/main/java/coffeemeet/server/inquiry/domain/Inquiry.java b/src/main/java/coffeemeet/server/inquiry/domain/Inquiry.java index 37ad009a..f7340d9a 100644 --- a/src/main/java/coffeemeet/server/inquiry/domain/Inquiry.java +++ b/src/main/java/coffeemeet/server/inquiry/domain/Inquiry.java @@ -1,6 +1,6 @@ package coffeemeet.server.inquiry.domain; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/src/main/java/coffeemeet/server/oauth/implement/provider/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java b/src/main/java/coffeemeet/server/oauth/implement/provider/kakao/KakaoAuthCodeRequestUrlProvider.java similarity index 94% rename from src/main/java/coffeemeet/server/oauth/implement/provider/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java rename to src/main/java/coffeemeet/server/oauth/implement/provider/kakao/KakaoAuthCodeRequestUrlProvider.java index 6d8dbf4b..ca54f732 100644 --- a/src/main/java/coffeemeet/server/oauth/implement/provider/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java +++ b/src/main/java/coffeemeet/server/oauth/implement/provider/kakao/KakaoAuthCodeRequestUrlProvider.java @@ -1,4 +1,4 @@ -package coffeemeet.server.oauth.implement.provider.kakao.authcode; +package coffeemeet.server.oauth.implement.provider.kakao; import coffeemeet.server.oauth.config.kakao.KakaoProperties; import coffeemeet.server.oauth.implement.provider.AuthCodeRequestUrlProvider; diff --git a/src/main/java/coffeemeet/server/report/domain/Report.java b/src/main/java/coffeemeet/server/report/domain/Report.java index 1ec564b5..9c00dba7 100644 --- a/src/main/java/coffeemeet/server/report/domain/Report.java +++ b/src/main/java/coffeemeet/server/report/domain/Report.java @@ -1,6 +1,6 @@ package coffeemeet.server.report.domain; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; diff --git a/src/main/java/coffeemeet/server/user/domain/Interest.java b/src/main/java/coffeemeet/server/user/domain/Interest.java index aa70280e..00cecf71 100644 --- a/src/main/java/coffeemeet/server/user/domain/Interest.java +++ b/src/main/java/coffeemeet/server/user/domain/Interest.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.domain; -import coffeemeet.server.common.entity.BaseEntity; +import coffeemeet.server.common.domain.BaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; diff --git a/src/main/java/coffeemeet/server/user/domain/User.java b/src/main/java/coffeemeet/server/user/domain/User.java index 0e1d3a60..f586e83f 100644 --- a/src/main/java/coffeemeet/server/user/domain/User.java +++ b/src/main/java/coffeemeet/server/user/domain/User.java @@ -1,7 +1,7 @@ package coffeemeet.server.user.domain; import coffeemeet.server.chatting.message.domain.ChattingRoom; -import coffeemeet.server.common.entity.AdvancedBaseEntity; +import coffeemeet.server.common.domain.AdvancedBaseEntity; import jakarta.persistence.Column; import jakarta.persistence.Embedded; import jakarta.persistence.Entity; diff --git a/src/main/java/coffeemeet/server/user/implement/InterestCommand.java b/src/main/java/coffeemeet/server/user/implement/InterestCommand.java index 2fb312ef..9966b04f 100644 --- a/src/main/java/coffeemeet/server/user/implement/InterestCommand.java +++ b/src/main/java/coffeemeet/server/user/implement/InterestCommand.java @@ -6,10 +6,10 @@ import coffeemeet.server.user.infrastructure.InterestRepository; import java.util.List; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @Transactional @RequiredArgsConstructor public class InterestCommand { diff --git a/src/main/java/coffeemeet/server/user/implement/InterestQuery.java b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java index b605c471..87d8365f 100644 --- a/src/main/java/coffeemeet/server/user/implement/InterestQuery.java +++ b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java @@ -5,10 +5,10 @@ import coffeemeet.server.user.infrastructure.InterestRepository; import java.util.List; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @RequiredArgsConstructor @Transactional(readOnly = true) public class InterestQuery { diff --git a/src/main/java/coffeemeet/server/user/implement/UserCommand.java b/src/main/java/coffeemeet/server/user/implement/UserCommand.java index 5529abcd..173f0d0c 100644 --- a/src/main/java/coffeemeet/server/user/implement/UserCommand.java +++ b/src/main/java/coffeemeet/server/user/implement/UserCommand.java @@ -4,10 +4,10 @@ import coffeemeet.server.user.infrastructure.InterestRepository; import coffeemeet.server.user.infrastructure.UserRepository; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @Transactional @RequiredArgsConstructor public class UserCommand { diff --git a/src/main/java/coffeemeet/server/user/implement/UserQuery.java b/src/main/java/coffeemeet/server/user/implement/UserQuery.java index ada44e53..9b476d08 100644 --- a/src/main/java/coffeemeet/server/user/implement/UserQuery.java +++ b/src/main/java/coffeemeet/server/user/implement/UserQuery.java @@ -11,10 +11,10 @@ import coffeemeet.server.user.domain.User; import coffeemeet.server.user.infrastructure.UserRepository; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @RequiredArgsConstructor @Transactional(readOnly = true) public class UserQuery { diff --git a/src/main/java/coffeemeet/server/user/presentation/UserController.java b/src/main/java/coffeemeet/server/user/presentation/UserController.java index b3bfc342..428f0d7a 100644 --- a/src/main/java/coffeemeet/server/user/presentation/UserController.java +++ b/src/main/java/coffeemeet/server/user/presentation/UserController.java @@ -2,13 +2,13 @@ import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.common.annotation.Login; +import coffeemeet.server.common.domain.AuthInfo; import coffeemeet.server.common.util.FileUtils; import coffeemeet.server.user.domain.OAuthProvider; -import coffeemeet.server.user.presentation.dto.AuthInfo; -import coffeemeet.server.user.presentation.dto.MyProfileHttpDto; -import coffeemeet.server.user.presentation.dto.SignupHttpDto; -import coffeemeet.server.user.presentation.dto.UpdateProfileHttpDto; -import coffeemeet.server.user.presentation.dto.UserProfileHttpDto; +import coffeemeet.server.user.presentation.dto.MyProfileHTTP; +import coffeemeet.server.user.presentation.dto.SignupHTTP; +import coffeemeet.server.user.presentation.dto.UpdateProfileHTTP; +import coffeemeet.server.user.presentation.dto.UserProfileHTTP; import coffeemeet.server.user.service.UserService; import coffeemeet.server.user.service.dto.MyProfileDto; import coffeemeet.server.user.service.dto.UserProfileDto.Response; @@ -36,7 +36,7 @@ public class UserController { private final UserService userService; @PostMapping("/sign-up") - public ResponseEntity signup(@Valid @RequestBody SignupHttpDto.Request request) { + public ResponseEntity signup(@Valid @RequestBody SignupHTTP.Request request) { return ResponseEntity.ok( userService.signup(request.nickname(), request.keywords(), request.authCode(), request.oAuthProvider())); @@ -49,15 +49,15 @@ public ResponseEntity login(@PathVariable OAuthProvider oAuthProvide } @GetMapping("/{userId}") - public ResponseEntity findUserProfile(@PathVariable long userId) { + public ResponseEntity findUserProfile(@PathVariable long userId) { Response response = userService.findUserProfile(userId); - return ResponseEntity.ok(UserProfileHttpDto.Response.of(response)); + return ResponseEntity.ok(UserProfileHTTP.Response.of(response)); } @GetMapping("/me") - public ResponseEntity findMyProfile(@Login AuthInfo authInfo) { + public ResponseEntity findMyProfile(@Login AuthInfo authInfo) { MyProfileDto.Response response = userService.findMyProfile(authInfo.userId()); - return ResponseEntity.ok(MyProfileHttpDto.Response.of(response)); + return ResponseEntity.ok(MyProfileHTTP.Response.of(response)); } @PostMapping("/me/profile-image") @@ -73,7 +73,7 @@ public ResponseEntity updateProfileImage( @PatchMapping("/me") public ResponseEntity updateProfileInfo(@Login AuthInfo authInfo, - @Valid @RequestBody UpdateProfileHttpDto.Request request) { + @Valid @RequestBody UpdateProfileHTTP.Request request) { userService.updateProfileInfo(authInfo.userId(), request.nickname(), request.interests()); return ResponseEntity.ok().build(); } diff --git a/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHTTP.java similarity index 89% rename from src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHTTP.java index 9add67b9..79577f90 100644 --- a/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHTTP.java @@ -6,7 +6,7 @@ import java.time.LocalDateTime; import java.util.List; -public sealed interface MyProfileHttpDto permits MyProfileHttpDto.Response { +public sealed interface MyProfileHTTP permits MyProfileHTTP.Response { record Response( String name, @@ -19,7 +19,7 @@ record Response( LocalDateTime sanctionPeriod, Department department, List interests - ) implements MyProfileHttpDto { + ) implements MyProfileHTTP { public static Response of(MyProfileDto.Response response) { return new Response( diff --git a/src/main/java/coffeemeet/server/user/presentation/dto/SignupHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/SignupHTTP.java similarity index 82% rename from src/main/java/coffeemeet/server/user/presentation/dto/SignupHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/SignupHTTP.java index ef5739e0..f3e2adc1 100644 --- a/src/main/java/coffeemeet/server/user/presentation/dto/SignupHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/SignupHTTP.java @@ -7,7 +7,7 @@ import java.util.List; import lombok.NonNull; -public sealed interface SignupHttpDto permits SignupHttpDto.Request { +public sealed interface SignupHTTP permits SignupHTTP.Request { record Request( @NotBlank @@ -18,7 +18,7 @@ record Request( String authCode, @NonNull OAuthProvider oAuthProvider - ) implements SignupHttpDto { + ) implements SignupHTTP { } diff --git a/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHTTP.java similarity index 68% rename from src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHTTP.java index e5a596c1..ebfdde12 100644 --- a/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHTTP.java @@ -4,12 +4,12 @@ import jakarta.validation.constraints.Size; import java.util.List; -public sealed interface UpdateProfileHttpDto permits UpdateProfileHttpDto.Request { +public sealed interface UpdateProfileHTTP permits UpdateProfileHTTP.Request { record Request( String nickname, @Size(min = 1, max = 3) List interests - ) implements UpdateProfileHttpDto { + ) implements UpdateProfileHTTP { } diff --git a/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHTTP.java similarity index 84% rename from src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHTTP.java index c47d566d..757a88ce 100644 --- a/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHTTP.java @@ -5,14 +5,14 @@ import coffeemeet.server.user.service.dto.UserProfileDto; import java.util.List; -public sealed interface UserProfileHttpDto permits UserProfileHttpDto.Response { +public sealed interface UserProfileHTTP permits UserProfileHTTP.Response { record Response( String nickname, String profileImageUrl, Department department, List interests - ) implements UserProfileHttpDto { + ) implements UserProfileHTTP { public static Response of(UserProfileDto.Response response) { return new Response( diff --git a/src/main/java/coffeemeet/server/user/service/UserService.java b/src/main/java/coffeemeet/server/user/service/UserService.java index 18e80d84..b1aaef5f 100644 --- a/src/main/java/coffeemeet/server/user/service/UserService.java +++ b/src/main/java/coffeemeet/server/user/service/UserService.java @@ -1,6 +1,6 @@ package coffeemeet.server.user.service; -import static coffeemeet.server.common.implement.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.domain.KeyType.PROFILE_IMAGE; import coffeemeet.server.auth.domain.AuthTokens; import coffeemeet.server.auth.domain.AuthTokensGenerator; diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java index e378ddf9..5be41d1d 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java @@ -3,15 +3,15 @@ import static org.instancio.Select.field; import coffeemeet.server.user.domain.Keyword; -import coffeemeet.server.user.presentation.dto.SignupHttpDto; -import coffeemeet.server.user.presentation.dto.SignupHttpDto.Request; +import coffeemeet.server.user.presentation.dto.SignupHTTP; +import coffeemeet.server.user.presentation.dto.SignupHTTP.Request; import java.util.List; import org.instancio.Instancio; public class SignupDtoFixture { - public static SignupHttpDto.Request signupDto() { - return Instancio.of(SignupHttpDto.Request.class) + public static SignupHTTP.Request signupDto() { + return Instancio.of(SignupHTTP.Request.class) .set(field(Request::keywords), keywords()) .create(); } diff --git a/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java b/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java index 361c8fe2..1a52310f 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java @@ -3,15 +3,15 @@ import static org.instancio.Select.field; import coffeemeet.server.user.domain.Keyword; -import coffeemeet.server.user.presentation.dto.UpdateProfileHttpDto; +import coffeemeet.server.user.presentation.dto.UpdateProfileHTTP; import java.util.List; import org.instancio.Instancio; public class UpdateProfileDtoFixture { - public static UpdateProfileHttpDto.Request updateProfileDtoRequest() { - return Instancio.of(UpdateProfileHttpDto.Request.class) - .set(field(UpdateProfileHttpDto.Request::interests), keywords()) + public static UpdateProfileHTTP.Request updateProfileDtoRequest() { + return Instancio.of(UpdateProfileHTTP.Request.class) + .set(field(UpdateProfileHTTP.Request::interests), keywords()) .create(); } diff --git a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java index 6417c3e4..90d0e2a9 100644 --- a/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/entity/CertificationFixture.java @@ -6,8 +6,8 @@ import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.Department; import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.presentation.dto.EmailDto; -import coffeemeet.server.certification.presentation.dto.VerificationCodeDto; +import coffeemeet.server.certification.presentation.dto.EmailHTTP; +import coffeemeet.server.certification.presentation.dto.VerificationCodeHTTP; import coffeemeet.server.user.domain.User; import org.instancio.Instancio; import org.instancio.internal.generator.domain.internet.EmailGenerator; @@ -66,14 +66,14 @@ public static Department department() { return Instancio.create(Department.class); } - public static EmailDto.Request emailDtoRequest() { - return Instancio.of(EmailDto.Request.class) - .generate(field(EmailDto.Request::companyEmail), gen -> gen.net().email()).create(); + public static EmailHTTP.Request emailDtoRequest() { + return Instancio.of(EmailHTTP.Request.class) + .generate(field(EmailHTTP.Request::companyEmail), gen -> gen.net().email()).create(); } - public static VerificationCodeDto.Request verificationCodeDtoRequest() { - return Instancio.of(VerificationCodeDto.Request.class) - .set(field(VerificationCodeDto.Request::verificationCode), + public static VerificationCodeHTTP.Request verificationCodeDtoRequest() { + return Instancio.of(VerificationCodeHTTP.Request.class) + .set(field(VerificationCodeHTTP.Request::verificationCode), String.format("%06d", new IntegerGenerator().range(0, 999999).get())).create(); } diff --git a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java index 00bf24c8..a120eb41 100644 --- a/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -56,7 +56,8 @@ void sendVerificationCodeTest() { SimpleMailMessage sentMailMessage = simpleMailMessage.getValue(); assertAll( () -> assertThat(sentMailMessage.getFrom()).isEqualTo(sender), - () -> assertThat(Objects.requireNonNull(sentMailMessage.getTo())[0]).isEqualTo(companyEmail.getValue()), + () -> assertThat(Objects.requireNonNull(sentMailMessage.getTo())[0]).isEqualTo( + companyEmail.getValue()), () -> assertThat(sentMailMessage.getText()).contains(verificationCode) ); } diff --git a/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java b/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java index 1a8462bf..2f6dee27 100644 --- a/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java +++ b/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java @@ -7,6 +7,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; +import coffeemeet.server.common.domain.KeyType; import com.amazonaws.services.s3.AmazonS3; import java.io.File; import java.net.URL; diff --git a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java index 17795595..5b52dfda 100644 --- a/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java +++ b/src/test/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.java @@ -4,7 +4,7 @@ import static org.mockito.BDDMockito.given; import coffeemeet.server.oauth.config.kakao.KakaoProperties; -import coffeemeet.server.oauth.implement.provider.kakao.authcode.KakaoAuthCodeRequestUrlProvider; +import coffeemeet.server.oauth.implement.provider.kakao.KakaoAuthCodeRequestUrlProvider; import coffeemeet.server.user.domain.OAuthProvider; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java b/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java index 7f3e6438..4579d1e6 100644 --- a/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java +++ b/src/test/java/coffeemeet/server/user/presentation/UserControllerTest.java @@ -37,8 +37,8 @@ import coffeemeet.server.common.fixture.dto.UserProfileDtoFixture; import coffeemeet.server.user.domain.OAuthProvider; import coffeemeet.server.user.domain.User; -import coffeemeet.server.user.presentation.dto.SignupHttpDto; -import coffeemeet.server.user.presentation.dto.UpdateProfileHttpDto.Request; +import coffeemeet.server.user.presentation.dto.SignupHTTP; +import coffeemeet.server.user.presentation.dto.UpdateProfileHTTP.Request; import coffeemeet.server.user.service.UserService; import coffeemeet.server.user.service.dto.MyProfileDto.Response; import coffeemeet.server.user.service.dto.UserProfileDto; @@ -61,7 +61,7 @@ class UserControllerTest extends ControllerTestConfig { @DisplayName("회원가입을 할 수 있다.") void signupTest() throws Exception { // given - SignupHttpDto.Request request = SignupDtoFixture.signupDto(); + SignupHTTP.Request request = SignupDtoFixture.signupDto(); AuthTokens authTokens = new AuthTokens("accessToken", "refreshToken"); given(userService.signup(any(), any(), any(), any())).willReturn(authTokens); diff --git a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java index 7194efaa..74b06510 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -1,8 +1,8 @@ package coffeemeet.server.user.service; import static coffeemeet.server.certification.domain.Department.IT; +import static coffeemeet.server.common.domain.KeyType.PROFILE_IMAGE; import static coffeemeet.server.common.fixture.entity.UserFixture.user; -import static coffeemeet.server.common.implement.KeyType.PROFILE_IMAGE; import static coffeemeet.server.user.domain.Keyword.COOK; import static coffeemeet.server.user.domain.Keyword.GAME; import static coffeemeet.server.user.domain.OAuthProvider.KAKAO; @@ -39,7 +39,7 @@ import coffeemeet.server.user.implement.InterestQuery; import coffeemeet.server.user.implement.UserCommand; import coffeemeet.server.user.implement.UserQuery; -import coffeemeet.server.user.presentation.dto.SignupHttpDto.Request; +import coffeemeet.server.user.presentation.dto.SignupHTTP.Request; import coffeemeet.server.user.service.dto.MyProfileDto; import coffeemeet.server.user.service.dto.UserProfileDto.Response; import java.io.File;