From bfa1ab6bd2e0ba676ec7cedeaa3de5ed5941b6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=A0=EC=B0=AC=EA=B7=9C=28Shin=20Changyu=29?= <63400830+scv1702@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:40:52 +0900 Subject: [PATCH] =?UTF-8?q?GETP-196=20refactor:=20member=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=ED=8F=AC=ED=8A=B8-=EC=96=B4?= =?UTF-8?q?=EB=8C=91=ED=84=B0=20=EC=95=84=ED=82=A4=ED=85=8D=EC=B2=98=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9=20(#128)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * GETP-196 refactor: member 컴포넌트의 application layer가 out port에 의존하도록 변경 * GETP-196 refactor: member 도메인 모델과 jpa 모델을 분리 * GETP-196 rename: member 컴포넌트의 application layer를 application.member 패키지로 이동 * GETP-196 refactor: member 컴포넌트의 web adapter가 application layer의 port에 의존하도록 변경 --- .../api/controller/auth/SignUpController.java | 2 +- .../request/ServiceTermAgreementRequest.java | 2 +- .../auth/dto/request/SignUpRequest.java | 10 +- .../dto/request/EditMyClientRequest.java | 10 +- .../dto/request/RegisterMyClientRequest.java | 10 +- .../client/query/dto/ClientResponse.java | 4 +- .../member/command/MyMemberController.java | 12 +- .../member/query/MyMemberQueryController.java | 2 +- .../query/dto/response/MemberResponse.java | 10 +- .../dto/request/CreatePeopleRequest.java | 10 +- .../dto/request/UpdatePeopleRequest.java | 10 +- .../dto/request/ScheduleMeetingRequest.java | 2 +- .../ProjectApplicantQueryController.java | 2 +- .../security/details/PrincipalDetails.java | 2 +- .../details/PrincipalDetailsService.java | 14 +- .../validation}/EmailPattern.java | 4 +- .../validation}/PhoneNumberPattern.java | 4 +- .../validation}/UserMemberType.java | 2 +- .../validation}/UserMemberTypeValidator.java | 4 +- .../command/ChangeProfileImageCommand.java | 9 ++ .../member/command/EditMemberCommand.java} | 24 +-- .../port/in/ChangeProfileImageUseCase.java | 8 + .../member/port/in/EditMemberUseCase.java | 8 + .../member/port/out/CheckMemberPort.java | 8 + .../member/port/out/LoadMemberPort.java | 11 ++ .../member/port/out/SaveMemberPort.java | 8 + .../member/port/out/UpdateMemberPort.java | 8 + .../member/service/MemberService.java | 51 ++++++ .../getp/common/infra/PhoneNumberMapper.java | 2 +- .../auth/application/AccessTokenService.java | 6 +- .../domain/auth/application/AuthService.java | 2 +- .../auth/application/JwtTokenService.java | 14 +- .../auth/application/RefreshTokenService.java | 6 +- .../auth/application/SignUpService.java | 27 ++-- .../domain/auth/application/TokenFactory.java | 2 +- .../application/VerificationCodeSender.java | 2 +- .../auth/application/VerificationService.java | 2 +- .../application/command/SignUpCommand.java | 8 +- .../infra/EmailVerificationCodeSender.java | 2 +- .../command/application/ClientService.java | 24 +-- .../command/EditClientCommand.java | 6 +- .../command/RegisterClientCommand.java | 6 +- .../domain/client/command/domain/Client.java | 2 +- .../client/query/dao/ClientQueryDslDao.java | 34 ++-- .../ServiceTermAgreementCommand.java | 2 +- .../command/application/MemberService.java | 79 ---------- .../command/CreateMemberCommand.java | 26 ---- .../domain/model/MemberRepository.java | 11 -- .../member/command/domain/model/Nickname.java | 33 ---- .../command/domain/model/ProfileImage.java | 33 ---- .../domain/model/ServiceTermAgreement.java | 40 ----- .../exception/AlreadyUsedEmailException.java | 2 +- .../FailedToSaveProfileImageException.java | 2 +- .../ServiceTermAgreementServiceImpl.java | 12 +- .../{command/domain => }/model/Email.java | 11 +- .../{command/domain => }/model/Member.java | 51 +----- .../domain => }/model/MemberType.java | 2 +- .../getp/domain/member/model/Nickname.java | 28 ++++ .../{command/domain => }/model/Password.java | 24 +-- .../domain => }/model/PhoneNumber.java | 17 +- .../domain/member/model/ProfileImage.java | 28 ++++ .../member/model/ServiceTermAgreement.java | 25 +++ .../service/ProfileImageService.java | 10 +- .../service/ServiceTermAgreementService.java | 6 +- .../command/application/PeopleMapper.java | 2 +- .../command/application/PeopleService.java | 12 +- .../command/CreatePeopleCommand.java | 6 +- .../command/UpdatePeopleCommand.java | 6 +- .../domain/people/command/domain/People.java | 2 +- .../people/command/domain/PeopleInfo.java | 2 +- .../people/query/dao/PeopleQueryDslDao.java | 44 +++--- .../command/ScheduleMeetingCommand.java | 2 +- .../command/domain/ProjectMeeting.java | 2 +- .../domain/ProjectMeetingScheduler.java | 2 +- .../application/ProjectApplicantService.java | 2 +- .../dao/ProjectApplicantQueryDslDao.java | 16 +- .../project/query/dao/ProjectQueryDslDao.java | 14 +- .../domain/ServiceTermChecker.java | 2 +- .../serviceTerm/domain/ServiceTermTag.java | 6 +- .../infra/ServiceTermCheckerImpl.java | 2 +- .../getp/mail/command/SendMailCommand.java | 2 +- .../adapter/member/MemberJpaEntity.java | 54 +++++++ .../adapter/member/MemberJpaRepository.java | 12 ++ .../member/MemberPersistenceAdapter.java | 52 +++++++ .../member/MemberPersistenceMapper.java | 30 ++++ .../member}/NotFoundMemberException.java | 2 +- .../member/ServiceTermAgreementJpaVO.java | 29 ++++ .../getp/api/controller/ControllerTest.java | 2 +- .../controller/auth/SignUpControllerTest.java | 2 +- .../command/MyClientControllerTest.java | 2 +- .../query/ClientQueryControllerTest.java | 10 +- .../query/MyClientQueryControllerTest.java | 4 +- .../command/PeopleLikeControllerTest.java | 2 +- .../command/ProjectLikeControllerTest.java | 2 +- .../command/MyMemberControllerTest.java | 13 +- .../query/MyMemberQueryControllerTest.java | 2 +- .../command/MyPeopleControllerTest.java | 4 +- .../MyPeopleProfileControllerTest.java | 4 +- .../MyPeopleProfileQueryControllerTest.java | 4 +- .../query/MyPeopleQueryControllerTest.java | 6 +- .../query/PeopleQueryControllerTest.java | 8 +- .../ProjectApplicationControllerTest.java | 2 +- .../ProjectCommissionControllerTest.java | 2 +- .../command/ProjectMeetingControllerTest.java | 2 +- .../AppliedProjectQueryControllerTest.java | 2 +- ...ommissionedProjectQueryControllerTest.java | 2 +- .../ProjectApplicantQueryControllerTest.java | 6 +- .../annotation/WithCustomMockUser.java | 4 +- ...hCustomMockUserSecurityContextFactory.java | 2 +- .../auth/application/SignUpServiceTest.java | 111 ------------- .../application/VerificationServiceTest.java | 2 +- .../fixture/EmailVerificationFixture.java | 2 +- .../application/ClientServiceTest.java | 146 ------------------ .../client/query/infra/ClientDataLoader.java | 19 ++- .../application/MemberServiceTest.java | 127 --------------- .../domain/member/fixture/EmailFixture.java | 2 +- .../domain/member/fixture/MemberFixture.java | 6 +- .../member/fixture/NicknameFixture.java | 2 +- .../member/fixture/PasswordFixture.java | 2 +- .../member/fixture/PhoneNumberFixture.java | 2 +- .../member/fixture/ProfileImageFixture.java | 2 +- .../infra/SimplePasswordEncoder.java | 2 +- .../{command/domain => }/model/EmailTest.java | 2 +- .../domain => }/model/MemberTest.java | 2 +- .../domain => }/model/PasswordTest.java | 4 +- .../people/query/infra/PeopleDataLoader.java | 19 ++- 126 files changed, 708 insertions(+), 972 deletions(-) rename src/main/java/es/princip/getp/{domain/member/command/annotation => api/validation}/EmailPattern.java (84%) rename src/main/java/es/princip/getp/{domain/member/command/annotation => api/validation}/PhoneNumberPattern.java (84%) rename src/main/java/es/princip/getp/{domain/member/command/annotation => api/validation}/UserMemberType.java (89%) rename src/main/java/es/princip/getp/{domain/member/command/annotation => api/validation}/UserMemberTypeValidator.java (78%) create mode 100644 src/main/java/es/princip/getp/application/member/command/ChangeProfileImageCommand.java rename src/main/java/es/princip/getp/{domain/member/command/application/command/UpdateMemberCommand.java => application/member/command/EditMemberCommand.java} (56%) create mode 100644 src/main/java/es/princip/getp/application/member/port/in/ChangeProfileImageUseCase.java create mode 100644 src/main/java/es/princip/getp/application/member/port/in/EditMemberUseCase.java create mode 100644 src/main/java/es/princip/getp/application/member/port/out/CheckMemberPort.java create mode 100644 src/main/java/es/princip/getp/application/member/port/out/LoadMemberPort.java create mode 100644 src/main/java/es/princip/getp/application/member/port/out/SaveMemberPort.java create mode 100644 src/main/java/es/princip/getp/application/member/port/out/UpdateMemberPort.java create mode 100644 src/main/java/es/princip/getp/application/member/service/MemberService.java rename src/main/java/es/princip/getp/domain/member/command/{domain/command => }/ServiceTermAgreementCommand.java (71%) delete mode 100644 src/main/java/es/princip/getp/domain/member/command/application/MemberService.java delete mode 100644 src/main/java/es/princip/getp/domain/member/command/application/command/CreateMemberCommand.java delete mode 100644 src/main/java/es/princip/getp/domain/member/command/domain/model/MemberRepository.java delete mode 100644 src/main/java/es/princip/getp/domain/member/command/domain/model/Nickname.java delete mode 100644 src/main/java/es/princip/getp/domain/member/command/domain/model/ProfileImage.java delete mode 100644 src/main/java/es/princip/getp/domain/member/command/domain/model/ServiceTermAgreement.java rename src/main/java/es/princip/getp/domain/member/{command => }/exception/AlreadyUsedEmailException.java (88%) rename src/main/java/es/princip/getp/domain/member/{command => }/exception/FailedToSaveProfileImageException.java (90%) rename src/main/java/es/princip/getp/domain/member/{command => }/infra/ServiceTermAgreementServiceImpl.java (75%) rename src/main/java/es/princip/getp/domain/member/{command/domain => }/model/Email.java (85%) rename src/main/java/es/princip/getp/domain/member/{command/domain => }/model/Member.java (73%) rename src/main/java/es/princip/getp/domain/member/{command/domain => }/model/MemberType.java (90%) create mode 100644 src/main/java/es/princip/getp/domain/member/model/Nickname.java rename src/main/java/es/princip/getp/domain/member/{command/domain => }/model/Password.java (72%) rename src/main/java/es/princip/getp/domain/member/{command/domain => }/model/PhoneNumber.java (62%) create mode 100644 src/main/java/es/princip/getp/domain/member/model/ProfileImage.java create mode 100644 src/main/java/es/princip/getp/domain/member/model/ServiceTermAgreement.java rename src/main/java/es/princip/getp/domain/member/{command/domain => }/service/ProfileImageService.java (83%) rename src/main/java/es/princip/getp/domain/member/{command/domain => }/service/ServiceTermAgreementService.java (68%) create mode 100644 src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaEntity.java create mode 100644 src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaRepository.java create mode 100644 src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceAdapter.java create mode 100644 src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceMapper.java rename src/main/java/es/princip/getp/{domain/member/command/exception => persistence/adapter/member}/NotFoundMemberException.java (88%) create mode 100644 src/main/java/es/princip/getp/persistence/adapter/member/ServiceTermAgreementJpaVO.java delete mode 100644 src/test/java/es/princip/getp/domain/auth/application/SignUpServiceTest.java delete mode 100644 src/test/java/es/princip/getp/domain/client/command/application/ClientServiceTest.java delete mode 100644 src/test/java/es/princip/getp/domain/member/command/application/MemberServiceTest.java rename src/test/java/es/princip/getp/domain/member/{command => }/infra/SimplePasswordEncoder.java (88%) rename src/test/java/es/princip/getp/domain/member/{command/domain => }/model/EmailTest.java (95%) rename src/test/java/es/princip/getp/domain/member/{command/domain => }/model/MemberTest.java (97%) rename src/test/java/es/princip/getp/domain/member/{command/domain => }/model/PasswordTest.java (95%) diff --git a/src/main/java/es/princip/getp/api/controller/auth/SignUpController.java b/src/main/java/es/princip/getp/api/controller/auth/SignUpController.java index 841afb72..80ed6d52 100644 --- a/src/main/java/es/princip/getp/api/controller/auth/SignUpController.java +++ b/src/main/java/es/princip/getp/api/controller/auth/SignUpController.java @@ -6,7 +6,7 @@ import es.princip.getp.api.controller.ApiResponse.ApiSuccessResult; import es.princip.getp.domain.auth.application.SignUpService; import es.princip.getp.domain.auth.application.command.SignUpCommand; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; diff --git a/src/main/java/es/princip/getp/api/controller/auth/dto/request/ServiceTermAgreementRequest.java b/src/main/java/es/princip/getp/api/controller/auth/dto/request/ServiceTermAgreementRequest.java index b7eed39f..2d4d91f4 100644 --- a/src/main/java/es/princip/getp/api/controller/auth/dto/request/ServiceTermAgreementRequest.java +++ b/src/main/java/es/princip/getp/api/controller/auth/dto/request/ServiceTermAgreementRequest.java @@ -1,6 +1,6 @@ package es.princip.getp.api.controller.auth.dto.request; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; +import es.princip.getp.domain.member.command.ServiceTermAgreementCommand; import es.princip.getp.domain.serviceTerm.domain.ServiceTermTag; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/es/princip/getp/api/controller/auth/dto/request/SignUpRequest.java b/src/main/java/es/princip/getp/api/controller/auth/dto/request/SignUpRequest.java index ddfde793..9df047cb 100644 --- a/src/main/java/es/princip/getp/api/controller/auth/dto/request/SignUpRequest.java +++ b/src/main/java/es/princip/getp/api/controller/auth/dto/request/SignUpRequest.java @@ -1,11 +1,11 @@ package es.princip.getp.api.controller.auth.dto.request; import es.princip.getp.domain.auth.application.command.SignUpCommand; -import es.princip.getp.domain.member.command.annotation.UserMemberType; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.MemberType; -import es.princip.getp.domain.member.command.domain.model.Password; +import es.princip.getp.api.validation.UserMemberType; +import es.princip.getp.domain.member.command.ServiceTermAgreementCommand; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.MemberType; +import es.princip.getp.domain.member.model.Password; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/es/princip/getp/api/controller/client/command/dto/request/EditMyClientRequest.java b/src/main/java/es/princip/getp/api/controller/client/command/dto/request/EditMyClientRequest.java index f92e0985..f10aec32 100644 --- a/src/main/java/es/princip/getp/api/controller/client/command/dto/request/EditMyClientRequest.java +++ b/src/main/java/es/princip/getp/api/controller/client/command/dto/request/EditMyClientRequest.java @@ -3,11 +3,11 @@ import es.princip.getp.domain.client.command.application.command.EditClientCommand; import es.princip.getp.domain.client.command.domain.Address; import es.princip.getp.domain.client.command.domain.BankAccount; -import es.princip.getp.domain.member.command.annotation.EmailPattern; -import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.api.validation.EmailPattern; +import es.princip.getp.api.validation.PhoneNumberPattern; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/es/princip/getp/api/controller/client/command/dto/request/RegisterMyClientRequest.java b/src/main/java/es/princip/getp/api/controller/client/command/dto/request/RegisterMyClientRequest.java index e275c0a1..fc090aa5 100644 --- a/src/main/java/es/princip/getp/api/controller/client/command/dto/request/RegisterMyClientRequest.java +++ b/src/main/java/es/princip/getp/api/controller/client/command/dto/request/RegisterMyClientRequest.java @@ -3,11 +3,11 @@ import es.princip.getp.domain.client.command.application.command.RegisterClientCommand; import es.princip.getp.domain.client.command.domain.Address; import es.princip.getp.domain.client.command.domain.BankAccount; -import es.princip.getp.domain.member.command.annotation.EmailPattern; -import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.api.validation.EmailPattern; +import es.princip.getp.api.validation.PhoneNumberPattern; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; import jakarta.validation.Valid; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/es/princip/getp/api/controller/client/query/dto/ClientResponse.java b/src/main/java/es/princip/getp/api/controller/client/query/dto/ClientResponse.java index 7aaa80e8..14ab6873 100644 --- a/src/main/java/es/princip/getp/api/controller/client/query/dto/ClientResponse.java +++ b/src/main/java/es/princip/getp/api/controller/client/query/dto/ClientResponse.java @@ -3,7 +3,7 @@ import es.princip.getp.domain.client.command.domain.Address; import es.princip.getp.domain.client.command.domain.BankAccount; import es.princip.getp.domain.client.command.domain.Client; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.Member; import java.time.LocalDateTime; @@ -25,7 +25,7 @@ public static ClientResponse of(final Client client, final Member member) { member.getNickname().getValue(), client.getEmail().getValue(), member.getPhoneNumber().getValue(), - member.getProfileImage().getUri(), + member.getProfileImage().getUrl(), client.getAddress(), client.getBankAccount(), client.getCreatedAt(), diff --git a/src/main/java/es/princip/getp/api/controller/member/command/MyMemberController.java b/src/main/java/es/princip/getp/api/controller/member/command/MyMemberController.java index c6024365..f52af552 100644 --- a/src/main/java/es/princip/getp/api/controller/member/command/MyMemberController.java +++ b/src/main/java/es/princip/getp/api/controller/member/command/MyMemberController.java @@ -2,9 +2,10 @@ import es.princip.getp.api.controller.ApiResponse; import es.princip.getp.api.controller.ApiResponse.ApiSuccessResult; -import es.princip.getp.api.security.details.PrincipalDetails; import es.princip.getp.api.controller.member.command.dto.response.ProfileImageResponse; -import es.princip.getp.domain.member.command.application.MemberService; +import es.princip.getp.api.security.details.PrincipalDetails; +import es.princip.getp.application.member.command.ChangeProfileImageCommand; +import es.princip.getp.application.member.port.in.ChangeProfileImageUseCase; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -17,11 +18,11 @@ import org.springframework.web.multipart.MultipartFile; @RestController -@RequestMapping("/member/me") @RequiredArgsConstructor +@RequestMapping("/member/me") public class MyMemberController { - private final MemberService memberService; + private final ChangeProfileImageUseCase changeProfileImageUseCase; /** * 내 프로필 이미지 등록 @@ -37,7 +38,8 @@ public ResponseEntity> uploadProfileImage @RequestPart final MultipartFile image ) { final Long memberId = principalDetails.getMember().getMemberId(); - final String profileImageUri = memberService.changeProfileImage(memberId, image); + final ChangeProfileImageCommand command = new ChangeProfileImageCommand(memberId, image); + final String profileImageUri = changeProfileImageUseCase.changeProfileImage(command); final ProfileImageResponse response = new ProfileImageResponse(profileImageUri); return ApiResponse.success(HttpStatus.CREATED, response); } diff --git a/src/main/java/es/princip/getp/api/controller/member/query/MyMemberQueryController.java b/src/main/java/es/princip/getp/api/controller/member/query/MyMemberQueryController.java index 839738c1..77111e94 100644 --- a/src/main/java/es/princip/getp/api/controller/member/query/MyMemberQueryController.java +++ b/src/main/java/es/princip/getp/api/controller/member/query/MyMemberQueryController.java @@ -3,7 +3,7 @@ import es.princip.getp.api.controller.ApiResponse; import es.princip.getp.api.security.details.PrincipalDetails; import es.princip.getp.api.controller.member.query.dto.response.MemberResponse; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.Member; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/es/princip/getp/api/controller/member/query/dto/response/MemberResponse.java b/src/main/java/es/princip/getp/api/controller/member/query/dto/response/MemberResponse.java index 93362278..56f621a3 100644 --- a/src/main/java/es/princip/getp/api/controller/member/query/dto/response/MemberResponse.java +++ b/src/main/java/es/princip/getp/api/controller/member/query/dto/response/MemberResponse.java @@ -1,9 +1,9 @@ package es.princip.getp.api.controller.member.query.dto.response; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberType; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.ProfileImage; +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.model.MemberType; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.ProfileImage; import java.time.LocalDateTime; import java.util.Optional; @@ -25,7 +25,7 @@ public static MemberResponse from(final Member member) { .map(Nickname::getValue) .orElse(null), Optional.ofNullable(member.getProfileImage()) - .map(ProfileImage::getUri) + .map(ProfileImage::getUrl) .orElse(null), member.getMemberType(), member.getCreatedAt(), diff --git a/src/main/java/es/princip/getp/api/controller/people/command/dto/request/CreatePeopleRequest.java b/src/main/java/es/princip/getp/api/controller/people/command/dto/request/CreatePeopleRequest.java index 5f55e49c..718f7ee8 100644 --- a/src/main/java/es/princip/getp/api/controller/people/command/dto/request/CreatePeopleRequest.java +++ b/src/main/java/es/princip/getp/api/controller/people/command/dto/request/CreatePeopleRequest.java @@ -1,11 +1,11 @@ package es.princip.getp.api.controller.people.command.dto.request; import es.princip.getp.common.annotation.Enum; -import es.princip.getp.domain.member.command.annotation.EmailPattern; -import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.api.validation.EmailPattern; +import es.princip.getp.api.validation.PhoneNumberPattern; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; import es.princip.getp.domain.people.command.application.command.CreatePeopleCommand; import es.princip.getp.domain.people.command.domain.PeopleType; import jakarta.validation.constraints.NotBlank; diff --git a/src/main/java/es/princip/getp/api/controller/people/command/dto/request/UpdatePeopleRequest.java b/src/main/java/es/princip/getp/api/controller/people/command/dto/request/UpdatePeopleRequest.java index 7154c1d2..895394ab 100644 --- a/src/main/java/es/princip/getp/api/controller/people/command/dto/request/UpdatePeopleRequest.java +++ b/src/main/java/es/princip/getp/api/controller/people/command/dto/request/UpdatePeopleRequest.java @@ -1,11 +1,11 @@ package es.princip.getp.api.controller.people.command.dto.request; import es.princip.getp.common.annotation.Enum; -import es.princip.getp.domain.member.command.annotation.EmailPattern; -import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.api.validation.EmailPattern; +import es.princip.getp.api.validation.PhoneNumberPattern; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; import es.princip.getp.domain.people.command.application.command.UpdatePeopleCommand; import es.princip.getp.domain.people.command.domain.PeopleType; import jakarta.validation.constraints.NotBlank; diff --git a/src/main/java/es/princip/getp/api/controller/project/command/dto/request/ScheduleMeetingRequest.java b/src/main/java/es/princip/getp/api/controller/project/command/dto/request/ScheduleMeetingRequest.java index b39b46d5..8e9eba73 100644 --- a/src/main/java/es/princip/getp/api/controller/project/command/dto/request/ScheduleMeetingRequest.java +++ b/src/main/java/es/princip/getp/api/controller/project/command/dto/request/ScheduleMeetingRequest.java @@ -1,7 +1,7 @@ package es.princip.getp.api.controller.project.command.dto.request; import es.princip.getp.common.domain.MeetingSchedule; -import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern; +import es.princip.getp.api.validation.PhoneNumberPattern; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryController.java b/src/main/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryController.java index f10d5d42..f8843448 100644 --- a/src/main/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryController.java +++ b/src/main/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryController.java @@ -5,7 +5,7 @@ import es.princip.getp.api.controller.PageResponse; import es.princip.getp.api.security.details.PrincipalDetails; import es.princip.getp.api.controller.people.query.dto.people.DetailPeopleResponse; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.Member; import es.princip.getp.domain.project.query.application.ProjectApplicantService; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; diff --git a/src/main/java/es/princip/getp/api/security/details/PrincipalDetails.java b/src/main/java/es/princip/getp/api/security/details/PrincipalDetails.java index 98417991..446d5d50 100644 --- a/src/main/java/es/princip/getp/api/security/details/PrincipalDetails.java +++ b/src/main/java/es/princip/getp/api/security/details/PrincipalDetails.java @@ -1,6 +1,6 @@ package es.princip.getp.api.security.details; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.Member; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; diff --git a/src/main/java/es/princip/getp/api/security/details/PrincipalDetailsService.java b/src/main/java/es/princip/getp/api/security/details/PrincipalDetailsService.java index b00ba8ed..4e0fc1a6 100644 --- a/src/main/java/es/princip/getp/api/security/details/PrincipalDetailsService.java +++ b/src/main/java/es/princip/getp/api/security/details/PrincipalDetailsService.java @@ -1,8 +1,7 @@ package es.princip.getp.api.security.details; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; +import es.princip.getp.application.member.port.out.LoadMemberPort; +import es.princip.getp.domain.member.model.Email; import lombok.RequiredArgsConstructor; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; @@ -12,12 +11,11 @@ @Service @RequiredArgsConstructor public class PrincipalDetailsService implements UserDetailsService { - private final MemberRepository memberRepository; + + private final LoadMemberPort loadMemberPort; @Override - public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - Member member = memberRepository.findByEmail(Email.of(username)) - .orElseThrow(() -> new UsernameNotFoundException("User not found")); - return new PrincipalDetails(member); + public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException { + return new PrincipalDetails(loadMemberPort.loadBy(Email.of(username))); } } diff --git a/src/main/java/es/princip/getp/domain/member/command/annotation/EmailPattern.java b/src/main/java/es/princip/getp/api/validation/EmailPattern.java similarity index 84% rename from src/main/java/es/princip/getp/domain/member/command/annotation/EmailPattern.java rename to src/main/java/es/princip/getp/api/validation/EmailPattern.java index 222f78f1..497d341e 100644 --- a/src/main/java/es/princip/getp/domain/member/command/annotation/EmailPattern.java +++ b/src/main/java/es/princip/getp/api/validation/EmailPattern.java @@ -1,6 +1,6 @@ -package es.princip.getp.domain.member.command.annotation; +package es.princip.getp.api.validation; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import jakarta.validation.Constraint; import jakarta.validation.constraints.Pattern; diff --git a/src/main/java/es/princip/getp/domain/member/command/annotation/PhoneNumberPattern.java b/src/main/java/es/princip/getp/api/validation/PhoneNumberPattern.java similarity index 84% rename from src/main/java/es/princip/getp/domain/member/command/annotation/PhoneNumberPattern.java rename to src/main/java/es/princip/getp/api/validation/PhoneNumberPattern.java index 81fe3676..713f2317 100644 --- a/src/main/java/es/princip/getp/domain/member/command/annotation/PhoneNumberPattern.java +++ b/src/main/java/es/princip/getp/api/validation/PhoneNumberPattern.java @@ -1,6 +1,6 @@ -package es.princip.getp.domain.member.command.annotation; +package es.princip.getp.api.validation; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.PhoneNumber; import jakarta.validation.Constraint; import jakarta.validation.constraints.Pattern; diff --git a/src/main/java/es/princip/getp/domain/member/command/annotation/UserMemberType.java b/src/main/java/es/princip/getp/api/validation/UserMemberType.java similarity index 89% rename from src/main/java/es/princip/getp/domain/member/command/annotation/UserMemberType.java rename to src/main/java/es/princip/getp/api/validation/UserMemberType.java index 6c69060b..a65ebefe 100644 --- a/src/main/java/es/princip/getp/domain/member/command/annotation/UserMemberType.java +++ b/src/main/java/es/princip/getp/api/validation/UserMemberType.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.annotation; +package es.princip.getp.api.validation; import jakarta.validation.Constraint; diff --git a/src/main/java/es/princip/getp/domain/member/command/annotation/UserMemberTypeValidator.java b/src/main/java/es/princip/getp/api/validation/UserMemberTypeValidator.java similarity index 78% rename from src/main/java/es/princip/getp/domain/member/command/annotation/UserMemberTypeValidator.java rename to src/main/java/es/princip/getp/api/validation/UserMemberTypeValidator.java index 6bf333fe..d835aec2 100644 --- a/src/main/java/es/princip/getp/domain/member/command/annotation/UserMemberTypeValidator.java +++ b/src/main/java/es/princip/getp/api/validation/UserMemberTypeValidator.java @@ -1,6 +1,6 @@ -package es.princip.getp.domain.member.command.annotation; +package es.princip.getp.api.validation; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; diff --git a/src/main/java/es/princip/getp/application/member/command/ChangeProfileImageCommand.java b/src/main/java/es/princip/getp/application/member/command/ChangeProfileImageCommand.java new file mode 100644 index 00000000..0f677db8 --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/command/ChangeProfileImageCommand.java @@ -0,0 +1,9 @@ +package es.princip.getp.application.member.command; + +import org.springframework.web.multipart.MultipartFile; + +public record ChangeProfileImageCommand( + Long memberId, + MultipartFile image +) { +} diff --git a/src/main/java/es/princip/getp/domain/member/command/application/command/UpdateMemberCommand.java b/src/main/java/es/princip/getp/application/member/command/EditMemberCommand.java similarity index 56% rename from src/main/java/es/princip/getp/domain/member/command/application/command/UpdateMemberCommand.java rename to src/main/java/es/princip/getp/application/member/command/EditMemberCommand.java index d1feb6d3..9b13d53a 100644 --- a/src/main/java/es/princip/getp/domain/member/command/application/command/UpdateMemberCommand.java +++ b/src/main/java/es/princip/getp/application/member/command/EditMemberCommand.java @@ -1,43 +1,43 @@ -package es.princip.getp.domain.member.command.application.command; +package es.princip.getp.application.member.command; import es.princip.getp.domain.client.command.application.command.EditClientCommand; import es.princip.getp.domain.client.command.application.command.RegisterClientCommand; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; import es.princip.getp.domain.people.command.application.command.CreatePeopleCommand; import es.princip.getp.domain.people.command.application.command.UpdatePeopleCommand; -public record UpdateMemberCommand( +public record EditMemberCommand( Long memberId, Nickname nickname, PhoneNumber phoneNumber ) { - public static UpdateMemberCommand from(final CreatePeopleCommand command) { - return new UpdateMemberCommand( + public static EditMemberCommand from(final CreatePeopleCommand command) { + return new EditMemberCommand( command.memberId(), command.nickname(), command.phoneNumber() ); } - public static UpdateMemberCommand from(final UpdatePeopleCommand command) { - return new UpdateMemberCommand( + public static EditMemberCommand from(final UpdatePeopleCommand command) { + return new EditMemberCommand( command.memberId(), command.nickname(), command.phoneNumber() ); } - public static UpdateMemberCommand from(final RegisterClientCommand command) { - return new UpdateMemberCommand( + public static EditMemberCommand from(final RegisterClientCommand command) { + return new EditMemberCommand( command.memberId(), command.nickname(), command.phoneNumber() ); } - public static UpdateMemberCommand from(final EditClientCommand command) { - return new UpdateMemberCommand( + public static EditMemberCommand from(final EditClientCommand command) { + return new EditMemberCommand( command.memberId(), command.nickname(), command.phoneNumber() diff --git a/src/main/java/es/princip/getp/application/member/port/in/ChangeProfileImageUseCase.java b/src/main/java/es/princip/getp/application/member/port/in/ChangeProfileImageUseCase.java new file mode 100644 index 00000000..aee1cec8 --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/port/in/ChangeProfileImageUseCase.java @@ -0,0 +1,8 @@ +package es.princip.getp.application.member.port.in; + +import es.princip.getp.application.member.command.ChangeProfileImageCommand; + +public interface ChangeProfileImageUseCase { + + String changeProfileImage(ChangeProfileImageCommand command); +} diff --git a/src/main/java/es/princip/getp/application/member/port/in/EditMemberUseCase.java b/src/main/java/es/princip/getp/application/member/port/in/EditMemberUseCase.java new file mode 100644 index 00000000..83c70cd0 --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/port/in/EditMemberUseCase.java @@ -0,0 +1,8 @@ +package es.princip.getp.application.member.port.in; + +import es.princip.getp.application.member.command.EditMemberCommand; + +public interface EditMemberUseCase { + + void editMember(EditMemberCommand command); +} diff --git a/src/main/java/es/princip/getp/application/member/port/out/CheckMemberPort.java b/src/main/java/es/princip/getp/application/member/port/out/CheckMemberPort.java new file mode 100644 index 00000000..0f342e2a --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/port/out/CheckMemberPort.java @@ -0,0 +1,8 @@ +package es.princip.getp.application.member.port.out; + +import es.princip.getp.domain.member.model.Email; + +public interface CheckMemberPort { + + boolean existsByEmail(Email email); +} diff --git a/src/main/java/es/princip/getp/application/member/port/out/LoadMemberPort.java b/src/main/java/es/princip/getp/application/member/port/out/LoadMemberPort.java new file mode 100644 index 00000000..b6897c55 --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/port/out/LoadMemberPort.java @@ -0,0 +1,11 @@ +package es.princip.getp.application.member.port.out; + +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Member; + +public interface LoadMemberPort { + + Member loadBy(Email email); + + Member loadBy(Long id); +} diff --git a/src/main/java/es/princip/getp/application/member/port/out/SaveMemberPort.java b/src/main/java/es/princip/getp/application/member/port/out/SaveMemberPort.java new file mode 100644 index 00000000..e2c2e667 --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/port/out/SaveMemberPort.java @@ -0,0 +1,8 @@ +package es.princip.getp.application.member.port.out; + +import es.princip.getp.domain.member.model.Member; + +public interface SaveMemberPort { + + Long save(Member member); +} diff --git a/src/main/java/es/princip/getp/application/member/port/out/UpdateMemberPort.java b/src/main/java/es/princip/getp/application/member/port/out/UpdateMemberPort.java new file mode 100644 index 00000000..7e6bd4c5 --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/port/out/UpdateMemberPort.java @@ -0,0 +1,8 @@ +package es.princip.getp.application.member.port.out; + +import es.princip.getp.domain.member.model.Member; + +public interface UpdateMemberPort { + + void update(Member member); +} diff --git a/src/main/java/es/princip/getp/application/member/service/MemberService.java b/src/main/java/es/princip/getp/application/member/service/MemberService.java new file mode 100644 index 00000000..51bf5156 --- /dev/null +++ b/src/main/java/es/princip/getp/application/member/service/MemberService.java @@ -0,0 +1,51 @@ +package es.princip.getp.application.member.service; + +import es.princip.getp.application.member.command.ChangeProfileImageCommand; +import es.princip.getp.application.member.command.EditMemberCommand; +import es.princip.getp.application.member.port.in.ChangeProfileImageUseCase; +import es.princip.getp.application.member.port.in.EditMemberUseCase; +import es.princip.getp.application.member.port.out.LoadMemberPort; +import es.princip.getp.application.member.port.out.UpdateMemberPort; +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.model.ProfileImage; +import es.princip.getp.domain.member.service.ProfileImageService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +@Slf4j +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class MemberService implements EditMemberUseCase, ChangeProfileImageUseCase { + + private final ProfileImageService profileImageService; + + private final UpdateMemberPort updateMemberPort; + private final LoadMemberPort loadMemberPort; + + @Override + @Transactional + public void editMember(final EditMemberCommand command) { + final Member member = loadMemberPort.loadBy(command.memberId()); + member.edit(command.nickname(), command.phoneNumber()); + updateMemberPort.update(member); + } + + @Override + @Transactional + public String changeProfileImage(final ChangeProfileImageCommand command) { + final Long memberId = command.memberId(); + final MultipartFile image = command.image(); + final Member member = loadMemberPort.loadBy(memberId); + if (member.hasProfileImage()) { + profileImageService.deleteProfileImage(member.getProfileImage()); + } + ProfileImage profileImage = profileImageService.saveProfileImage(member, image); + member.changeProfileImage(profileImage); + updateMemberPort.update(member); + return profileImage.getUrl(); + } +} diff --git a/src/main/java/es/princip/getp/common/infra/PhoneNumberMapper.java b/src/main/java/es/princip/getp/common/infra/PhoneNumberMapper.java index 4ca61d82..f36bfc1c 100644 --- a/src/main/java/es/princip/getp/common/infra/PhoneNumberMapper.java +++ b/src/main/java/es/princip/getp/common/infra/PhoneNumberMapper.java @@ -1,6 +1,6 @@ package es.princip.getp.common.infra; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.PhoneNumber; import org.mapstruct.Mapper; @Mapper(componentModel = "spring") diff --git a/src/main/java/es/princip/getp/domain/auth/application/AccessTokenService.java b/src/main/java/es/princip/getp/domain/auth/application/AccessTokenService.java index 84d99a6a..a1f97ecd 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/AccessTokenService.java +++ b/src/main/java/es/princip/getp/domain/auth/application/AccessTokenService.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.auth.application; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; +import es.princip.getp.application.member.port.out.LoadMemberPort; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -12,8 +12,8 @@ public class AccessTokenService extends JwtTokenService { public AccessTokenService( @Value("${spring.jwt.access-token.expire-time}") final Long expireTime, @Value("${spring.jwt.secret}") final String secretKey, - final MemberRepository memberRepository + final LoadMemberPort loadMemberPort ) { - super(expireTime, secretKey, "Access", "Authorization", memberRepository); + super(expireTime, secretKey, "Access", "Authorization", loadMemberPort); } } diff --git a/src/main/java/es/princip/getp/domain/auth/application/AuthService.java b/src/main/java/es/princip/getp/domain/auth/application/AuthService.java index 92072173..29c197fa 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/AuthService.java +++ b/src/main/java/es/princip/getp/domain/auth/application/AuthService.java @@ -4,7 +4,7 @@ import es.princip.getp.api.controller.auth.dto.response.Token; import es.princip.getp.api.security.details.PrincipalDetails; import es.princip.getp.domain.auth.exception.IncorrectEmailOrPasswordException; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.Member; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; diff --git a/src/main/java/es/princip/getp/domain/auth/application/JwtTokenService.java b/src/main/java/es/princip/getp/domain/auth/application/JwtTokenService.java index 58f57c9c..ffff61f8 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/JwtTokenService.java +++ b/src/main/java/es/princip/getp/domain/auth/application/JwtTokenService.java @@ -3,9 +3,9 @@ import es.princip.getp.api.security.details.PrincipalDetails; import es.princip.getp.api.security.exception.ExpiredTokenException; import es.princip.getp.api.security.exception.InvalidTokenException; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; +import es.princip.getp.application.member.port.out.LoadMemberPort; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Member; import io.jsonwebtoken.*; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; @@ -27,20 +27,20 @@ public abstract class JwtTokenService { protected final Key key; protected final String tokenType; protected final String header; - protected final MemberRepository memberRepository; + protected final LoadMemberPort loadMemberPort; protected JwtTokenService( final Long expireTime, final String secretKey, final String tokenType, final String header, - final MemberRepository memberRepository + final LoadMemberPort loadMemberPort ) { this.expireTime = expireTime; this.key = Keys.hmacShaKeyFor(Decoders.BASE64.decode(secretKey)); this.tokenType = tokenType; this.header = header; - this.memberRepository = memberRepository; + this.loadMemberPort = loadMemberPort; } /** @@ -70,7 +70,7 @@ public String generateJwtToken(final Member member) { public Authentication getAuthentication(final String token) { final Claims claims = validateAndParseToken(token); final Email email = Email.of(claims.getSubject()); - final Member member = memberRepository.findByEmail(email).orElseThrow(); + final Member member = loadMemberPort.loadBy(email); final PrincipalDetails principalDetails = new PrincipalDetails(member); return new UsernamePasswordAuthenticationToken(principalDetails, "", principalDetails.getAuthorities()); diff --git a/src/main/java/es/princip/getp/domain/auth/application/RefreshTokenService.java b/src/main/java/es/princip/getp/domain/auth/application/RefreshTokenService.java index c232046c..d1a3c714 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/RefreshTokenService.java +++ b/src/main/java/es/princip/getp/domain/auth/application/RefreshTokenService.java @@ -1,9 +1,9 @@ package es.princip.getp.domain.auth.application; import es.princip.getp.api.security.exception.InvalidTokenException; +import es.princip.getp.application.member.port.out.LoadMemberPort; import es.princip.getp.domain.auth.domain.RefreshToken; import es.princip.getp.domain.auth.domain.RefreshTokenRepository; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; import io.jsonwebtoken.Claims; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -20,10 +20,10 @@ public class RefreshTokenService extends JwtTokenService { public RefreshTokenService( @Value("${spring.jwt.refresh-token.expire-time}") final Long expireTime, @Value("${spring.jwt.secret}") final String secretKey, - final MemberRepository memberRepository, + final LoadMemberPort loadMemberPort, final RefreshTokenRepository refreshTokenRepository ) { - super(expireTime, secretKey,"Refresh", "Refresh-Token", memberRepository); + super(expireTime, secretKey,"Refresh", "Refresh-Token", loadMemberPort); this.refreshTokenRepository = refreshTokenRepository; } diff --git a/src/main/java/es/princip/getp/domain/auth/application/SignUpService.java b/src/main/java/es/princip/getp/domain/auth/application/SignUpService.java index a538672d..02c1ebdf 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/SignUpService.java +++ b/src/main/java/es/princip/getp/domain/auth/application/SignUpService.java @@ -1,12 +1,13 @@ package es.princip.getp.domain.auth.application; +import es.princip.getp.application.member.port.out.CheckMemberPort; +import es.princip.getp.application.member.port.out.SaveMemberPort; import es.princip.getp.domain.auth.application.command.SignUpCommand; import es.princip.getp.domain.auth.exception.DuplicatedEmailException; -import es.princip.getp.domain.member.command.application.MemberService; -import es.princip.getp.domain.member.command.application.command.CreateMemberCommand; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.service.ServiceTermAgreementService; +import es.princip.getp.domain.member.exception.AlreadyUsedEmailException; import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; @@ -18,13 +19,16 @@ public class SignUpService { private final VerificationService emailVerificationService; - private final MemberRepository memberRepository; - private final MemberService memberService; + private final ServiceTermAgreementService agreementService; + + private final CheckMemberPort checkMemberPort; + private final SaveMemberPort saveMemberPort; + private final PasswordEncoder passwordEncoder; @Transactional public void sendEmailVerificationCodeForSignUp(final Email email) { - if (memberRepository.existsByEmail(email)) { + if (checkMemberPort.existsByEmail(email)) { throw new DuplicatedEmailException(); } emailVerificationService.sendVerificationCode(email); @@ -33,8 +37,11 @@ public void sendEmailVerificationCodeForSignUp(final Email email) { @Transactional public void signUp(final SignUpCommand command) { emailVerificationService.verifyEmail(command.email(), command.verificationCode()); - final Long memberId = memberService.create(CreateMemberCommand.from(command)); - final Member member = memberRepository.findById(memberId).orElseThrow(); + if (checkMemberPort.existsByEmail(command.email())) + throw new AlreadyUsedEmailException(); + final Member member = Member.of(command.email(), command.password(), command.memberType()); + agreementService.agreeServiceTerms(member, command.serviceTerms()); member.encodePassword(passwordEncoder); + saveMemberPort.save(member); } } diff --git a/src/main/java/es/princip/getp/domain/auth/application/TokenFactory.java b/src/main/java/es/princip/getp/domain/auth/application/TokenFactory.java index e945c9c8..cf38519a 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/TokenFactory.java +++ b/src/main/java/es/princip/getp/domain/auth/application/TokenFactory.java @@ -1,7 +1,7 @@ package es.princip.getp.domain.auth.application; import es.princip.getp.api.controller.auth.dto.response.Token; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.Member; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/src/main/java/es/princip/getp/domain/auth/application/VerificationCodeSender.java b/src/main/java/es/princip/getp/domain/auth/application/VerificationCodeSender.java index cfe0a525..10970934 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/VerificationCodeSender.java +++ b/src/main/java/es/princip/getp/domain/auth/application/VerificationCodeSender.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.auth.application; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; public interface VerificationCodeSender { void send(Email email, String verificationCode); diff --git a/src/main/java/es/princip/getp/domain/auth/application/VerificationService.java b/src/main/java/es/princip/getp/domain/auth/application/VerificationService.java index e0648edd..9d022835 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/VerificationService.java +++ b/src/main/java/es/princip/getp/domain/auth/application/VerificationService.java @@ -5,7 +5,7 @@ import es.princip.getp.domain.auth.domain.EmailVerificationRepository; import es.princip.getp.domain.auth.exception.IncorrectVerificationCodeException; import es.princip.getp.domain.auth.exception.NotFoundVerificationException; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/es/princip/getp/domain/auth/application/command/SignUpCommand.java b/src/main/java/es/princip/getp/domain/auth/application/command/SignUpCommand.java index 72b27dfe..e683a8dd 100644 --- a/src/main/java/es/princip/getp/domain/auth/application/command/SignUpCommand.java +++ b/src/main/java/es/princip/getp/domain/auth/application/command/SignUpCommand.java @@ -1,9 +1,9 @@ package es.princip.getp.domain.auth.application.command; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.MemberType; -import es.princip.getp.domain.member.command.domain.model.Password; +import es.princip.getp.domain.member.command.ServiceTermAgreementCommand; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.MemberType; +import es.princip.getp.domain.member.model.Password; import java.util.List; diff --git a/src/main/java/es/princip/getp/domain/auth/infra/EmailVerificationCodeSender.java b/src/main/java/es/princip/getp/domain/auth/infra/EmailVerificationCodeSender.java index d10b44ad..f3cd918b 100644 --- a/src/main/java/es/princip/getp/domain/auth/infra/EmailVerificationCodeSender.java +++ b/src/main/java/es/princip/getp/domain/auth/infra/EmailVerificationCodeSender.java @@ -2,7 +2,7 @@ import es.princip.getp.domain.auth.application.VerificationCodeSender; import es.princip.getp.domain.auth.exception.FailedVerificationCodeSendingException; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import es.princip.getp.mail.EmailSender; import es.princip.getp.mail.command.SendMailCommand; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/es/princip/getp/domain/client/command/application/ClientService.java b/src/main/java/es/princip/getp/domain/client/command/application/ClientService.java index 9612cc95..d532b435 100644 --- a/src/main/java/es/princip/getp/domain/client/command/application/ClientService.java +++ b/src/main/java/es/princip/getp/domain/client/command/application/ClientService.java @@ -1,14 +1,14 @@ package es.princip.getp.domain.client.command.application; +import es.princip.getp.application.member.command.EditMemberCommand; +import es.princip.getp.application.member.port.in.EditMemberUseCase; +import es.princip.getp.application.member.port.out.LoadMemberPort; import es.princip.getp.domain.client.command.application.command.EditClientCommand; import es.princip.getp.domain.client.command.application.command.RegisterClientCommand; import es.princip.getp.domain.client.command.domain.Client; import es.princip.getp.domain.client.command.domain.ClientRepository; import es.princip.getp.domain.client.exception.AlreadyExistsClientException; -import es.princip.getp.domain.member.command.application.MemberService; -import es.princip.getp.domain.member.command.application.command.UpdateMemberCommand; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; +import es.princip.getp.domain.member.model.Email; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,8 +18,8 @@ @RequiredArgsConstructor public class ClientService { - private final MemberService memberService; - private final MemberRepository memberRepository; + private final EditMemberUseCase editMemberUseCase; + private final LoadMemberPort loadMemberPort; private final ClientRepository clientRepository; @Transactional @@ -27,13 +27,13 @@ public Long registerClient(RegisterClientCommand command) { if (clientRepository.existsByMemberId(command.memberId())) { throw new AlreadyExistsClientException(); } - memberService.update(UpdateMemberCommand.from(command)); + editMemberUseCase.editMember(EditMemberCommand.from(command)); // 이메일이 입력되지 않은 경우 회원 가입 시 작성한 이메일 주소를 기본값으로 사용 Email email = command.email(); if (email == null) { - email = memberRepository.findById(command.memberId()).orElseThrow().getEmail(); + email = loadMemberPort.loadBy(command.memberId()).getEmail(); } - Client client = Client.builder() + final Client client = Client.builder() .email(email) .bankAccount(command.bankAccount()) .address(command.address()) @@ -44,14 +44,14 @@ public Long registerClient(RegisterClientCommand command) { @Transactional public void editClient(EditClientCommand command) { - memberService.update(UpdateMemberCommand.from(command)); - Client client = clientRepository.findByMemberId(command.memberId()).orElseThrow(); + editMemberUseCase.editMember(EditMemberCommand.from(command)); + final Client client = clientRepository.findByMemberId(command.memberId()).orElseThrow(); client.edit(command.email(), command.address(), command.bankAccount()); } @Transactional public void delete(Long memberId) { - Client client = clientRepository.findByMemberId(memberId).orElseThrow(); + final Client client = clientRepository.findByMemberId(memberId).orElseThrow(); clientRepository.delete(client); } } \ No newline at end of file diff --git a/src/main/java/es/princip/getp/domain/client/command/application/command/EditClientCommand.java b/src/main/java/es/princip/getp/domain/client/command/application/command/EditClientCommand.java index 070edd6b..b98a5ee9 100644 --- a/src/main/java/es/princip/getp/domain/client/command/application/command/EditClientCommand.java +++ b/src/main/java/es/princip/getp/domain/client/command/application/command/EditClientCommand.java @@ -2,9 +2,9 @@ import es.princip.getp.domain.client.command.domain.Address; import es.princip.getp.domain.client.command.domain.BankAccount; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; public record EditClientCommand( Long memberId, diff --git a/src/main/java/es/princip/getp/domain/client/command/application/command/RegisterClientCommand.java b/src/main/java/es/princip/getp/domain/client/command/application/command/RegisterClientCommand.java index 824d5081..21410b65 100644 --- a/src/main/java/es/princip/getp/domain/client/command/application/command/RegisterClientCommand.java +++ b/src/main/java/es/princip/getp/domain/client/command/application/command/RegisterClientCommand.java @@ -2,9 +2,9 @@ import es.princip.getp.domain.client.command.domain.Address; import es.princip.getp.domain.client.command.domain.BankAccount; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; public record RegisterClientCommand( Long memberId, diff --git a/src/main/java/es/princip/getp/domain/client/command/domain/Client.java b/src/main/java/es/princip/getp/domain/client/command/domain/Client.java index db679ad1..d53bcba1 100644 --- a/src/main/java/es/princip/getp/domain/client/command/domain/Client.java +++ b/src/main/java/es/princip/getp/domain/client/command/domain/Client.java @@ -2,7 +2,7 @@ import es.princip.getp.common.domain.BaseTimeEntity; import es.princip.getp.domain.like.command.domain.Likeable; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; diff --git a/src/main/java/es/princip/getp/domain/client/query/dao/ClientQueryDslDao.java b/src/main/java/es/princip/getp/domain/client/query/dao/ClientQueryDslDao.java index e26dbcad..3d0605ea 100644 --- a/src/main/java/es/princip/getp/domain/client/query/dao/ClientQueryDslDao.java +++ b/src/main/java/es/princip/getp/domain/client/query/dao/ClientQueryDslDao.java @@ -3,17 +3,19 @@ import com.querydsl.core.Tuple; import es.princip.getp.api.controller.client.query.dto.ClientResponse; import es.princip.getp.common.util.QueryDslSupport; -import jakarta.persistence.EntityNotFoundException; +import es.princip.getp.domain.client.exception.NotFoundClientException; +import es.princip.getp.persistence.adapter.member.QMemberJpaEntity; import org.springframework.stereotype.Repository; import java.util.Optional; import static es.princip.getp.domain.client.command.domain.QClient.client; -import static es.princip.getp.domain.member.command.domain.model.QMember.member; @Repository public class ClientQueryDslDao extends QueryDslSupport implements ClientDao { + private static final QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; + private ClientResponse toClientResponse(final Tuple result) { if (result == null) { return null; @@ -21,10 +23,10 @@ private ClientResponse toClientResponse(final Tuple result) { return new ClientResponse( result.get(client.clientId), - result.get(member.nickname.value), - result.get(member.phoneNumber.value), + result.get(member.nickname), + result.get(member.phoneNumber), result.get(client.email.value), - result.get(member.profileImage.uri), + result.get(member.profileImageUrl), result.get(client.address), result.get(client.bankAccount), result.get(client.createdAt), @@ -36,10 +38,10 @@ private ClientResponse toClientResponse(final Tuple result) { public ClientResponse findById(final Long clientId) { Tuple result = queryFactory.select( client.clientId, - member.nickname.value, - member.phoneNumber.value, + member.nickname, + member.phoneNumber, client.email, - member.profileImage.uri, + member.profileImageUrl, client.address, client.bankAccount, client.createdAt, @@ -50,19 +52,18 @@ public ClientResponse findById(final Long clientId) { .where(client.clientId.eq(clientId)) .fetchOne(); - return Optional.ofNullable(toClientResponse(result)).orElseThrow( - () -> new EntityNotFoundException("해당 의뢰자 정보가 존재하지 않습니다.") - ); + return Optional.ofNullable(toClientResponse(result)) + .orElseThrow(NotFoundClientException::new); } @Override public ClientResponse findByMemberId(final Long memberId) { Tuple result = queryFactory.select( client.clientId, - member.nickname.value, - member.phoneNumber.value, + member.nickname, + member.phoneNumber, client.email.value, - member.profileImage.uri, + member.profileImageUrl, client.address, client.bankAccount, client.createdAt, @@ -73,8 +74,7 @@ public ClientResponse findByMemberId(final Long memberId) { .where(client.memberId.eq(memberId)) .fetchOne(); - return Optional.ofNullable(toClientResponse(result)).orElseThrow( - () -> new EntityNotFoundException("해당 의뢰자 정보가 존재하지 않습니다.") - ); + return Optional.ofNullable(toClientResponse(result)) + .orElseThrow(NotFoundClientException::new); } } diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/command/ServiceTermAgreementCommand.java b/src/main/java/es/princip/getp/domain/member/command/ServiceTermAgreementCommand.java similarity index 71% rename from src/main/java/es/princip/getp/domain/member/command/domain/command/ServiceTermAgreementCommand.java rename to src/main/java/es/princip/getp/domain/member/command/ServiceTermAgreementCommand.java index e15c9281..a63f545e 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/command/ServiceTermAgreementCommand.java +++ b/src/main/java/es/princip/getp/domain/member/command/ServiceTermAgreementCommand.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.domain.command; +package es.princip.getp.domain.member.command; import es.princip.getp.domain.serviceTerm.domain.ServiceTermTag; diff --git a/src/main/java/es/princip/getp/domain/member/command/application/MemberService.java b/src/main/java/es/princip/getp/domain/member/command/application/MemberService.java deleted file mode 100644 index ae6c1e4a..00000000 --- a/src/main/java/es/princip/getp/domain/member/command/application/MemberService.java +++ /dev/null @@ -1,79 +0,0 @@ -package es.princip.getp.domain.member.command.application; - -import es.princip.getp.domain.member.command.application.command.CreateMemberCommand; -import es.princip.getp.domain.member.command.application.command.UpdateMemberCommand; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; -import es.princip.getp.domain.member.command.domain.model.ProfileImage; -import es.princip.getp.domain.member.command.domain.service.ProfileImageService; -import es.princip.getp.domain.member.command.domain.service.ServiceTermAgreementService; -import es.princip.getp.domain.member.command.exception.AlreadyUsedEmailException; -import es.princip.getp.domain.member.command.exception.NotFoundMemberException; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; - -@Slf4j -@Service -@RequiredArgsConstructor -@Transactional(readOnly = true) -public class MemberService { - - private final ServiceTermAgreementService agreementService; - private final ProfileImageService profileImageService; - - private final MemberRepository memberRepository; - - private Member findById(final Long memberId) { - return memberRepository.findById(memberId).orElseThrow(NotFoundMemberException::new); - } - - /** - * 회원을 생성한다. - * - * @param command 회원 생성 명령 - * @throws AlreadyUsedEmailException 이미 사용 중인 이메일인 경우 - * @return 생성된 회원의 식별자 - */ - @Transactional - public Long create(final CreateMemberCommand command) { - if (memberRepository.existsByEmail(command.email())) - throw new AlreadyUsedEmailException(); - final Member member = Member.of(command.email(), command.password(), command.memberType()); - agreementService.agreeServiceTerms(member, command.serviceTerms()); - return memberRepository.save(member).getMemberId(); - } - - /** - * 회원 정보를 수정한다. - * - * @param command 회원 정보 수정 명령 - * @throws NotFoundMemberException 해당 회원이 존재하지 않는 경우 - */ - @Transactional - public void update(final UpdateMemberCommand command) { - final Member member = findById(command.memberId()); - member.edit(command.nickname(), command.phoneNumber()); - } - - /** - * 회원의 프로필 이미지를 수정한다. 기존의 프로필 이미지가 존재하는 경우 삭제한다. - * - * @param memberId 회원 식별자 - * @param image 프로필 이미지 - * @throws NotFoundMemberException 해당 회원이 존재하지 않는 경우 - * @return 수정된 프로필 이미지의 URI - */ - @Transactional - public String changeProfileImage(final Long memberId, final MultipartFile image) { - Member member = findById(memberId); - if (member.hasProfileImage()) { - profileImageService.deleteProfileImage(member.getProfileImage()); - } - ProfileImage profileImage = profileImageService.saveProfileImage(member, image); - member.changeProfileImage(profileImage); - return profileImage.getUri(); - } -} diff --git a/src/main/java/es/princip/getp/domain/member/command/application/command/CreateMemberCommand.java b/src/main/java/es/princip/getp/domain/member/command/application/command/CreateMemberCommand.java deleted file mode 100644 index 36e684e8..00000000 --- a/src/main/java/es/princip/getp/domain/member/command/application/command/CreateMemberCommand.java +++ /dev/null @@ -1,26 +0,0 @@ -package es.princip.getp.domain.member.command.application.command; - -import es.princip.getp.domain.auth.application.command.SignUpCommand; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.MemberType; -import es.princip.getp.domain.member.command.domain.model.Password; - -import java.util.List; - -public record CreateMemberCommand( - Email email, - Password password, - List serviceTerms, - MemberType memberType -) { - - public static CreateMemberCommand from(final SignUpCommand command) { - return new CreateMemberCommand( - command.email(), - command.password(), - command.serviceTerms(), - command.memberType() - ); - } -} \ No newline at end of file diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/MemberRepository.java b/src/main/java/es/princip/getp/domain/member/command/domain/model/MemberRepository.java deleted file mode 100644 index 22f9a9be..00000000 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/MemberRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package es.princip.getp.domain.member.command.domain.model; - -import org.springframework.data.jpa.repository.JpaRepository; - -import java.util.Optional; - -public interface MemberRepository extends JpaRepository { - boolean existsByEmail(Email email); - - Optional findByEmail(Email email); -} \ No newline at end of file diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/Nickname.java b/src/main/java/es/princip/getp/domain/member/command/domain/model/Nickname.java deleted file mode 100644 index 7d18e563..00000000 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/Nickname.java +++ /dev/null @@ -1,33 +0,0 @@ -package es.princip.getp.domain.member.command.domain.model; - -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import jakarta.validation.constraints.NotNull; -import lombok.*; - -import java.util.Objects; - -@Embeddable -@Getter -@ToString -@EqualsAndHashCode -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Nickname { - - @Column(name = "nickname") - @NotNull - private String value; - - private Nickname(final String value) { - this.value = value; - } - - public static Nickname of(final String value) { - validate(value); - return new Nickname(value); - } - - private static void validate(final String value) { - Objects.requireNonNull(value); - } -} diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/ProfileImage.java b/src/main/java/es/princip/getp/domain/member/command/domain/model/ProfileImage.java deleted file mode 100644 index 607e3e08..00000000 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/ProfileImage.java +++ /dev/null @@ -1,33 +0,0 @@ -package es.princip.getp.domain.member.command.domain.model; - -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import jakarta.validation.constraints.NotNull; -import lombok.*; - -import java.util.Objects; - -@Embeddable -@ToString -@EqualsAndHashCode -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class ProfileImage { - - @Column(name = "profile_image_uri") - @NotNull - private String uri; - - private ProfileImage(final String uri) { - this.uri = uri; - } - - public static ProfileImage of(final String uri) { - validate(uri); - return new ProfileImage(uri); - } - - private static void validate(final String uri) { - Objects.requireNonNull(uri); - } -} diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/ServiceTermAgreement.java b/src/main/java/es/princip/getp/domain/member/command/domain/model/ServiceTermAgreement.java deleted file mode 100644 index 56421d34..00000000 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/ServiceTermAgreement.java +++ /dev/null @@ -1,40 +0,0 @@ -package es.princip.getp.domain.member.command.domain.model; - -import es.princip.getp.domain.serviceTerm.domain.ServiceTermTag; -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import jakarta.persistence.Embedded; -import jakarta.validation.constraints.NotNull; -import lombok.*; - -import java.time.LocalDateTime; -import java.util.Objects; - -@Embeddable -@ToString -@EqualsAndHashCode -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class ServiceTermAgreement { - - @Column(name = "agreed") - @NotNull - private boolean agreed; - - @Column(name = "agreed_at") - @NotNull - private LocalDateTime agreedAt; - - @Embedded - @NotNull - private ServiceTermTag tag; - - public ServiceTermAgreement(final ServiceTermTag tag, final Boolean agreed) { - Objects.requireNonNull(tag); - Objects.requireNonNull(agreed); - - this.agreed = agreed; - this.tag = tag; - this.agreedAt = LocalDateTime.now(); - } -} diff --git a/src/main/java/es/princip/getp/domain/member/command/exception/AlreadyUsedEmailException.java b/src/main/java/es/princip/getp/domain/member/exception/AlreadyUsedEmailException.java similarity index 88% rename from src/main/java/es/princip/getp/domain/member/command/exception/AlreadyUsedEmailException.java rename to src/main/java/es/princip/getp/domain/member/exception/AlreadyUsedEmailException.java index 6a78c17e..63e2c1c3 100644 --- a/src/main/java/es/princip/getp/domain/member/command/exception/AlreadyUsedEmailException.java +++ b/src/main/java/es/princip/getp/domain/member/exception/AlreadyUsedEmailException.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.exception; +package es.princip.getp.domain.member.exception; import es.princip.getp.common.exception.BusinessLogicException; import es.princip.getp.common.exception.ErrorDescription; diff --git a/src/main/java/es/princip/getp/domain/member/command/exception/FailedToSaveProfileImageException.java b/src/main/java/es/princip/getp/domain/member/exception/FailedToSaveProfileImageException.java similarity index 90% rename from src/main/java/es/princip/getp/domain/member/command/exception/FailedToSaveProfileImageException.java rename to src/main/java/es/princip/getp/domain/member/exception/FailedToSaveProfileImageException.java index a9c9f74d..fdc703d5 100644 --- a/src/main/java/es/princip/getp/domain/member/command/exception/FailedToSaveProfileImageException.java +++ b/src/main/java/es/princip/getp/domain/member/exception/FailedToSaveProfileImageException.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.exception; +package es.princip.getp.domain.member.exception; import es.princip.getp.common.exception.ApiErrorException; import es.princip.getp.common.exception.ErrorDescription; diff --git a/src/main/java/es/princip/getp/domain/member/command/infra/ServiceTermAgreementServiceImpl.java b/src/main/java/es/princip/getp/domain/member/infra/ServiceTermAgreementServiceImpl.java similarity index 75% rename from src/main/java/es/princip/getp/domain/member/command/infra/ServiceTermAgreementServiceImpl.java rename to src/main/java/es/princip/getp/domain/member/infra/ServiceTermAgreementServiceImpl.java index 58fafff4..6c79328a 100644 --- a/src/main/java/es/princip/getp/domain/member/command/infra/ServiceTermAgreementServiceImpl.java +++ b/src/main/java/es/princip/getp/domain/member/infra/ServiceTermAgreementServiceImpl.java @@ -1,9 +1,9 @@ -package es.princip.getp.domain.member.command.infra; +package es.princip.getp.domain.member.infra; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.ServiceTermAgreement; -import es.princip.getp.domain.member.command.domain.service.ServiceTermAgreementService; +import es.princip.getp.domain.member.command.ServiceTermAgreementCommand; +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.model.ServiceTermAgreement; +import es.princip.getp.domain.member.service.ServiceTermAgreementService; import es.princip.getp.domain.serviceTerm.domain.ServiceTermChecker; import es.princip.getp.domain.serviceTerm.domain.ServiceTermRepository; import es.princip.getp.domain.serviceTerm.domain.ServiceTermTag; @@ -35,6 +35,6 @@ private ServiceTermAgreement createServiceTermAgreement(final ServiceTermTag tag if (!serviceTermRepository.existsByTag(tag)) { throw new NotFoundServiceTermException(); } - return new ServiceTermAgreement(tag, agreed); + return ServiceTermAgreement.of(tag, agreed); } } diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/Email.java b/src/main/java/es/princip/getp/domain/member/model/Email.java similarity index 85% rename from src/main/java/es/princip/getp/domain/member/command/domain/model/Email.java rename to src/main/java/es/princip/getp/domain/member/model/Email.java index 916340f7..c8e4afb7 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/Email.java +++ b/src/main/java/es/princip/getp/domain/member/model/Email.java @@ -1,6 +1,5 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; -import es.princip.getp.domain.member.command.annotation.EmailPattern; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; import jakarta.validation.constraints.NotNull; @@ -9,21 +8,21 @@ import java.util.Objects; import java.util.regex.Pattern; -@Embeddable @Getter @ToString +@Embeddable @EqualsAndHashCode @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Email { + public static final String EMAIL_REGEX = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$"; private static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL_REGEX); - @Column(name = "email") @NotNull - @EmailPattern + @Column(name = "email") private String value; - private Email(final String value) { + public Email(final String value) { this.value = value; } diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/Member.java b/src/main/java/es/princip/getp/domain/member/model/Member.java similarity index 73% rename from src/main/java/es/princip/getp/domain/member/command/domain/model/Member.java rename to src/main/java/es/princip/getp/domain/member/model/Member.java index c6826715..4717c33f 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/Member.java +++ b/src/main/java/es/princip/getp/domain/member/model/Member.java @@ -1,64 +1,27 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; import es.princip.getp.common.domain.BaseTimeEntity; -import jakarta.persistence.*; -import jakarta.validation.constraints.NotNull; -import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.NoArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.validation.annotation.Validated; import java.util.Collections; import java.util.HashSet; import java.util.Objects; import java.util.Set; -@Entity -@Table(name = "member", - uniqueConstraints = { - @UniqueConstraint(name = "uq_email", columnNames = {"email"}), - @UniqueConstraint(name = "uq_nickname", columnNames = {"nickname"}) - } -) @Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Validated +@AllArgsConstructor public class Member extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "member_id") private Long memberId; - - @Embedded - @NotNull private Email email; - - @Embedded - @NotNull private Password password; - - @Enumerated(EnumType.STRING) - @Column(name = "member_type") - @NotNull private MemberType memberType; - - @Embedded private Nickname nickname; - - @Embedded private PhoneNumber phoneNumber; - - @Embedded private ProfileImage profileImage; - - @ElementCollection - @CollectionTable( - name = "member_service_term_agreement", - joinColumns = @JoinColumn(name = "member_id") - ) - private Set agreements = new HashSet<>(); + private Set serviceTermAgreements = new HashSet<>(); private Member( final Email email, @@ -106,8 +69,8 @@ private void setProfileImage(final ProfileImage profileImage) { * @param agreements 서비스 약관 동의 */ public void agreeServiceTerms(final Set agreements) { - this.agreements.clear(); - this.agreements.addAll(agreements); + this.serviceTermAgreements.clear(); + this.serviceTermAgreements.addAll(agreements); } /** @@ -160,6 +123,6 @@ public void encodePassword(final PasswordEncoder encoder) { * @return 서비스 약관 동의 목록 */ public Set getServiceTermAgreements() { - return Collections.unmodifiableSet(agreements); + return Collections.unmodifiableSet(serviceTermAgreements); } } diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/MemberType.java b/src/main/java/es/princip/getp/domain/member/model/MemberType.java similarity index 90% rename from src/main/java/es/princip/getp/domain/member/command/domain/model/MemberType.java rename to src/main/java/es/princip/getp/domain/member/model/MemberType.java index 523a96eb..dece7496 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/MemberType.java +++ b/src/main/java/es/princip/getp/domain/member/model/MemberType.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; import com.fasterxml.jackson.annotation.JsonCreator; diff --git a/src/main/java/es/princip/getp/domain/member/model/Nickname.java b/src/main/java/es/princip/getp/domain/member/model/Nickname.java new file mode 100644 index 00000000..638ec0c2 --- /dev/null +++ b/src/main/java/es/princip/getp/domain/member/model/Nickname.java @@ -0,0 +1,28 @@ +package es.princip.getp.domain.member.model; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +import java.util.Objects; + +@Getter +@ToString +@EqualsAndHashCode +public class Nickname { + + private final String value; + + public Nickname(final String value) { + this.value = value; + } + + public static Nickname of(final String value) { + validate(value); + return new Nickname(value); + } + + private static void validate(final String value) { + Objects.requireNonNull(value); + } +} diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/Password.java b/src/main/java/es/princip/getp/domain/member/model/Password.java similarity index 72% rename from src/main/java/es/princip/getp/domain/member/command/domain/model/Password.java rename to src/main/java/es/princip/getp/domain/member/model/Password.java index bf11b216..1142ad57 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/Password.java +++ b/src/main/java/es/princip/getp/domain/member/model/Password.java @@ -1,34 +1,26 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import jakarta.persistence.Transient; -import jakarta.validation.constraints.NotNull; -import lombok.*; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; import org.springframework.security.crypto.password.PasswordEncoder; import java.util.Objects; import java.util.regex.Pattern; -@Embeddable -@ToString @Getter +@ToString @EqualsAndHashCode -@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Password { public static final String PASSWORD_REGEX = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[!@#$%^&*_+=/])[A-Za-z\\d!@#$%^&*_+=/]{8,20}$"; private static final Pattern PASSWORD_PATTERN = Pattern.compile(PASSWORD_REGEX); - @Column(name = "password") - @NotNull - private String value; - - @Transient - private boolean encoded; + private final String value; + private final boolean encoded; - private Password(final String value, final boolean encoded) { + public Password(final String value, final boolean encoded) { this.value = value; this.encoded = encoded; } diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/model/PhoneNumber.java b/src/main/java/es/princip/getp/domain/member/model/PhoneNumber.java similarity index 62% rename from src/main/java/es/princip/getp/domain/member/command/domain/model/PhoneNumber.java rename to src/main/java/es/princip/getp/domain/member/model/PhoneNumber.java index 4388deeb..9f60ff48 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/model/PhoneNumber.java +++ b/src/main/java/es/princip/getp/domain/member/model/PhoneNumber.java @@ -1,28 +1,21 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; -import es.princip.getp.domain.member.command.annotation.PhoneNumberPattern; -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import jakarta.validation.constraints.NotNull; -import lombok.*; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; import java.util.Objects; import java.util.regex.Pattern; -@Embeddable @Getter @ToString @EqualsAndHashCode -@NoArgsConstructor(access = AccessLevel.PROTECTED) public class PhoneNumber { public static final String PHONE_REGEX = "^[0-9]+$"; private static final Pattern PHONE_PATTERN = Pattern.compile(PHONE_REGEX); - @Column(name = "phone_number") - @PhoneNumberPattern - @NotNull - private String value; + private final String value; public PhoneNumber(final String value) { validate(value); diff --git a/src/main/java/es/princip/getp/domain/member/model/ProfileImage.java b/src/main/java/es/princip/getp/domain/member/model/ProfileImage.java new file mode 100644 index 00000000..42b578e5 --- /dev/null +++ b/src/main/java/es/princip/getp/domain/member/model/ProfileImage.java @@ -0,0 +1,28 @@ +package es.princip.getp.domain.member.model; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +import java.util.Objects; + +@Getter +@ToString +@EqualsAndHashCode +public class ProfileImage { + + private final String url; + + public ProfileImage(final String url) { + this.url = url; + } + + public static ProfileImage of(final String url) { + validate(url); + return new ProfileImage(url); + } + + private static void validate(final String url) { + Objects.requireNonNull(url); + } +} diff --git a/src/main/java/es/princip/getp/domain/member/model/ServiceTermAgreement.java b/src/main/java/es/princip/getp/domain/member/model/ServiceTermAgreement.java new file mode 100644 index 00000000..0443747b --- /dev/null +++ b/src/main/java/es/princip/getp/domain/member/model/ServiceTermAgreement.java @@ -0,0 +1,25 @@ +package es.princip.getp.domain.member.model; + +import es.princip.getp.domain.serviceTerm.domain.ServiceTermTag; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +import java.time.LocalDateTime; + + +@Getter +@ToString +@EqualsAndHashCode +@AllArgsConstructor +public class ServiceTermAgreement { + + private final ServiceTermTag tag; + private final boolean agreed; + private final LocalDateTime agreedAt; + + public static ServiceTermAgreement of(final ServiceTermTag tag, final Boolean agreed) { + return new ServiceTermAgreement(tag, agreed, LocalDateTime.now()); + } +} diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/service/ProfileImageService.java b/src/main/java/es/princip/getp/domain/member/service/ProfileImageService.java similarity index 83% rename from src/main/java/es/princip/getp/domain/member/command/domain/service/ProfileImageService.java rename to src/main/java/es/princip/getp/domain/member/service/ProfileImageService.java index 98267c4d..8cd1caeb 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/service/ProfileImageService.java +++ b/src/main/java/es/princip/getp/domain/member/service/ProfileImageService.java @@ -1,9 +1,9 @@ -package es.princip.getp.domain.member.command.domain.service; +package es.princip.getp.domain.member.service; import es.princip.getp.common.util.ImageUtil; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.ProfileImage; -import es.princip.getp.domain.member.command.exception.FailedToSaveProfileImageException; +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.model.ProfileImage; +import es.princip.getp.domain.member.exception.FailedToSaveProfileImageException; import es.princip.getp.storage.application.ImageStorage; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -53,6 +53,6 @@ private Path getPathToSaveProfileImage(final Member member, final MultipartFile } public void deleteProfileImage(final ProfileImage profileImage) { - imageStorage.deleteImage(URI.create(profileImage.getUri())); + imageStorage.deleteImage(URI.create(profileImage.getUrl())); } } diff --git a/src/main/java/es/princip/getp/domain/member/command/domain/service/ServiceTermAgreementService.java b/src/main/java/es/princip/getp/domain/member/service/ServiceTermAgreementService.java similarity index 68% rename from src/main/java/es/princip/getp/domain/member/command/domain/service/ServiceTermAgreementService.java rename to src/main/java/es/princip/getp/domain/member/service/ServiceTermAgreementService.java index a74e54ab..f890adc5 100644 --- a/src/main/java/es/princip/getp/domain/member/command/domain/service/ServiceTermAgreementService.java +++ b/src/main/java/es/princip/getp/domain/member/service/ServiceTermAgreementService.java @@ -1,7 +1,7 @@ -package es.princip.getp.domain.member.command.domain.service; +package es.princip.getp.domain.member.service; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.command.ServiceTermAgreementCommand; +import es.princip.getp.domain.member.model.Member; import jakarta.persistence.EntityNotFoundException; import java.util.List; diff --git a/src/main/java/es/princip/getp/domain/people/command/application/PeopleMapper.java b/src/main/java/es/princip/getp/domain/people/command/application/PeopleMapper.java index a1a3199b..23942902 100644 --- a/src/main/java/es/princip/getp/domain/people/command/application/PeopleMapper.java +++ b/src/main/java/es/princip/getp/domain/people/command/application/PeopleMapper.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.people.command.application; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import es.princip.getp.domain.people.command.domain.People; import es.princip.getp.domain.people.command.domain.PeopleInfo; import es.princip.getp.domain.people.command.domain.PeopleType; diff --git a/src/main/java/es/princip/getp/domain/people/command/application/PeopleService.java b/src/main/java/es/princip/getp/domain/people/command/application/PeopleService.java index bcbcb5cf..290e453a 100644 --- a/src/main/java/es/princip/getp/domain/people/command/application/PeopleService.java +++ b/src/main/java/es/princip/getp/domain/people/command/application/PeopleService.java @@ -1,7 +1,7 @@ package es.princip.getp.domain.people.command.application; -import es.princip.getp.domain.member.command.application.MemberService; -import es.princip.getp.domain.member.command.application.command.UpdateMemberCommand; +import es.princip.getp.application.member.command.EditMemberCommand; +import es.princip.getp.application.member.port.in.EditMemberUseCase; import es.princip.getp.domain.people.command.application.command.CreatePeopleCommand; import es.princip.getp.domain.people.command.application.command.UpdatePeopleCommand; import es.princip.getp.domain.people.command.domain.People; @@ -13,13 +13,13 @@ import org.springframework.transaction.annotation.Transactional; @Service -@Transactional(readOnly = true) @RequiredArgsConstructor +@Transactional(readOnly = true) public class PeopleService { private final PeopleMapper peopleMapper; - private final MemberService memberService; + private final EditMemberUseCase editMemberUseCase; private final PeopleRepository peopleRepository; /** @@ -34,7 +34,7 @@ public Long create(final CreatePeopleCommand command) { if (peopleRepository.existsByMemberId(command.memberId())) { throw new AlreadyExistsPeopleException(); } - memberService.update(UpdateMemberCommand.from(command)); + editMemberUseCase.editMember(EditMemberCommand.from(command)); final People people = peopleMapper.mapToPeople(command.memberId(), command.email(), command.peopleType()); return peopleRepository.save(people).getPeopleId(); } @@ -47,7 +47,7 @@ public Long create(final CreatePeopleCommand command) { */ @Transactional public void update(final UpdatePeopleCommand command) { - memberService.update(UpdateMemberCommand.from(command)); + editMemberUseCase.editMember(EditMemberCommand.from(command)); final People people = peopleRepository.findByMemberId(command.memberId()) .orElseThrow(NotFoundPeopleException::new); people.editInfo(command.email(), command.peopleType()); diff --git a/src/main/java/es/princip/getp/domain/people/command/application/command/CreatePeopleCommand.java b/src/main/java/es/princip/getp/domain/people/command/application/command/CreatePeopleCommand.java index 3dcaf179..c00b9c31 100644 --- a/src/main/java/es/princip/getp/domain/people/command/application/command/CreatePeopleCommand.java +++ b/src/main/java/es/princip/getp/domain/people/command/application/command/CreatePeopleCommand.java @@ -1,8 +1,8 @@ package es.princip.getp.domain.people.command.application.command; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; import es.princip.getp.domain.people.command.domain.PeopleType; public record CreatePeopleCommand( diff --git a/src/main/java/es/princip/getp/domain/people/command/application/command/UpdatePeopleCommand.java b/src/main/java/es/princip/getp/domain/people/command/application/command/UpdatePeopleCommand.java index e975da01..a267bb61 100644 --- a/src/main/java/es/princip/getp/domain/people/command/application/command/UpdatePeopleCommand.java +++ b/src/main/java/es/princip/getp/domain/people/command/application/command/UpdatePeopleCommand.java @@ -1,8 +1,8 @@ package es.princip.getp.domain.people.command.application.command; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Nickname; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Nickname; +import es.princip.getp.domain.member.model.PhoneNumber; import es.princip.getp.domain.people.command.domain.PeopleType; public record UpdatePeopleCommand( diff --git a/src/main/java/es/princip/getp/domain/people/command/domain/People.java b/src/main/java/es/princip/getp/domain/people/command/domain/People.java index e3b7bd9a..a77db22c 100644 --- a/src/main/java/es/princip/getp/domain/people/command/domain/People.java +++ b/src/main/java/es/princip/getp/domain/people/command/domain/People.java @@ -3,7 +3,7 @@ import es.princip.getp.common.domain.BaseTimeEntity; import es.princip.getp.domain.like.command.domain.LikeReceivable; import es.princip.getp.domain.like.command.domain.Likeable; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import es.princip.getp.domain.people.exception.AlreadyRegisteredPeopleProfileException; import es.princip.getp.domain.people.exception.NotRegisteredPeopleProfileException; import jakarta.persistence.*; diff --git a/src/main/java/es/princip/getp/domain/people/command/domain/PeopleInfo.java b/src/main/java/es/princip/getp/domain/people/command/domain/PeopleInfo.java index 6ca57a3c..0052346b 100644 --- a/src/main/java/es/princip/getp/domain/people/command/domain/PeopleInfo.java +++ b/src/main/java/es/princip/getp/domain/people/command/domain/PeopleInfo.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.people.command.domain; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; import lombok.AccessLevel; diff --git a/src/main/java/es/princip/getp/domain/people/query/dao/PeopleQueryDslDao.java b/src/main/java/es/princip/getp/domain/people/query/dao/PeopleQueryDslDao.java index 1d9e86d8..b4f4ed91 100644 --- a/src/main/java/es/princip/getp/domain/people/query/dao/PeopleQueryDslDao.java +++ b/src/main/java/es/princip/getp/domain/people/query/dao/PeopleQueryDslDao.java @@ -3,13 +3,6 @@ import com.querydsl.core.Tuple; import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.Expressions; -import es.princip.getp.common.util.QueryDslSupport; -import es.princip.getp.domain.like.query.dao.PeopleLikeDao; -import es.princip.getp.domain.people.command.domain.People; -import es.princip.getp.domain.people.command.domain.PeopleProfile; -import es.princip.getp.domain.people.command.domain.QPeople; -import es.princip.getp.domain.people.exception.NotFoundPeopleException; -import es.princip.getp.domain.people.exception.NotRegisteredPeopleProfileException; import es.princip.getp.api.controller.people.query.dto.people.CardPeopleResponse; import es.princip.getp.api.controller.people.query.dto.people.DetailPeopleResponse; import es.princip.getp.api.controller.people.query.dto.people.MyPeopleResponse; @@ -17,6 +10,14 @@ import es.princip.getp.api.controller.people.query.dto.peopleProfile.CardPeopleProfileResponse; import es.princip.getp.api.controller.people.query.dto.peopleProfile.DetailPeopleProfileResponse; import es.princip.getp.api.controller.people.query.dto.peopleProfile.PublicDetailPeopleProfileResponse; +import es.princip.getp.common.util.QueryDslSupport; +import es.princip.getp.domain.like.query.dao.PeopleLikeDao; +import es.princip.getp.domain.people.command.domain.People; +import es.princip.getp.domain.people.command.domain.PeopleProfile; +import es.princip.getp.domain.people.command.domain.QPeople; +import es.princip.getp.domain.people.exception.NotFoundPeopleException; +import es.princip.getp.domain.people.exception.NotRegisteredPeopleProfileException; +import es.princip.getp.persistence.adapter.member.QMemberJpaEntity; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -27,7 +28,6 @@ import java.util.Optional; import java.util.function.Function; -import static es.princip.getp.domain.member.command.domain.model.QMember.member; import static es.princip.getp.domain.people.command.domain.QPeople.people; import static es.princip.getp.domain.people.query.dao.PeopleDaoUtil.orderSpecifiersFromSort; import static es.princip.getp.domain.people.query.dao.PeopleDaoUtil.toPeopleIds; @@ -38,12 +38,14 @@ // TODO: 조회 성능 개선 필요 public class PeopleQueryDslDao extends QueryDslSupport implements PeopleDao { + private static final QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; + private final PeopleLikeDao peopleLikeDao; private Map findMemberAndPeopleByPeopleId(final Long... peopleId) { return queryFactory.select( - member.nickname.value, - member.profileImage.uri, + member.nickname, + member.profileImageUrl, people.peopleId, people.info.peopleType ) @@ -57,8 +59,8 @@ private Map findMemberAndPeopleByPeopleId(final Long... peopleId) { private Optional findMemberAndPeopleByPeopleId(final Long peopleId) { return Optional.ofNullable( queryFactory.select( - member.nickname.value, - member.profileImage.uri, + member.nickname, + member.profileImageUrl, people.peopleId, people.info.peopleType ) @@ -87,8 +89,8 @@ private List getCardPeopleContent(final Pageable pageable) { final Long peopleId = people.getPeopleId(); return new CardPeopleResponse( peopleId, - memberAndPeople.get(peopleId).get(member.nickname.value), - memberAndPeople.get(peopleId).get(member.profileImage.uri), + memberAndPeople.get(peopleId).get(member.nickname), + memberAndPeople.get(peopleId).get(member.profileImageUrl), memberAndPeople.get(peopleId).get(qPeople.info.peopleType), 0, likesCounts.get(peopleId), @@ -123,8 +125,8 @@ public DetailPeopleResponse findDetailPeopleById(final Long peopleId) { return new DetailPeopleResponse( peopleId, - memberAndPeople.get(member.nickname.value), - memberAndPeople.get(member.profileImage.uri), + memberAndPeople.get(member.nickname), + memberAndPeople.get(member.profileImageUrl), memberAndPeople.get(people.info.peopleType), 0, peopleLikeDao.countByLikedId(peopleId), @@ -149,8 +151,8 @@ public PublicDetailPeopleResponse findPublicDetailPeopleById(final Long peopleId return new PublicDetailPeopleResponse( peopleId, - memberAndPeople.get(member.nickname.value), - memberAndPeople.get(member.profileImage.uri), + memberAndPeople.get(member.nickname), + memberAndPeople.get(member.profileImageUrl), memberAndPeople.get(people.info.peopleType), 0, peopleLikeDao.countByLikedId(peopleId), @@ -166,9 +168,9 @@ public MyPeopleResponse findByMemberId(final Long memberId) { MyPeopleResponse.class, people.peopleId, people.info.email.value, - member.nickname.value, - member.phoneNumber.value, - member.profileImage.uri, + member.nickname, + member.phoneNumber, + member.profileImageUrl, people.info.peopleType, Expressions.asNumber(0).as("completedProjectsCount"), Expressions.asNumber(0).as("likesCount"), diff --git a/src/main/java/es/princip/getp/domain/project/command/application/command/ScheduleMeetingCommand.java b/src/main/java/es/princip/getp/domain/project/command/application/command/ScheduleMeetingCommand.java index e1c1b0dd..ced038ba 100644 --- a/src/main/java/es/princip/getp/domain/project/command/application/command/ScheduleMeetingCommand.java +++ b/src/main/java/es/princip/getp/domain/project/command/application/command/ScheduleMeetingCommand.java @@ -1,7 +1,7 @@ package es.princip.getp.domain.project.command.application.command; import es.princip.getp.common.domain.MeetingSchedule; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.PhoneNumber; public record ScheduleMeetingCommand( Long memberId, diff --git a/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeeting.java b/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeeting.java index 147dbd2a..41a69ca5 100644 --- a/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeeting.java +++ b/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeeting.java @@ -2,7 +2,7 @@ import es.princip.getp.common.domain.BaseTimeEntity; import es.princip.getp.common.domain.MeetingSchedule; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.PhoneNumber; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; diff --git a/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeetingScheduler.java b/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeetingScheduler.java index ec390f39..59016ee2 100644 --- a/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeetingScheduler.java +++ b/src/main/java/es/princip/getp/domain/project/command/domain/ProjectMeetingScheduler.java @@ -1,7 +1,7 @@ package es.princip.getp.domain.project.command.domain; import es.princip.getp.common.domain.MeetingSchedule; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.PhoneNumber; import es.princip.getp.domain.people.command.domain.People; import es.princip.getp.domain.project.exception.NotApplicantException; import es.princip.getp.domain.project.exception.NotClientOfProjectException; diff --git a/src/main/java/es/princip/getp/domain/project/query/application/ProjectApplicantService.java b/src/main/java/es/princip/getp/domain/project/query/application/ProjectApplicantService.java index 936ff775..0da3cd12 100644 --- a/src/main/java/es/princip/getp/domain/project/query/application/ProjectApplicantService.java +++ b/src/main/java/es/princip/getp/domain/project/query/application/ProjectApplicantService.java @@ -4,7 +4,7 @@ import es.princip.getp.domain.client.command.domain.Client; import es.princip.getp.domain.client.command.domain.ClientRepository; import es.princip.getp.domain.client.exception.NotFoundClientException; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.Member; import es.princip.getp.api.controller.people.query.dto.people.DetailPeopleResponse; import es.princip.getp.domain.project.command.domain.Project; import es.princip.getp.domain.project.command.domain.ProjectRepository; diff --git a/src/main/java/es/princip/getp/domain/project/query/dao/ProjectApplicantQueryDslDao.java b/src/main/java/es/princip/getp/domain/project/query/dao/ProjectApplicantQueryDslDao.java index 5d3e4f57..efd1c342 100644 --- a/src/main/java/es/princip/getp/domain/project/query/dao/ProjectApplicantQueryDslDao.java +++ b/src/main/java/es/princip/getp/domain/project/query/dao/ProjectApplicantQueryDslDao.java @@ -1,12 +1,13 @@ package es.princip.getp.domain.project.query.dao; import com.querydsl.core.Tuple; +import es.princip.getp.api.controller.people.query.dto.people.DetailPeopleResponse; +import es.princip.getp.api.controller.people.query.dto.peopleProfile.DetailPeopleProfileResponse; import es.princip.getp.common.util.QueryDslSupport; import es.princip.getp.domain.like.query.dao.PeopleLikeDao; import es.princip.getp.domain.people.command.domain.People; import es.princip.getp.domain.people.command.domain.QPeople; -import es.princip.getp.api.controller.people.query.dto.people.DetailPeopleResponse; -import es.princip.getp.api.controller.people.query.dto.peopleProfile.DetailPeopleProfileResponse; +import es.princip.getp.persistence.adapter.member.QMemberJpaEntity; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -16,7 +17,6 @@ import java.util.Map; import java.util.function.Function; -import static es.princip.getp.domain.member.command.domain.model.QMember.member; import static es.princip.getp.domain.people.command.domain.QPeople.people; import static es.princip.getp.domain.people.query.dao.PeopleDaoUtil.orderSpecifiersFromSort; import static es.princip.getp.domain.people.query.dao.PeopleDaoUtil.toPeopleIds; @@ -28,12 +28,14 @@ // TODO: 조회 성능 개선 필요 public class ProjectApplicantQueryDslDao extends QueryDslSupport implements ProjectApplicantDao { + private static final QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; + private final PeopleLikeDao peopleLikeDao; private Map findMemberAndPeopleByPeopleId(final Long... peopleId) { return queryFactory.select( - member.nickname.value, - member.profileImage.uri, + member.nickname, + member.profileImageUrl, people.peopleId, people.info.peopleType ) @@ -77,8 +79,8 @@ private List assemble( final Long peopleId = people.getPeopleId(); return new DetailPeopleResponse( peopleId, - memberAndPeople.get(peopleId).get(member.nickname.value), - memberAndPeople.get(peopleId).get(member.profileImage.uri), + memberAndPeople.get(peopleId).get(member.nickname), + memberAndPeople.get(peopleId).get(member.profileImageUrl), memberAndPeople.get(peopleId).get(qPeople.info.peopleType), 0, likesCounts.get(peopleId), diff --git a/src/main/java/es/princip/getp/domain/project/query/dao/ProjectQueryDslDao.java b/src/main/java/es/princip/getp/domain/project/query/dao/ProjectQueryDslDao.java index 48d08cfe..a2aac1e3 100644 --- a/src/main/java/es/princip/getp/domain/project/query/dao/ProjectQueryDslDao.java +++ b/src/main/java/es/princip/getp/domain/project/query/dao/ProjectQueryDslDao.java @@ -1,15 +1,16 @@ package es.princip.getp.domain.project.query.dao; import com.querydsl.core.types.Projections; +import es.princip.getp.api.controller.project.query.dto.AttachmentFilesResponse; +import es.princip.getp.api.controller.project.query.dto.ProjectCardResponse; +import es.princip.getp.api.controller.project.query.dto.ProjectClientResponse; +import es.princip.getp.api.controller.project.query.dto.ProjectDetailResponse; import es.princip.getp.common.dto.HashtagsResponse; import es.princip.getp.common.util.QueryDslSupport; import es.princip.getp.domain.like.query.dao.ProjectLikeDao; import es.princip.getp.domain.project.command.domain.Project; import es.princip.getp.domain.project.exception.NotFoundProjectException; -import es.princip.getp.api.controller.project.query.dto.AttachmentFilesResponse; -import es.princip.getp.api.controller.project.query.dto.ProjectCardResponse; -import es.princip.getp.api.controller.project.query.dto.ProjectClientResponse; -import es.princip.getp.api.controller.project.query.dto.ProjectDetailResponse; +import es.princip.getp.persistence.adapter.member.QMemberJpaEntity; import jakarta.persistence.EntityNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; @@ -21,7 +22,6 @@ import java.util.Optional; import static es.princip.getp.domain.client.command.domain.QClient.client; -import static es.princip.getp.domain.member.command.domain.model.QMember.member; import static es.princip.getp.domain.project.command.domain.QProject.project; import static es.princip.getp.domain.project.query.dao.ProjectDaoUtil.toProjectIds; @@ -29,6 +29,8 @@ @RequiredArgsConstructor public class ProjectQueryDslDao extends QueryDslSupport implements ProjectDao { + private static final QMemberJpaEntity member = QMemberJpaEntity.memberJpaEntity; + private final ProjectLikeDao projectLikeDao; private final ProjectApplicationDao projectApplicationDao; @@ -70,7 +72,7 @@ private ProjectClientResponse getProjectClientResponseByClientId(final Long clie Projections.constructor( ProjectClientResponse.class, client.clientId, - member.nickname.value, + member.nickname, client.address ) ) diff --git a/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermChecker.java b/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermChecker.java index 4373e610..bbb0de08 100644 --- a/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermChecker.java +++ b/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermChecker.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.serviceTerm.domain; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; +import es.princip.getp.domain.member.command.ServiceTermAgreementCommand; import es.princip.getp.domain.serviceTerm.exception.NotAgreedAllRequiredServiceTermException; import jakarta.persistence.EntityNotFoundException; diff --git a/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermTag.java b/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermTag.java index 5d471fe7..57f2403a 100644 --- a/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermTag.java +++ b/src/main/java/es/princip/getp/domain/serviceTerm/domain/ServiceTermTag.java @@ -7,10 +7,10 @@ import java.io.Serializable; -@Embeddable +@Getter @ToString +@Embeddable @EqualsAndHashCode -@Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class ServiceTermTag implements Serializable { @@ -18,7 +18,7 @@ public class ServiceTermTag implements Serializable { @NotNull private String value; - private ServiceTermTag(final String value) { + public ServiceTermTag(final String value) { this.value = value; } diff --git a/src/main/java/es/princip/getp/domain/serviceTerm/infra/ServiceTermCheckerImpl.java b/src/main/java/es/princip/getp/domain/serviceTerm/infra/ServiceTermCheckerImpl.java index 0ec2dcd5..bcbe7742 100644 --- a/src/main/java/es/princip/getp/domain/serviceTerm/infra/ServiceTermCheckerImpl.java +++ b/src/main/java/es/princip/getp/domain/serviceTerm/infra/ServiceTermCheckerImpl.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.serviceTerm.infra; -import es.princip.getp.domain.member.command.domain.command.ServiceTermAgreementCommand; +import es.princip.getp.domain.member.command.ServiceTermAgreementCommand; import es.princip.getp.domain.serviceTerm.domain.ServiceTerm; import es.princip.getp.domain.serviceTerm.domain.ServiceTermChecker; import es.princip.getp.domain.serviceTerm.domain.ServiceTermRepository; diff --git a/src/main/java/es/princip/getp/mail/command/SendMailCommand.java b/src/main/java/es/princip/getp/mail/command/SendMailCommand.java index 3fded654..af9c5e72 100644 --- a/src/main/java/es/princip/getp/mail/command/SendMailCommand.java +++ b/src/main/java/es/princip/getp/mail/command/SendMailCommand.java @@ -1,6 +1,6 @@ package es.princip.getp.mail.command; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; public record SendMailCommand( Email email, diff --git a/src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaEntity.java b/src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaEntity.java new file mode 100644 index 00000000..d4ddead5 --- /dev/null +++ b/src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaEntity.java @@ -0,0 +1,54 @@ +package es.princip.getp.persistence.adapter.member; + +import es.princip.getp.common.domain.BaseTimeEntity; +import es.princip.getp.domain.member.model.MemberType; +import jakarta.persistence.*; +import lombok.*; + +import java.util.HashSet; +import java.util.Set; + +@Getter +@Entity +@Builder +@AllArgsConstructor +@Table(name = "member", + uniqueConstraints = { + @UniqueConstraint(name = "uq_email", columnNames = {"email"}), + @UniqueConstraint(name = "uq_nickname", columnNames = {"nickname"}) + } +) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class MemberJpaEntity extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "member_id") + private Long memberId; + + @Column(name = "email") + private String email; + + @Column(name = "password") + private String password; + + @Enumerated(EnumType.STRING) + @Column(name = "member_type") + private MemberType memberType; + + @Column(name = "nickname") + private String nickname; + + @Column(name = "phone_number") + private String phoneNumber; + + @Column(name = "profile_image_url") + private String profileImageUrl; + + @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable( + name = "member_service_term_agreement", + joinColumns = @JoinColumn(name = "member_id") + ) + private Set serviceTermAgreements = new HashSet<>(); +} diff --git a/src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaRepository.java b/src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaRepository.java new file mode 100644 index 00000000..e939742d --- /dev/null +++ b/src/main/java/es/princip/getp/persistence/adapter/member/MemberJpaRepository.java @@ -0,0 +1,12 @@ +package es.princip.getp.persistence.adapter.member; + +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface MemberJpaRepository extends JpaRepository { + + boolean existsByEmail(String email); + + Optional findByEmail(String email); +} \ No newline at end of file diff --git a/src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceAdapter.java b/src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceAdapter.java new file mode 100644 index 00000000..fb905320 --- /dev/null +++ b/src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceAdapter.java @@ -0,0 +1,52 @@ +package es.princip.getp.persistence.adapter.member; + +import es.princip.getp.application.member.port.out.CheckMemberPort; +import es.princip.getp.application.member.port.out.LoadMemberPort; +import es.princip.getp.application.member.port.out.SaveMemberPort; +import es.princip.getp.application.member.port.out.UpdateMemberPort; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Member; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; + +@Repository +@RequiredArgsConstructor +public class MemberPersistenceAdapter implements SaveMemberPort, LoadMemberPort, CheckMemberPort, UpdateMemberPort { + + private final MemberPersistenceMapper mapper; + + private final MemberJpaRepository memberJpaRepository; + + @Override + public Member loadBy(final Email email) { + final MemberJpaEntity memberJpaEntity = memberJpaRepository.findByEmail(email.getValue()) + .orElseThrow(NotFoundMemberException::new); + return mapper.mapToDomain(memberJpaEntity); + } + + @Override + public Member loadBy(final Long memberId) { + final MemberJpaEntity memberJpaEntity = memberJpaRepository.findById(memberId) + .orElseThrow(NotFoundMemberException::new); + return mapper.mapToDomain(memberJpaEntity); + } + + @Override + public Long save(final Member member) { + final MemberJpaEntity memberJpaEntity = mapper.mapToJpa(member); + return memberJpaRepository.save(memberJpaEntity).getMemberId(); + } + + @Override + public void update(final Member member) { + if (!memberJpaRepository.existsById(member.getMemberId())) { + throw new NotFoundMemberException(); + } + save(member); + } + + @Override + public boolean existsByEmail(final Email email) { + return memberJpaRepository.existsByEmail(email.getValue()); + } +} diff --git a/src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceMapper.java b/src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceMapper.java new file mode 100644 index 00000000..ea9567ca --- /dev/null +++ b/src/main/java/es/princip/getp/persistence/adapter/member/MemberPersistenceMapper.java @@ -0,0 +1,30 @@ +package es.princip.getp.persistence.adapter.member; + +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.model.ServiceTermAgreement; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper(componentModel = "spring") +public interface MemberPersistenceMapper { + + @Mapping(source = "email", target = "email.value") + @Mapping(source = "password", target = "password.value") + @Mapping(source = "nickname", target = "nickname.value") + @Mapping(source = "phoneNumber", target = "phoneNumber.value") + @Mapping(source = "profileImageUrl", target = "profileImage.url") + Member mapToDomain(MemberJpaEntity memberJpaEntity); + + @Mapping(target = "email", source = "email.value") + @Mapping(target = "password", source = "password.value") + @Mapping(target = "nickname", source = "nickname.value") + @Mapping(target = "phoneNumber", source = "phoneNumber.value") + @Mapping(target = "profileImageUrl", source = "profileImage.url") + MemberJpaEntity mapToJpa(Member member); + + @Mapping(source = "tag", target = "tag.value") + ServiceTermAgreement mapToDomain(ServiceTermAgreementJpaVO serviceTermAgreementJpaVO); + + @Mapping(target = "tag", source = "tag.value") + ServiceTermAgreementJpaVO mapToJpa(ServiceTermAgreement serviceTermAgreement); +} diff --git a/src/main/java/es/princip/getp/domain/member/command/exception/NotFoundMemberException.java b/src/main/java/es/princip/getp/persistence/adapter/member/NotFoundMemberException.java similarity index 88% rename from src/main/java/es/princip/getp/domain/member/command/exception/NotFoundMemberException.java rename to src/main/java/es/princip/getp/persistence/adapter/member/NotFoundMemberException.java index 3a4931ba..a6e5fdd9 100644 --- a/src/main/java/es/princip/getp/domain/member/command/exception/NotFoundMemberException.java +++ b/src/main/java/es/princip/getp/persistence/adapter/member/NotFoundMemberException.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.exception; +package es.princip.getp.persistence.adapter.member; import es.princip.getp.common.exception.ErrorDescription; import es.princip.getp.common.exception.NotFoundException; diff --git a/src/main/java/es/princip/getp/persistence/adapter/member/ServiceTermAgreementJpaVO.java b/src/main/java/es/princip/getp/persistence/adapter/member/ServiceTermAgreementJpaVO.java new file mode 100644 index 00000000..249451ee --- /dev/null +++ b/src/main/java/es/princip/getp/persistence/adapter/member/ServiceTermAgreementJpaVO.java @@ -0,0 +1,29 @@ +package es.princip.getp.persistence.adapter.member; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.validation.constraints.NotNull; +import lombok.*; + +import java.time.LocalDateTime; + +@Getter +@ToString +@Embeddable +@EqualsAndHashCode +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ServiceTermAgreementJpaVO { + + @NotNull + @Column(name = "service_term_tag") + private String tag; + + @NotNull + @Column(name = "agreed") + private boolean agreed; + + @NotNull + @Column(name = "agreed_at") + private LocalDateTime agreedAt; +} diff --git a/src/test/java/es/princip/getp/api/controller/ControllerTest.java b/src/test/java/es/princip/getp/api/controller/ControllerTest.java index 3543d4c1..db59aae7 100644 --- a/src/test/java/es/princip/getp/api/controller/ControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/ControllerTest.java @@ -7,13 +7,13 @@ import es.princip.getp.api.security.PrincipalDetailsParameterResolver; import es.princip.getp.api.security.SecurityConfig; import es.princip.getp.api.security.SecurityTestConfig; +import es.princip.getp.application.member.service.MemberService; import es.princip.getp.domain.auth.application.AuthService; import es.princip.getp.domain.auth.application.SignUpService; import es.princip.getp.domain.client.command.application.ClientService; import es.princip.getp.domain.client.query.dao.ClientDao; import es.princip.getp.domain.like.command.application.PeopleLikeService; import es.princip.getp.domain.like.command.application.ProjectLikeService; -import es.princip.getp.domain.member.command.application.MemberService; import es.princip.getp.domain.people.command.application.PeopleProfileService; import es.princip.getp.domain.people.command.application.PeopleService; import es.princip.getp.domain.people.query.dao.PeopleDao; diff --git a/src/test/java/es/princip/getp/api/controller/auth/SignUpControllerTest.java b/src/test/java/es/princip/getp/api/controller/auth/SignUpControllerTest.java index 10c3d33a..42b58f19 100644 --- a/src/test/java/es/princip/getp/api/controller/auth/SignUpControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/auth/SignUpControllerTest.java @@ -6,7 +6,7 @@ import es.princip.getp.api.controller.auth.dto.request.SignUpRequest; import es.princip.getp.domain.auth.application.SignUpService; import es.princip.getp.domain.auth.application.command.SignUpCommand; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/src/test/java/es/princip/getp/api/controller/client/command/MyClientControllerTest.java b/src/test/java/es/princip/getp/api/controller/client/command/MyClientControllerTest.java index f0ef4a7a..1d1578a6 100644 --- a/src/test/java/es/princip/getp/api/controller/client/command/MyClientControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/client/command/MyClientControllerTest.java @@ -8,7 +8,7 @@ import es.princip.getp.api.security.annotation.WithCustomMockUser; import es.princip.getp.api.security.details.PrincipalDetails; import es.princip.getp.domain.client.command.application.ClientService; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/src/test/java/es/princip/getp/api/controller/client/query/ClientQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/client/query/ClientQueryControllerTest.java index 9bca3e31..14681c25 100644 --- a/src/test/java/es/princip/getp/api/controller/client/query/ClientQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/client/query/ClientQueryControllerTest.java @@ -1,11 +1,11 @@ package es.princip.getp.api.controller.client.query; +import es.princip.getp.api.controller.ControllerTest; import es.princip.getp.api.controller.client.query.dto.ClientResponse; +import es.princip.getp.api.security.annotation.WithCustomMockUser; import es.princip.getp.common.exception.BusinessLogicException; -import es.princip.getp.api.controller.ControllerTest; import es.princip.getp.domain.client.query.dao.ClientDao; -import es.princip.getp.domain.member.command.domain.model.MemberType; -import es.princip.getp.api.security.annotation.WithCustomMockUser; +import es.princip.getp.domain.member.model.MemberType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -44,7 +44,7 @@ void getClient_WhenMemberTypeIsAdmin() throws Exception { NICKNAME, PHONE_NUMBER, EMAIL, - profileImage(1L).getUri(), + profileImage(1L).getUrl(), address(), bankAccount(), now, @@ -67,7 +67,7 @@ void getClient_WhenMemberTypeIsManager() throws Exception { NICKNAME, PHONE_NUMBER, EMAIL, - profileImage(1L).getUri(), + profileImage(1L).getUrl(), address(), bankAccount(), now, diff --git a/src/test/java/es/princip/getp/api/controller/client/query/MyClientQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/client/query/MyClientQueryControllerTest.java index f29e8baf..4d966df0 100644 --- a/src/test/java/es/princip/getp/api/controller/client/query/MyClientQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/client/query/MyClientQueryControllerTest.java @@ -6,7 +6,7 @@ import es.princip.getp.api.docs.PayloadDocumentationHelper; import es.princip.getp.api.security.annotation.WithCustomMockUser; import es.princip.getp.domain.client.query.dao.ClientDao; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -43,7 +43,7 @@ class GetMyClient { NICKNAME, PHONE_NUMBER, EMAIL, - profileImage(memberId).getUri(), + profileImage(memberId).getUrl(), address(), bankAccount(), now, diff --git a/src/test/java/es/princip/getp/api/controller/like/command/PeopleLikeControllerTest.java b/src/test/java/es/princip/getp/api/controller/like/command/PeopleLikeControllerTest.java index 071857c6..1cb5ded0 100644 --- a/src/test/java/es/princip/getp/api/controller/like/command/PeopleLikeControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/like/command/PeopleLikeControllerTest.java @@ -3,7 +3,7 @@ import es.princip.getp.api.controller.ControllerTest; import es.princip.getp.domain.like.command.application.PeopleLikeService; import es.princip.getp.domain.like.exception.AlreadyLikedException; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import es.princip.getp.domain.people.exception.NotFoundPeopleException; import es.princip.getp.api.security.annotation.WithCustomMockUser; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/es/princip/getp/api/controller/like/command/ProjectLikeControllerTest.java b/src/test/java/es/princip/getp/api/controller/like/command/ProjectLikeControllerTest.java index 97ee22a0..d1baaa87 100644 --- a/src/test/java/es/princip/getp/api/controller/like/command/ProjectLikeControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/like/command/ProjectLikeControllerTest.java @@ -3,7 +3,7 @@ import es.princip.getp.api.controller.ControllerTest; import es.princip.getp.api.security.annotation.WithCustomMockUser; import es.princip.getp.domain.like.command.application.ProjectLikeService; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/src/test/java/es/princip/getp/api/controller/member/command/MyMemberControllerTest.java b/src/test/java/es/princip/getp/api/controller/member/command/MyMemberControllerTest.java index 5c2a457e..70492bd2 100644 --- a/src/test/java/es/princip/getp/api/controller/member/command/MyMemberControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/member/command/MyMemberControllerTest.java @@ -2,13 +2,13 @@ import es.princip.getp.api.controller.ControllerTest; import es.princip.getp.api.security.annotation.WithCustomMockUser; -import es.princip.getp.domain.member.command.application.MemberService; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.application.member.command.ChangeProfileImageCommand; +import es.princip.getp.application.member.port.in.ChangeProfileImageUseCase; +import es.princip.getp.domain.member.model.MemberType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.multipart.MultipartFile; import static es.princip.getp.api.docs.FieldDescriptorHelper.getDescriptor; import static es.princip.getp.api.docs.HeaderDescriptorHelper.authorizationHeaderDescriptor; @@ -16,7 +16,6 @@ import static es.princip.getp.domain.member.fixture.ProfileImageFixture.profileImage; import static es.princip.getp.storage.fixture.ImageStorageFixture.imageMultiPartFile; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; import static org.springframework.restdocs.request.RequestDocumentation.partWithName; @@ -27,7 +26,7 @@ class MyMemberControllerTest extends ControllerTest { @Autowired - private MemberService memberService; + private ChangeProfileImageUseCase changeProfileImageUseCase; @Nested @DisplayName("프로필 업로드") @@ -39,8 +38,8 @@ class UploadProfileImage { @WithCustomMockUser(memberType = MemberType.ROLE_PEOPLE) @Test public void uploadProfileImage() throws Exception { - given(memberService.changeProfileImage(eq(memberId), any(MultipartFile.class))) - .willReturn(profileImage(memberId).getUri()); + given(changeProfileImageUseCase.changeProfileImage(any(ChangeProfileImageCommand.class))) + .willReturn(profileImage(memberId).getUrl()); mockMvc.perform(multipart("/member/me/profile-image") .file(imageMultiPartFile()) diff --git a/src/test/java/es/princip/getp/api/controller/member/query/MyMemberQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/member/query/MyMemberQueryControllerTest.java index 7f0f65f8..4bdb5c46 100644 --- a/src/test/java/es/princip/getp/api/controller/member/query/MyMemberQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/member/query/MyMemberQueryControllerTest.java @@ -2,7 +2,7 @@ import es.princip.getp.api.controller.ControllerTest; import es.princip.getp.api.security.annotation.WithCustomMockUser; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleControllerTest.java b/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleControllerTest.java index 87d5cf97..73877743 100644 --- a/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleControllerTest.java @@ -19,8 +19,8 @@ import static es.princip.getp.api.docs.HeaderDescriptorHelper.authorizationHeaderDescriptor; import static es.princip.getp.api.docs.PayloadDocumentationHelper.responseFields; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_CLIENT; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE; +import static es.princip.getp.domain.member.model.MemberType.ROLE_CLIENT; +import static es.princip.getp.domain.member.model.MemberType.ROLE_PEOPLE; import static es.princip.getp.domain.member.fixture.EmailFixture.EMAIL; import static es.princip.getp.domain.member.fixture.NicknameFixture.NICKNAME; import static es.princip.getp.domain.member.fixture.PhoneNumberFixture.PHONE_NUMBER; diff --git a/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleProfileControllerTest.java b/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleProfileControllerTest.java index 7442d981..5f349c84 100644 --- a/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleProfileControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/people/command/MyPeopleProfileControllerTest.java @@ -18,8 +18,8 @@ import static es.princip.getp.api.docs.HeaderDescriptorHelper.authorizationHeaderDescriptor; import static es.princip.getp.common.fixture.HashtagFixture.hashtagsRequest; import static es.princip.getp.common.fixture.TechStackFixture.techStacksRequest; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_CLIENT; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE; +import static es.princip.getp.domain.member.model.MemberType.ROLE_CLIENT; +import static es.princip.getp.domain.member.model.MemberType.ROLE_PEOPLE; import static es.princip.getp.domain.people.fixture.ActivityAreaFixture.activityArea; import static es.princip.getp.domain.people.fixture.EducationFixture.education; import static es.princip.getp.domain.people.fixture.IntroductionFixture.introduction; diff --git a/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleProfileQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleProfileQueryControllerTest.java index 67155991..16b26db9 100644 --- a/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleProfileQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleProfileQueryControllerTest.java @@ -16,8 +16,8 @@ import static es.princip.getp.api.docs.HeaderDescriptorHelper.authorizationHeaderDescriptor; import static es.princip.getp.common.fixture.HashtagFixture.hashtagsResponse; import static es.princip.getp.common.fixture.TechStackFixture.techStacksResponse; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_CLIENT; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE; +import static es.princip.getp.domain.member.model.MemberType.ROLE_CLIENT; +import static es.princip.getp.domain.member.model.MemberType.ROLE_PEOPLE; import static es.princip.getp.domain.people.fixture.ActivityAreaFixture.activityArea; import static es.princip.getp.domain.people.fixture.EducationFixture.education; import static es.princip.getp.domain.people.fixture.IntroductionFixture.introduction; diff --git a/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleQueryControllerTest.java index 546858cb..b958f71b 100644 --- a/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/people/query/MyPeopleQueryControllerTest.java @@ -17,8 +17,8 @@ import java.time.LocalDateTime; import static es.princip.getp.api.docs.HeaderDescriptorHelper.authorizationHeaderDescriptor; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_CLIENT; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE; +import static es.princip.getp.domain.member.model.MemberType.ROLE_CLIENT; +import static es.princip.getp.domain.member.model.MemberType.ROLE_PEOPLE; import static es.princip.getp.domain.member.fixture.EmailFixture.EMAIL; import static es.princip.getp.domain.member.fixture.NicknameFixture.NICKNAME; import static es.princip.getp.domain.member.fixture.PhoneNumberFixture.PHONE_NUMBER; @@ -52,7 +52,7 @@ public void getMyPeople(PrincipalDetails principalDetails) throws Exception { EMAIL, NICKNAME, PHONE_NUMBER, - profileImage(1L).getUri(), + profileImage(1L).getUrl(), PeopleType.INDIVIDUAL, 0, 0, diff --git a/src/test/java/es/princip/getp/api/controller/people/query/PeopleQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/people/query/PeopleQueryControllerTest.java index 96f3bbab..dbb595e9 100644 --- a/src/test/java/es/princip/getp/api/controller/people/query/PeopleQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/people/query/PeopleQueryControllerTest.java @@ -29,7 +29,7 @@ import static es.princip.getp.api.docs.PayloadDocumentationHelper.responseFields; import static es.princip.getp.common.fixture.HashtagFixture.hashtagsResponse; import static es.princip.getp.common.fixture.TechStackFixture.techStacksResponse; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE; +import static es.princip.getp.domain.member.model.MemberType.ROLE_PEOPLE; import static es.princip.getp.domain.member.fixture.NicknameFixture.NICKNAME; import static es.princip.getp.domain.member.fixture.ProfileImageFixture.profileImage; import static es.princip.getp.domain.people.fixture.ActivityAreaFixture.activityArea; @@ -71,7 +71,7 @@ public void getCardPeoplePage() throws Exception { new CardPeopleResponse( 1L, NICKNAME, - profileImage(1L).getUri(), + profileImage(1L).getUrl(), PeopleType.INDIVIDUAL, 0, 0, @@ -128,7 +128,7 @@ public void getPeople_WhenUserNotLogined() throws Exception { PublicDetailPeopleResponse response = new PublicDetailPeopleResponse( peopleId, NICKNAME, - profileImage(1L).getUri(), + profileImage(1L).getUrl(), PeopleType.INDIVIDUAL, 0, 0, @@ -154,7 +154,7 @@ public void getPeople_WhenUserLogined() throws Exception { DetailPeopleResponse response = new DetailPeopleResponse( 1L, NICKNAME, - profileImage(1L).getUri(), + profileImage(1L).getUrl(), PeopleType.INDIVIDUAL, 0, 0, diff --git a/src/test/java/es/princip/getp/api/controller/project/command/ProjectApplicationControllerTest.java b/src/test/java/es/princip/getp/api/controller/project/command/ProjectApplicationControllerTest.java index f7a63a0d..4238513b 100644 --- a/src/test/java/es/princip/getp/api/controller/project/command/ProjectApplicationControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/project/command/ProjectApplicationControllerTest.java @@ -6,7 +6,7 @@ import es.princip.getp.api.controller.project.command.dto.request.ApplyProjectRequest; import es.princip.getp.api.docs.PayloadDocumentationHelper; import es.princip.getp.api.security.annotation.WithCustomMockUser; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import es.princip.getp.domain.project.command.application.ProjectApplicationService; import es.princip.getp.domain.project.command.application.command.ApplyProjectCommand; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/es/princip/getp/api/controller/project/command/ProjectCommissionControllerTest.java b/src/test/java/es/princip/getp/api/controller/project/command/ProjectCommissionControllerTest.java index 1438ef73..83c915ad 100644 --- a/src/test/java/es/princip/getp/api/controller/project/command/ProjectCommissionControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/project/command/ProjectCommissionControllerTest.java @@ -6,7 +6,7 @@ import es.princip.getp.api.controller.project.command.dto.request.CommissionProjectRequest; import es.princip.getp.api.docs.PayloadDocumentationHelper; import es.princip.getp.api.security.annotation.WithCustomMockUser; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import es.princip.getp.domain.project.command.application.ProjectCommissionService; import es.princip.getp.domain.project.command.application.command.RegisterProjectCommand; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/es/princip/getp/api/controller/project/command/ProjectMeetingControllerTest.java b/src/test/java/es/princip/getp/api/controller/project/command/ProjectMeetingControllerTest.java index d71944c7..26986bbe 100644 --- a/src/test/java/es/princip/getp/api/controller/project/command/ProjectMeetingControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/project/command/ProjectMeetingControllerTest.java @@ -6,7 +6,7 @@ import es.princip.getp.api.controller.project.command.dto.request.ScheduleMeetingRequest; import es.princip.getp.api.docs.PayloadDocumentationHelper; import es.princip.getp.api.security.annotation.WithCustomMockUser; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import es.princip.getp.domain.project.command.application.ProjectMeetingService; import es.princip.getp.domain.project.command.application.command.ScheduleMeetingCommand; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/es/princip/getp/api/controller/project/query/AppliedProjectQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/project/query/AppliedProjectQueryControllerTest.java index 0101d9b6..9cb22575 100644 --- a/src/test/java/es/princip/getp/api/controller/project/query/AppliedProjectQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/project/query/AppliedProjectQueryControllerTest.java @@ -7,7 +7,7 @@ import es.princip.getp.api.security.annotation.WithCustomMockUser; import es.princip.getp.common.description.PaginationDescription; import es.princip.getp.common.domain.Duration; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import es.princip.getp.domain.project.command.domain.ProjectStatus; import es.princip.getp.domain.project.query.dao.AppliedProjectDao; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/es/princip/getp/api/controller/project/query/MyCommissionedProjectQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/project/query/MyCommissionedProjectQueryControllerTest.java index 19447775..ce3077b7 100644 --- a/src/test/java/es/princip/getp/api/controller/project/query/MyCommissionedProjectQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/project/query/MyCommissionedProjectQueryControllerTest.java @@ -7,7 +7,7 @@ import es.princip.getp.api.docs.PayloadDocumentationHelper; import es.princip.getp.api.security.annotation.WithCustomMockUser; import es.princip.getp.common.domain.Duration; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import es.princip.getp.domain.project.command.domain.ProjectStatus; import es.princip.getp.domain.project.query.dao.MyCommissionedProjectDao; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryControllerTest.java b/src/test/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryControllerTest.java index 5ac46e01..2b348c35 100644 --- a/src/test/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryControllerTest.java +++ b/src/test/java/es/princip/getp/api/controller/project/query/ProjectApplicantQueryControllerTest.java @@ -8,8 +8,8 @@ import es.princip.getp.api.controller.project.query.description.GetApplicantsByProjectIdQueryParameterDescription; import es.princip.getp.api.security.annotation.WithCustomMockUser; import es.princip.getp.api.security.details.PrincipalDetails; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.model.MemberType; import es.princip.getp.domain.people.command.domain.PeopleType; import es.princip.getp.domain.project.query.application.ProjectApplicantService; import org.junit.jupiter.api.DisplayName; @@ -77,7 +77,7 @@ void getApplicantsByProjectId(final PrincipalDetails principalDetails) throws Ex new DetailPeopleResponse( 1L, NICKNAME, - profileImage(1L).getUri(), + profileImage(1L).getUrl(), PeopleType.INDIVIDUAL, 0, 0, diff --git a/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUser.java b/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUser.java index f5c70c50..388b7d3a 100644 --- a/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUser.java +++ b/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUser.java @@ -1,12 +1,12 @@ package es.princip.getp.api.security.annotation; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.MemberType; import org.springframework.security.test.context.support.WithSecurityContext; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE; +import static es.princip.getp.domain.member.model.MemberType.ROLE_PEOPLE; import static es.princip.getp.domain.member.fixture.EmailFixture.EMAIL; import static es.princip.getp.domain.member.fixture.NicknameFixture.NICKNAME; import static es.princip.getp.domain.member.fixture.PasswordFixture.PASSWORD; diff --git a/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUserSecurityContextFactory.java b/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUserSecurityContextFactory.java index 563ae723..90c59782 100644 --- a/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUserSecurityContextFactory.java +++ b/src/test/java/es/princip/getp/api/security/annotation/WithCustomMockUserSecurityContextFactory.java @@ -1,7 +1,7 @@ package es.princip.getp.api.security.annotation; import es.princip.getp.api.security.details.PrincipalDetails; -import es.princip.getp.domain.member.command.domain.model.*; +import es.princip.getp.domain.member.model.*; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.authority.SimpleGrantedAuthority; diff --git a/src/test/java/es/princip/getp/domain/auth/application/SignUpServiceTest.java b/src/test/java/es/princip/getp/domain/auth/application/SignUpServiceTest.java deleted file mode 100644 index 284d5390..00000000 --- a/src/test/java/es/princip/getp/domain/auth/application/SignUpServiceTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package es.princip.getp.domain.auth.application; - -import es.princip.getp.domain.auth.application.command.SignUpCommand; -import es.princip.getp.domain.auth.exception.DuplicatedEmailException; -import es.princip.getp.domain.auth.exception.NotVerifiedEmailException; -import es.princip.getp.domain.member.command.application.MemberService; -import es.princip.getp.domain.member.command.application.command.CreateMemberCommand; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; -import es.princip.getp.domain.member.command.domain.model.MemberType; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.security.crypto.password.PasswordEncoder; - -import java.util.List; -import java.util.Optional; - -import static es.princip.getp.domain.auth.fixture.EmailVerificationFixture.VERIFICATION_CODE; -import static es.princip.getp.domain.member.fixture.EmailFixture.EMAIL; -import static es.princip.getp.domain.member.fixture.EmailFixture.email; -import static es.princip.getp.domain.member.fixture.MemberFixture.member; -import static es.princip.getp.domain.member.fixture.PasswordFixture.password; -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.*; - -@ExtendWith(MockitoExtension.class) -class SignUpServiceTest { - - @Mock - private VerificationService emailVerificationService; - - @Mock - private MemberService memberService; - - @Mock - private MemberRepository memberRepository; - - @Mock - private PasswordEncoder passwordEncoder; - - @InjectMocks - private SignUpService signUpService; - - @Nested - @DisplayName("sendEmailVerificationCodeForSignUp()은") - class SendEmailVerificationCodeForSignUp { - - @Test - @DisplayName("회원 가입을 위한 이메일 인증 코드를 전송한다.") - void sendEmailVerificationCodeForSignUp() { - Email email = Email.of(EMAIL); - given(memberRepository.existsByEmail(email)).willReturn(false); - - signUpService.sendEmailVerificationCodeForSignUp(email); - - verify(emailVerificationService, times(1)).sendVerificationCode(email); - } - - @Test - @DisplayName("이미 가입된 이메일인 경우 실패한다.") - void sendEmailVerificationCodeForSignUp_WhenEmailIsDuplicated_ShouldThrowException() { - Email email = Email.of(EMAIL); - given(memberRepository.existsByEmail(email)).willReturn(true); - - assertThatCode(() -> signUpService.sendEmailVerificationCodeForSignUp(email)) - .isInstanceOf(DuplicatedEmailException.class); - } - } - - @Nested - @DisplayName("signUp()은") - class SignUp { - - private final Long memberId = 1L; - private final SignUpCommand command = new SignUpCommand( - email(), password(), VERIFICATION_CODE, List.of(), MemberType.ROLE_PEOPLE - ); - - @DisplayName("회원 가입을 진행한다.") - @Test - void signUp() { - Member member = spy(member(command.memberType())); - given(memberService.create(any(CreateMemberCommand.class))).willReturn(memberId); - given(memberRepository.findById(memberId)).willReturn(Optional.of(member)); - - signUpService.signUp(command); - - verify(emailVerificationService, times(1)) - .verifyEmail(command.email(), command.verificationCode()); - verify(member, times(1)).encodePassword(passwordEncoder); - } - - @DisplayName("이메일이 인증되지 않은 경우 실패한다.") - @Test - void signUp_WhenEmailIsNotVerified_ShouldThrowException() { - doThrow(new NotVerifiedEmailException()) - .when(emailVerificationService) - .verifyEmail(command.email(), command.verificationCode()); - - assertThatCode(() -> signUpService.signUp(command)) - .isInstanceOf(NotVerifiedEmailException.class); - } - } -} \ No newline at end of file diff --git a/src/test/java/es/princip/getp/domain/auth/application/VerificationServiceTest.java b/src/test/java/es/princip/getp/domain/auth/application/VerificationServiceTest.java index c6983a9f..38f9f697 100644 --- a/src/test/java/es/princip/getp/domain/auth/application/VerificationServiceTest.java +++ b/src/test/java/es/princip/getp/domain/auth/application/VerificationServiceTest.java @@ -4,7 +4,7 @@ import es.princip.getp.domain.auth.domain.EmailVerificationRepository; import es.princip.getp.domain.auth.exception.IncorrectVerificationCodeException; import es.princip.getp.domain.auth.exception.NotFoundVerificationException; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/es/princip/getp/domain/auth/fixture/EmailVerificationFixture.java b/src/test/java/es/princip/getp/domain/auth/fixture/EmailVerificationFixture.java index a560b346..f3b8cc5e 100644 --- a/src/test/java/es/princip/getp/domain/auth/fixture/EmailVerificationFixture.java +++ b/src/test/java/es/princip/getp/domain/auth/fixture/EmailVerificationFixture.java @@ -1,7 +1,7 @@ package es.princip.getp.domain.auth.fixture; import es.princip.getp.domain.auth.domain.EmailVerification; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; public class EmailVerificationFixture { public static String VERIFICATION_CODE = "1234"; diff --git a/src/test/java/es/princip/getp/domain/client/command/application/ClientServiceTest.java b/src/test/java/es/princip/getp/domain/client/command/application/ClientServiceTest.java deleted file mode 100644 index a09a1803..00000000 --- a/src/test/java/es/princip/getp/domain/client/command/application/ClientServiceTest.java +++ /dev/null @@ -1,146 +0,0 @@ -package es.princip.getp.domain.client.command.application; - -import es.princip.getp.domain.client.command.application.command.EditClientCommand; -import es.princip.getp.domain.client.command.application.command.RegisterClientCommand; -import es.princip.getp.domain.client.command.domain.Client; -import es.princip.getp.domain.client.command.domain.ClientRepository; -import es.princip.getp.domain.member.command.application.MemberService; -import es.princip.getp.domain.member.command.application.command.UpdateMemberCommand; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.Optional; - -import static es.princip.getp.domain.client.fixture.AddressFixture.address; -import static es.princip.getp.domain.client.fixture.BankAccountFixture.bankAccount; -import static es.princip.getp.domain.member.fixture.EmailFixture.email; -import static es.princip.getp.domain.member.fixture.NicknameFixture.nickname; -import static es.princip.getp.domain.member.fixture.PhoneNumberFixture.phoneNumber; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.mockito.Mockito.*; - -@ExtendWith(MockitoExtension.class) -public class ClientServiceTest { - - @InjectMocks - private ClientService clientService; - - @Mock - private MemberService memberService; - - @Mock - private MemberRepository memberRepository; - - @Mock - private ClientRepository clientRepository; - - @Nested - @DisplayName("registerClient()는") - class RegisterClient { - - private final Long clientId = 1L; - private final Long memberId = 1L; - - @Test - @DisplayName("의뢰자 정보를 등록한다.") - void registerClient() { - final RegisterClientCommand command = new RegisterClientCommand( - memberId, - nickname(), - email(), - phoneNumber(), - address(), - bankAccount() - ); - final Client client = spy(Client.class); - - given(client.getClientId()).willReturn(clientId); - willDoNothing().given(memberService).update(eq(UpdateMemberCommand.from(command))); - given(clientRepository.save(any(Client.class))).willReturn(client); - - final Long clientId = clientService.registerClient(command); - - assertThat(clientId).isEqualTo(this.clientId); - } - - @Test - @DisplayName("이메일이 입력되지 않은 경우 회원 정보의 이메일 주소를 사용한다.") - void registerClient_WhenEmailIsNull_UseEmailOfMember() { - final RegisterClientCommand command = new RegisterClientCommand( - memberId, - nickname(), - null, - phoneNumber(), - address(), - bankAccount() - ); - final Client client = spy(Client.class); - final Member member = spy(Member.class); - - given(client.getClientId()).willReturn(clientId); - given(member.getEmail()).willReturn(email()); - willDoNothing().given(memberService).update(eq(UpdateMemberCommand.from(command))); - given(memberRepository.findById(command.memberId())).willReturn(Optional.of(member)); - given(clientRepository.save(any(Client.class))).willReturn(client); - - final Long clientId = clientService.registerClient(command); - - assertThat(clientId).isEqualTo(this.clientId); - } - } - - @Nested - @DisplayName("editClient()는") - class EditClient { - - private final Long memberId = 1L; - - @Test - @DisplayName("의뢰자 정보를 수정한다.") - void editClient() { - final EditClientCommand command = new EditClientCommand( - memberId, - nickname(), - email(), - phoneNumber(), - address(), - bankAccount() - ); - final Client client = spy(Client.class); - given(clientRepository.findByMemberId(command.memberId())).willReturn(Optional.of(client)); - - clientService.editClient(command); - - verify(client, times(1)).edit(command.email(), command.address(), command.bankAccount()); - } - } - - @Nested - @DisplayName("delete()는") - class Delete { - - final Long memberId = 1L; - - @Test - @DisplayName("의뢰자 정보를 삭제한다.") - void delete() { - final Client client = spy(Client.class); - given(clientRepository.findByMemberId(memberId)).willReturn(Optional.of(client)); - - clientService.delete(memberId); - - verify(clientRepository, times(1)).delete(client); - } - } -} \ No newline at end of file diff --git a/src/test/java/es/princip/getp/domain/client/query/infra/ClientDataLoader.java b/src/test/java/es/princip/getp/domain/client/query/infra/ClientDataLoader.java index 2ab65665..c36b1c1a 100644 --- a/src/test/java/es/princip/getp/domain/client/query/infra/ClientDataLoader.java +++ b/src/test/java/es/princip/getp/domain/client/query/infra/ClientDataLoader.java @@ -2,16 +2,17 @@ import es.princip.getp.common.util.DataLoader; import es.princip.getp.domain.client.command.domain.Client; -import es.princip.getp.domain.member.command.domain.model.Member; +import es.princip.getp.domain.member.model.MemberType; +import es.princip.getp.persistence.adapter.member.MemberJpaEntity; import jakarta.persistence.EntityManager; import lombok.RequiredArgsConstructor; import java.util.ArrayList; import java.util.List; +import java.util.stream.LongStream; import static es.princip.getp.domain.client.fixture.ClientFixture.clientList; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_CLIENT; -import static es.princip.getp.domain.member.fixture.MemberFixture.memberList; +import static es.princip.getp.domain.member.fixture.PasswordFixture.PASSWORD; @RequiredArgsConstructor public class ClientDataLoader implements DataLoader { @@ -20,12 +21,18 @@ public class ClientDataLoader implements DataLoader { @Override public void load(final int size) { - final List memberList = memberList(size, 1, ROLE_CLIENT); + final List memberList = LongStream.range(1, 1 + size) + .mapToObj(i -> MemberJpaEntity.builder() + .email("test" + i + "@example.com") + .password(PASSWORD) + .memberType(MemberType.ROLE_CLIENT) + .build()) + .toList(); memberList.forEach(entityManager::persist); final Long memberIdBias = memberList.stream() .findFirst() - .map(Member::getMemberId) + .map(MemberJpaEntity::getMemberId) .orElse(1L); final List clientList = new ArrayList<>(clientList(size, memberIdBias)); @@ -35,7 +42,7 @@ public void load(final int size) { @Override public void teardown() { entityManager.createQuery("DELETE FROM Client").executeUpdate(); - entityManager.createQuery("DELETE FROM Member").executeUpdate(); + entityManager.createQuery("DELETE FROM MemberJpaEntity").executeUpdate(); entityManager.createNativeQuery("ALTER TABLE member AUTO_INCREMENT = 1") .executeUpdate(); entityManager.createNativeQuery("ALTER TABLE client AUTO_INCREMENT = 1") diff --git a/src/test/java/es/princip/getp/domain/member/command/application/MemberServiceTest.java b/src/test/java/es/princip/getp/domain/member/command/application/MemberServiceTest.java deleted file mode 100644 index 5058c9c4..00000000 --- a/src/test/java/es/princip/getp/domain/member/command/application/MemberServiceTest.java +++ /dev/null @@ -1,127 +0,0 @@ -package es.princip.getp.domain.member.command.application; - -import es.princip.getp.domain.member.command.application.command.CreateMemberCommand; -import es.princip.getp.domain.member.command.application.command.UpdateMemberCommand; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberRepository; -import es.princip.getp.domain.member.command.domain.model.MemberType; -import es.princip.getp.domain.member.command.domain.model.ProfileImage; -import es.princip.getp.domain.member.command.domain.service.ProfileImageService; -import es.princip.getp.domain.member.command.domain.service.ServiceTermAgreementService; -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.web.multipart.MultipartFile; - -import java.util.List; -import java.util.Optional; - -import static es.princip.getp.domain.member.fixture.EmailFixture.email; -import static es.princip.getp.domain.member.fixture.MemberFixture.member; -import static es.princip.getp.domain.member.fixture.NicknameFixture.nickname; -import static es.princip.getp.domain.member.fixture.PasswordFixture.password; -import static es.princip.getp.domain.member.fixture.PhoneNumberFixture.phoneNumber; -import static es.princip.getp.domain.member.fixture.ProfileImageFixture.profileImage; -import static es.princip.getp.storage.fixture.ImageStorageFixture.imageMultiPartFile; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willDoNothing; -import static org.mockito.Mockito.*; - -@Slf4j -@ExtendWith(MockitoExtension.class) -class MemberServiceTest { - - @Mock - private MemberRepository memberRepository; - - @Mock - private ServiceTermAgreementService agreementService; - - @Mock - private ProfileImageService profileImageService; - - @InjectMocks - private MemberService memberService; - - @DisplayName("create()는") - @Nested - class Create { - - private final Long memberId = 1L; - private final CreateMemberCommand command = new CreateMemberCommand( - email(), password(), List.of(), MemberType.ROLE_PEOPLE - ); - - @DisplayName("회원을 생성한다.") - @Test - void create() { - Member member = spy(Member.class); - given(member.getMemberId()).willReturn(memberId); - given(memberRepository.existsByEmail(command.email())).willReturn(false); - willDoNothing().given(agreementService).agreeServiceTerms(any(Member.class), anyList()); - given(memberRepository.save(any(Member.class))).willReturn(member); - - Long memberId = memberService.create(command); - - assertThat(memberId).isEqualTo(member.getMemberId()); - verify(agreementService, times(1)).agreeServiceTerms(any(Member.class), anyList()); - } - } - - @Nested - @DisplayName("update()는") - class Update { - - private final Long memberId = 1L; - private final UpdateMemberCommand command = new UpdateMemberCommand( - memberId, nickname(), phoneNumber() - ); - - @DisplayName("회원 정보를 수정한다.") - @Test - void update() { - Member member = spy(Member.class); - given(memberRepository.findById(memberId)).willReturn(Optional.of(member)); - - memberService.update(command); - - verify(member, times(1)).edit(command.nickname(), command.phoneNumber()); - } - } - - @Nested - @DisplayName("updateProfileImage()는") - class UpdateProfileImage { - - private final Member member = spy(member(MemberType.ROLE_PEOPLE)); - private final MultipartFile image = imageMultiPartFile(); - - @BeforeEach - void setUp() { - given(member.getMemberId()).willReturn(1L); - } - - @DisplayName("프로필 이미지를 수정한다.") - @Test - void updateProfileImage() { - ProfileImage profileImage = profileImage(member.getMemberId()); - given(member.hasProfileImage()).willReturn(true); - given(member.getProfileImage()).willReturn(profileImage); - given(memberRepository.findById(member.getMemberId())).willReturn(Optional.of(member)); - given(profileImageService.saveProfileImage(member, image)).willReturn(profileImage); - - memberService.changeProfileImage(member.getMemberId(), image); - - verify(profileImageService, times(1)).deleteProfileImage(profileImage); - verify(profileImageService, times(1)).saveProfileImage(member, image); - assertThat(member.getProfileImage()).isEqualTo(profileImage); - } - } -} \ No newline at end of file diff --git a/src/test/java/es/princip/getp/domain/member/fixture/EmailFixture.java b/src/test/java/es/princip/getp/domain/member/fixture/EmailFixture.java index 453028e8..ebde1550 100644 --- a/src/test/java/es/princip/getp/domain/member/fixture/EmailFixture.java +++ b/src/test/java/es/princip/getp/domain/member/fixture/EmailFixture.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.member.fixture; -import es.princip.getp.domain.member.command.domain.model.Email; +import es.princip.getp.domain.member.model.Email; public class EmailFixture { public static final String EMAIL = "test@example.com"; diff --git a/src/test/java/es/princip/getp/domain/member/fixture/MemberFixture.java b/src/test/java/es/princip/getp/domain/member/fixture/MemberFixture.java index b8d33523..ea8f441d 100644 --- a/src/test/java/es/princip/getp/domain/member/fixture/MemberFixture.java +++ b/src/test/java/es/princip/getp/domain/member/fixture/MemberFixture.java @@ -1,8 +1,8 @@ package es.princip.getp.domain.member.fixture; -import es.princip.getp.domain.member.command.domain.model.Email; -import es.princip.getp.domain.member.command.domain.model.Member; -import es.princip.getp.domain.member.command.domain.model.MemberType; +import es.princip.getp.domain.member.model.Email; +import es.princip.getp.domain.member.model.Member; +import es.princip.getp.domain.member.model.MemberType; import java.util.List; import java.util.stream.IntStream; diff --git a/src/test/java/es/princip/getp/domain/member/fixture/NicknameFixture.java b/src/test/java/es/princip/getp/domain/member/fixture/NicknameFixture.java index daf8351c..27cd9bf6 100644 --- a/src/test/java/es/princip/getp/domain/member/fixture/NicknameFixture.java +++ b/src/test/java/es/princip/getp/domain/member/fixture/NicknameFixture.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.member.fixture; -import es.princip.getp.domain.member.command.domain.model.Nickname; +import es.princip.getp.domain.member.model.Nickname; public class NicknameFixture { public static final String NICKNAME = "닉네임"; diff --git a/src/test/java/es/princip/getp/domain/member/fixture/PasswordFixture.java b/src/test/java/es/princip/getp/domain/member/fixture/PasswordFixture.java index 5c698cbb..9cafeb5a 100644 --- a/src/test/java/es/princip/getp/domain/member/fixture/PasswordFixture.java +++ b/src/test/java/es/princip/getp/domain/member/fixture/PasswordFixture.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.member.fixture; -import es.princip.getp.domain.member.command.domain.model.Password; +import es.princip.getp.domain.member.model.Password; public class PasswordFixture { diff --git a/src/test/java/es/princip/getp/domain/member/fixture/PhoneNumberFixture.java b/src/test/java/es/princip/getp/domain/member/fixture/PhoneNumberFixture.java index 4a756c8a..acac8af4 100644 --- a/src/test/java/es/princip/getp/domain/member/fixture/PhoneNumberFixture.java +++ b/src/test/java/es/princip/getp/domain/member/fixture/PhoneNumberFixture.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.member.fixture; -import es.princip.getp.domain.member.command.domain.model.PhoneNumber; +import es.princip.getp.domain.member.model.PhoneNumber; public class PhoneNumberFixture { public static final String PHONE_NUMBER = "01012345678"; diff --git a/src/test/java/es/princip/getp/domain/member/fixture/ProfileImageFixture.java b/src/test/java/es/princip/getp/domain/member/fixture/ProfileImageFixture.java index 91fd6cf3..6f9d8b7c 100644 --- a/src/test/java/es/princip/getp/domain/member/fixture/ProfileImageFixture.java +++ b/src/test/java/es/princip/getp/domain/member/fixture/ProfileImageFixture.java @@ -1,6 +1,6 @@ package es.princip.getp.domain.member.fixture; -import es.princip.getp.domain.member.command.domain.model.ProfileImage; +import es.princip.getp.domain.member.model.ProfileImage; import java.net.URI; diff --git a/src/test/java/es/princip/getp/domain/member/command/infra/SimplePasswordEncoder.java b/src/test/java/es/princip/getp/domain/member/infra/SimplePasswordEncoder.java similarity index 88% rename from src/test/java/es/princip/getp/domain/member/command/infra/SimplePasswordEncoder.java rename to src/test/java/es/princip/getp/domain/member/infra/SimplePasswordEncoder.java index 1e14d6ed..d2c346b3 100644 --- a/src/test/java/es/princip/getp/domain/member/command/infra/SimplePasswordEncoder.java +++ b/src/test/java/es/princip/getp/domain/member/infra/SimplePasswordEncoder.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.infra; +package es.princip.getp.domain.member.infra; import org.springframework.security.crypto.password.PasswordEncoder; diff --git a/src/test/java/es/princip/getp/domain/member/command/domain/model/EmailTest.java b/src/test/java/es/princip/getp/domain/member/model/EmailTest.java similarity index 95% rename from src/test/java/es/princip/getp/domain/member/command/domain/model/EmailTest.java rename to src/test/java/es/princip/getp/domain/member/model/EmailTest.java index 3c82f1e6..5bb0e89c 100644 --- a/src/test/java/es/princip/getp/domain/member/command/domain/model/EmailTest.java +++ b/src/test/java/es/princip/getp/domain/member/model/EmailTest.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/es/princip/getp/domain/member/command/domain/model/MemberTest.java b/src/test/java/es/princip/getp/domain/member/model/MemberTest.java similarity index 97% rename from src/test/java/es/princip/getp/domain/member/command/domain/model/MemberTest.java rename to src/test/java/es/princip/getp/domain/member/model/MemberTest.java index bdc5c7a9..1f9a4be6 100644 --- a/src/test/java/es/princip/getp/domain/member/command/domain/model/MemberTest.java +++ b/src/test/java/es/princip/getp/domain/member/model/MemberTest.java @@ -1,4 +1,4 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/src/test/java/es/princip/getp/domain/member/command/domain/model/PasswordTest.java b/src/test/java/es/princip/getp/domain/member/model/PasswordTest.java similarity index 95% rename from src/test/java/es/princip/getp/domain/member/command/domain/model/PasswordTest.java rename to src/test/java/es/princip/getp/domain/member/model/PasswordTest.java index 8db98be8..cd6fd622 100644 --- a/src/test/java/es/princip/getp/domain/member/command/domain/model/PasswordTest.java +++ b/src/test/java/es/princip/getp/domain/member/model/PasswordTest.java @@ -1,6 +1,6 @@ -package es.princip.getp.domain.member.command.domain.model; +package es.princip.getp.domain.member.model; -import es.princip.getp.domain.member.command.infra.SimplePasswordEncoder; +import es.princip.getp.domain.member.infra.SimplePasswordEncoder; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/src/test/java/es/princip/getp/domain/people/query/infra/PeopleDataLoader.java b/src/test/java/es/princip/getp/domain/people/query/infra/PeopleDataLoader.java index 5f4170ec..8facc375 100644 --- a/src/test/java/es/princip/getp/domain/people/query/infra/PeopleDataLoader.java +++ b/src/test/java/es/princip/getp/domain/people/query/infra/PeopleDataLoader.java @@ -1,16 +1,17 @@ package es.princip.getp.domain.people.query.infra; import es.princip.getp.common.util.DataLoader; -import es.princip.getp.domain.member.command.domain.model.Member; import es.princip.getp.domain.people.command.domain.People; import es.princip.getp.domain.people.command.domain.PeopleType; +import es.princip.getp.persistence.adapter.member.MemberJpaEntity; import jakarta.persistence.EntityManager; import lombok.RequiredArgsConstructor; import java.util.List; +import java.util.stream.LongStream; -import static es.princip.getp.domain.member.command.domain.model.MemberType.ROLE_PEOPLE; -import static es.princip.getp.domain.member.fixture.MemberFixture.memberList; +import static es.princip.getp.domain.member.model.MemberType.ROLE_PEOPLE; +import static es.princip.getp.domain.member.fixture.PasswordFixture.PASSWORD; import static es.princip.getp.domain.people.fixture.PeopleFixture.peopleList; @RequiredArgsConstructor @@ -20,12 +21,18 @@ public class PeopleDataLoader implements DataLoader { @Override public void load(final int size) { - final List memberList = memberList(size, 1, ROLE_PEOPLE); + final List memberList = LongStream.range(1, 1 + size) + .mapToObj(i -> MemberJpaEntity.builder() + .email("test" + i + "@example.com") + .password(PASSWORD) + .memberType(ROLE_PEOPLE) + .build()) + .toList(); memberList.forEach(entityManager::persist); final Long memberIdBias = memberList.stream() .findFirst() - .map(Member::getMemberId) + .map(MemberJpaEntity::getMemberId) .orElse(1L); final int individualSize = size / 2; final int teamSize = (size % 2) == 0 ? size / 2 : (size / 2) + 1; @@ -39,7 +46,7 @@ public void load(final int size) { @Override public void teardown() { entityManager.createQuery("DELETE FROM People").executeUpdate(); - entityManager.createQuery("DELETE FROM Member").executeUpdate(); + entityManager.createQuery("DELETE FROM MemberJpaEntity").executeUpdate(); entityManager.createNativeQuery("ALTER TABLE member AUTO_INCREMENT = 1").executeUpdate(); entityManager.createNativeQuery("ALTER TABLE people AUTO_INCREMENT = 1").executeUpdate(); }