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/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/service/cq/RefreshTokenCommand.java b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java similarity index 75% rename from src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenCommand.java rename to src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java index 174077b3..2d5a337e 100644 --- a/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenCommand.java +++ b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenCommand.java @@ -1,12 +1,12 @@ -package coffeemeet.server.auth.service.cq; +package coffeemeet.server.auth.implement; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.auth.repository.RefreshTokenRepository; +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/service/cq/RefreshTokenQuery.java b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java similarity index 83% rename from src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenQuery.java rename to src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java index f3ef300a..9b999ec7 100644 --- a/src/main/java/coffeemeet/server/auth/service/cq/RefreshTokenQuery.java +++ b/src/main/java/coffeemeet/server/auth/implement/RefreshTokenQuery.java @@ -1,15 +1,15 @@ -package coffeemeet.server.auth.service.cq; +package coffeemeet.server.auth.implement; import static coffeemeet.server.auth.exception.AuthErrorCode.AUTHENTICATION_FAILED; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.auth.repository.RefreshTokenRepository; +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/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 92% rename from src/main/java/coffeemeet/server/auth/controller/AuthController.java rename to src/main/java/coffeemeet/server/auth/presentation/AuthController.java index 75d7ce9c..4e394f93 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.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/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/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/service/cq/CertificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java similarity index 89% rename from src/main/java/coffeemeet/server/certification/service/cq/CertificationCommand.java rename to src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java index 5b8fc603..1c0d6d3b 100644 --- a/src/main/java/coffeemeet/server/certification/service/cq/CertificationCommand.java +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationCommand.java @@ -1,19 +1,19 @@ -package coffeemeet.server.certification.service.cq; +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.repository.CertificationRepository; +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.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @Transactional @RequiredArgsConstructor public class CertificationCommand { diff --git a/src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java similarity index 82% rename from src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java rename to src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java index 6f2625b3..c16bede6 100644 --- a/src/main/java/coffeemeet/server/certification/service/cq/CertificationQuery.java +++ b/src/main/java/coffeemeet/server/certification/implement/CertificationQuery.java @@ -1,15 +1,15 @@ -package coffeemeet.server.certification.service.cq; +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.repository.CertificationRepository; +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/service/cq/EmailVerificationCommand.java b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java similarity index 73% rename from src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationCommand.java rename to src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java index 5412ecc3..1b0361f1 100644 --- a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationCommand.java +++ b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationCommand.java @@ -1,12 +1,12 @@ -package coffeemeet.server.certification.service.cq; +package coffeemeet.server.certification.implement; import coffeemeet.server.certification.domain.CompanyEmail; import coffeemeet.server.certification.domain.EmailVerification; -import coffeemeet.server.certification.repository.EmailVerificationRepository; +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/service/cq/EmailVerificationQuery.java b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java similarity index 78% rename from src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java rename to src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java index 2cfed34f..e168395a 100644 --- a/src/main/java/coffeemeet/server/certification/service/cq/EmailVerificationQuery.java +++ b/src/main/java/coffeemeet/server/certification/implement/EmailVerificationQuery.java @@ -1,18 +1,18 @@ -package coffeemeet.server.certification.service.cq; +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.repository.EmailVerificationRepository; +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 { - private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증 번호를 요청한 기록이 없습니다."; + private static final String VERIFICATION_CODE_NOT_FOUND_MESSAGE = "인증코드 기간이 만료되었거나 해당 유저(%s)가 인증코드를 요청한 기록이 없습니다."; private final EmailVerificationRepository emailVerificationRepository; 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 84% rename from src/main/java/coffeemeet/server/certification/controller/CertificationController.java rename to src/main/java/coffeemeet/server/certification/presentation/CertificationController.java index 62b62ada..f4874e96 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.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.controller.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/controller/dto/EmailDto.java b/src/main/java/coffeemeet/server/certification/presentation/dto/EmailHTTP.java similarity index 53% rename from src/main/java/coffeemeet/server/certification/controller/dto/EmailDto.java rename to src/main/java/coffeemeet/server/certification/presentation/dto/EmailHTTP.java index 4d04f708..bb43735f 100644 --- a/src/main/java/coffeemeet/server/certification/controller/dto/EmailDto.java +++ b/src/main/java/coffeemeet/server/certification/presentation/dto/EmailHTTP.java @@ -1,14 +1,14 @@ -package coffeemeet.server.certification.controller.dto; +package coffeemeet.server.certification.presentation.dto; 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/controller/dto/VerificationCodeDto.java b/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeHTTP.java similarity index 52% rename from src/main/java/coffeemeet/server/certification/controller/dto/VerificationCodeDto.java rename to src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeHTTP.java index e749309f..7455f270 100644 --- a/src/main/java/coffeemeet/server/certification/controller/dto/VerificationCodeDto.java +++ b/src/main/java/coffeemeet/server/certification/presentation/dto/VerificationCodeHTTP.java @@ -1,14 +1,14 @@ -package coffeemeet.server.certification.controller.dto; +package coffeemeet.server.certification.presentation.dto; 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 eff6c4e2..734e2181 100644 --- a/src/main/java/coffeemeet/server/certification/service/CertificationService.java +++ b/src/main/java/coffeemeet/server/certification/service/CertificationService.java @@ -1,19 +1,19 @@ 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.domain.KeyType.BUSINESS_CARD; 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.EmailService; -import coffeemeet.server.common.media.S3MediaService; +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.service.cq.UserQuery; +import coffeemeet.server.user.implement.UserQuery; import java.io.File; import java.util.random.RandomGenerator; import lombok.RequiredArgsConstructor; @@ -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/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..a8584b9f 100644 --- a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java +++ b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessage.java @@ -1,9 +1,8 @@ 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.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/ChattingRoom.java b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java similarity index 83% 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..71fb719b 100644 --- a/src/main/java/coffeemeet/server/chatting/room/domain/ChattingRoom.java +++ b/src/main/java/coffeemeet/server/chatting/message/domain/ChattingRoom.java @@ -1,6 +1,6 @@ -package coffeemeet.server.chatting.room.domain; +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/message/domain/ChattingMessageHistory.java b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java similarity index 85% 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..22b91af5 100644 --- a/src/main/java/coffeemeet/server/chatting/message/domain/ChattingMessageHistory.java +++ b/src/main/java/coffeemeet/server/chatting/room/domain/ChattingMessageHistory.java @@ -1,9 +1,8 @@ -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.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/user_chatting_history/domain/UserChattingHistory.java b/src/main/java/coffeemeet/server/chatting/room/domain/UserChattingHistory.java similarity index 84% 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..f157456f 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,7 +1,6 @@ -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.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/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) { diff --git a/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java b/src/main/java/coffeemeet/server/common/config/AuthWebConfig.java index d2534d66..bae4b878 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.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/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/controller/dto/AuthInfo.java b/src/main/java/coffeemeet/server/common/domain/AuthInfo.java similarity index 57% rename from src/main/java/coffeemeet/server/user/controller/dto/AuthInfo.java rename to src/main/java/coffeemeet/server/common/domain/AuthInfo.java index b1bbaa20..ef3f2954 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/AuthInfo.java +++ b/src/main/java/coffeemeet/server/common/domain/AuthInfo.java @@ -1,4 +1,4 @@ -package coffeemeet.server.user.controller.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/domain/KeyType.java b/src/main/java/coffeemeet/server/common/domain/KeyType.java new file mode 100644 index 00000000..ab42c5df --- /dev/null +++ b/src/main/java/coffeemeet/server/common/domain/KeyType.java @@ -0,0 +1,18 @@ +package coffeemeet.server.common.domain; + +import lombok.Getter; + +@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/common/media/EmailService.java b/src/main/java/coffeemeet/server/common/implement/EmailSender.java similarity index 83% rename from src/main/java/coffeemeet/server/common/media/EmailService.java rename to src/main/java/coffeemeet/server/common/implement/EmailSender.java index 35b0f13b..17a308be 100644 --- a/src/main/java/coffeemeet/server/common/media/EmailService.java +++ b/src/main/java/coffeemeet/server/common/implement/EmailSender.java @@ -1,18 +1,18 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; import coffeemeet.server.certification.domain.CompanyEmail; 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 -public class EmailService { +@Component +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/implement/MediaManager.java b/src/main/java/coffeemeet/server/common/implement/MediaManager.java new file mode 100644 index 00000000..e189139a --- /dev/null +++ b/src/main/java/coffeemeet/server/common/implement/MediaManager.java @@ -0,0 +1,18 @@ +package coffeemeet.server.common.implement; + +import coffeemeet.server.common.domain.KeyType; +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/implement/S3MediaManager.java similarity index 71% rename from src/main/java/coffeemeet/server/common/media/S3MediaService.java rename to src/main/java/coffeemeet/server/common/implement/S3MediaManager.java index b2724760..e362dbec 100644 --- a/src/main/java/coffeemeet/server/common/media/S3MediaService.java +++ b/src/main/java/coffeemeet/server/common/implement/S3MediaManager.java @@ -1,24 +1,24 @@ -package coffeemeet.server.common.media; +package coffeemeet.server.common.implement; 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 lombok.Getter; import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; +import org.springframework.stereotype.Component; -@Service -public class S3MediaService { +@Component +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 +26,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 +57,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/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/UserArgumentResolver.java b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java similarity index 92% rename from src/main/java/coffeemeet/server/common/UserArgumentResolver.java rename to src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java index 947c20b6..27188479 100644 --- a/src/main/java/coffeemeet/server/common/UserArgumentResolver.java +++ b/src/main/java/coffeemeet/server/common/presentation/resolver/UserArgumentResolver.java @@ -1,13 +1,13 @@ -package coffeemeet.server.common; +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.service.cq.RefreshTokenQuery; +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.controller.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/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/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/KakaoAuthCodeRequestUrlProvider.java index 19c563e3..ca54f732 100644 --- a/src/main/java/coffeemeet/server/oauth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProvider.java +++ b/src/main/java/coffeemeet/server/oauth/implement/provider/kakao/KakaoAuthCodeRequestUrlProvider.java @@ -1,7 +1,7 @@ -package coffeemeet.server.oauth.infrastructure.kakao.authcode; +package coffeemeet.server.oauth.implement.provider.kakao; -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/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/controller/dto/UpdateProfileHttpDto.java b/src/main/java/coffeemeet/server/user/controller/dto/UpdateProfileHttpDto.java deleted file mode 100644 index e84ce0e1..00000000 --- a/src/main/java/coffeemeet/server/user/controller/dto/UpdateProfileHttpDto.java +++ /dev/null @@ -1,16 +0,0 @@ -package coffeemeet.server.user.controller.dto; - -import coffeemeet.server.interest.domain.Keyword; -import jakarta.validation.constraints.Size; -import java.util.List; - -public sealed interface UpdateProfileHttpDto permits UpdateProfileHttpDto.Request { - - record Request( - String nickname, - @Size(min = 1, max = 3) List interests - ) implements UpdateProfileHttpDto { - - } - -} diff --git a/src/main/java/coffeemeet/server/interest/domain/Interest.java b/src/main/java/coffeemeet/server/user/domain/Interest.java similarity index 88% rename from src/main/java/coffeemeet/server/interest/domain/Interest.java rename to src/main/java/coffeemeet/server/user/domain/Interest.java index 1a4fd237..00cecf71 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 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/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..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.room.domain.ChattingRoom; -import coffeemeet.server.common.entity.AdvancedBaseEntity; +import coffeemeet.server.chatting.message.domain.ChattingRoom; +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/interest/service/cq/InterestCommand.java b/src/main/java/coffeemeet/server/user/implement/InterestCommand.java similarity index 80% 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..9966b04f 100644 --- a/src/main/java/coffeemeet/server/interest/service/cq/InterestCommand.java +++ b/src/main/java/coffeemeet/server/user/implement/InterestCommand.java @@ -1,15 +1,15 @@ -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; +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/interest/service/cq/InterestQuery.java b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java similarity index 68% 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..87d8365f 100644 --- a/src/main/java/coffeemeet/server/interest/service/cq/InterestQuery.java +++ b/src/main/java/coffeemeet/server/user/implement/InterestQuery.java @@ -1,14 +1,14 @@ -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; +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/service/cq/UserCommand.java b/src/main/java/coffeemeet/server/user/implement/UserCommand.java similarity index 77% 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..173f0d0c 100644 --- a/src/main/java/coffeemeet/server/user/service/cq/UserCommand.java +++ b/src/main/java/coffeemeet/server/user/implement/UserCommand.java @@ -1,13 +1,13 @@ -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.stereotype.Component; import org.springframework.transaction.annotation.Transactional; -@Service +@Component @Transactional @RequiredArgsConstructor public class UserCommand { 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 94% 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..9b476d08 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,12 +9,12 @@ 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.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/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 78% rename from src/main/java/coffeemeet/server/user/controller/UserController.java rename to src/main/java/coffeemeet/server/user/presentation/UserController.java index 73da33c1..428f0d7a 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.domain.AuthInfo; 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.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/controller/dto/MyProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHTTP.java similarity index 81% rename from src/main/java/coffeemeet/server/user/controller/dto/MyProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHTTP.java index 9ef96f7b..79577f90 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/MyProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/MyProfileHTTP.java @@ -1,12 +1,12 @@ -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; -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/controller/dto/SignupHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/SignupHTTP.java similarity index 66% rename from src/main/java/coffeemeet/server/user/controller/dto/SignupHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/SignupHTTP.java index 27c5fe4b..f3e2adc1 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/SignupHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/SignupHTTP.java @@ -1,13 +1,13 @@ -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; 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/UpdateProfileHTTP.java b/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHTTP.java new file mode 100644 index 00000000..ebfdde12 --- /dev/null +++ b/src/main/java/coffeemeet/server/user/presentation/dto/UpdateProfileHTTP.java @@ -0,0 +1,16 @@ +package coffeemeet.server.user.presentation.dto; + +import coffeemeet.server.user.domain.Keyword; +import jakarta.validation.constraints.Size; +import java.util.List; + +public sealed interface UpdateProfileHTTP permits UpdateProfileHTTP.Request { + + record Request( + String nickname, + @Size(min = 1, max = 3) List interests + ) implements UpdateProfileHTTP { + + } + +} diff --git a/src/main/java/coffeemeet/server/user/controller/dto/UserProfileHttpDto.java b/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHTTP.java similarity index 70% rename from src/main/java/coffeemeet/server/user/controller/dto/UserProfileHttpDto.java rename to src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHTTP.java index 05779cee..757a88ce 100644 --- a/src/main/java/coffeemeet/server/user/controller/dto/UserProfileHttpDto.java +++ b/src/main/java/coffeemeet/server/user/presentation/dto/UserProfileHTTP.java @@ -1,18 +1,18 @@ -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; -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 231f78fd..b1aaef5f 100644 --- a/src/main/java/coffeemeet/server/user/service/UserService.java +++ b/src/main/java/coffeemeet/server/user/service/UserService.java @@ -1,26 +1,26 @@ package coffeemeet.server.user.service; -import static coffeemeet.server.common.media.S3MediaService.KeyType.PROFILE_IMAGE; +import static coffeemeet.server.common.domain.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.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.certification.implement.CertificationQuery; +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; 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; @@ -34,8 +34,8 @@ public class UserService { private static final String DEFAULT_IMAGE_URL = "기본 이미지 URL"; - private final S3MediaService s3MediaService; - private final OAuthService oAuthService; + private final MediaManager mediaManager; + 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()); } @@ -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/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 98% rename from src/test/java/coffeemeet/server/certification/controller/CertificationControllerTest.java rename to src/test/java/coffeemeet/server/certification/presentation/CertificationControllerTest.java index 6b225d3e..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; @@ -96,7 +96,7 @@ void registerCompanyInfoTest() throws Exception { } @Test - @DisplayName("이메일을 통해 인증번호를 전송할 수 있다.") + @DisplayName("이메일을 통해 인증코드를 전송할 수 있다.") void sendVerificationCodeByEmailTest() throws Exception { // given String emailDtoRequest = objectMapper.writeValueAsString(emailDtoRequest()); diff --git a/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java b/src/test/java/coffeemeet/server/certification/service/CertificationServiceTest.java index a23bb7fb..0010e90e 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.common.media.EmailService; -import coffeemeet.server.common.media.S3MediaService; +import coffeemeet.server.certification.implement.CertificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationCommand; +import coffeemeet.server.certification.implement.EmailVerificationQuery; +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.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 S3MediaService s3MediaService; + private MediaManager mediaManager; + @Mock - private EmailService emailService; + private EmailSender emailSender; + @Mock private UserQuery userQuery; + @Mock private CertificationCommand certificationCommand; + @Mock private EmailVerificationCommand emailVerificationCommand; + @Mock private EmailVerificationQuery emailVerificationQuery; @@ -64,16 +70,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 +98,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()); } 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..5be41d1d 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/SignupDtoFixture.java @@ -2,16 +2,16 @@ 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.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 a045adf8..1a52310f 100644 --- a/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/dto/UpdateProfileDtoFixture.java @@ -2,16 +2,16 @@ 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.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 ee66d5ad..90d0e2a9 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.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 new file mode 100644 index 00000000..a120eb41 --- /dev/null +++ b/src/test/java/coffeemeet/server/common/implement/EmailSenderTest.java @@ -0,0 +1,64 @@ +package coffeemeet.server.common.implement; + +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 java.util.Objects; +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(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 new file mode 100644 index 00000000..2f6dee27 --- /dev/null +++ b/src/test/java/coffeemeet/server/common/implement/S3MediaManagerTest.java @@ -0,0 +1,108 @@ +package coffeemeet.server.common.implement; + +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 coffeemeet.server.common.domain.KeyType; +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/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..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 @@ -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.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..4579d1e6 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.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 9e2cd8e2..74b06510 100644 --- a/src/test/java/coffeemeet/server/user/service/UserServiceTest.java +++ b/src/test/java/coffeemeet/server/user/service/UserServiceTest.java @@ -1,11 +1,12 @@ 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.media.S3MediaService.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.S3MediaService; -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.common.implement.MediaManager; +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.SignupHTTP.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; @@ -62,10 +62,10 @@ class UserServiceTest { private UserService userService; @Mock - private S3MediaService s3MediaService; + 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); @@ -224,8 +222,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); @@ -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(); } }