diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt index 77f80fa5..9dd7cd39 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCase.kt @@ -14,8 +14,9 @@ import team.comit.simtong.global.annotation.UseCase * 관리자의 로그인 기능을 담당하는 AdminSignInUseCase * * @author Chokyunghyeon + * @author kimbeomjin * @date 2022/10/04 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class AdminSignInUseCase( @@ -26,13 +27,10 @@ class AdminSignInUseCase( fun execute(request: AdminSignInRequest): TokenResponse { val admin = queryUserPort.queryUserByEmployeeNumber(request.employeeNumber) + ?.apply { this.checkAuthority(Authority.ROLE_ADMIN) } ?: throw UserExceptions.NotFound("관리자가 존재하지 않습니다.") - if (Authority.ROLE_COMMON == admin.authority) { - throw UserExceptions.DifferentPermissionAccount("관리자 계정이 아닙니다.") - } - - if (!securityPort.compare(request.password, admin.password)) { + if (!securityPort.compare(request.password, admin.password.value)) { throw UserExceptions.DifferentPassword() } @@ -41,5 +39,4 @@ class AdminSignInUseCase( authority = admin.authority ) } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt index 768a6815..51d14318 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCase.kt @@ -15,7 +15,7 @@ import team.comit.simtong.global.annotation.UseCase * * @author Chokyunghyeon * @date 2022/10/03 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class ChangeEmailUseCase( @@ -38,13 +38,10 @@ class ChangeEmailUseCase( } val currentUserId = securityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() + val employee = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() commandUserPort.save( - user.copy( - email = request.email - ) + employee.changeEmail(request.email) ) } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt index 7dade2d5..3b58c9e7 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCase.kt @@ -13,7 +13,7 @@ import team.comit.simtong.global.annotation.UseCase * * @author Chokyunghyeon * @date 2022/10/03 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class ChangeNicknameUseCase( @@ -28,12 +28,10 @@ class ChangeNicknameUseCase( } val currentUserId = securityPort.getCurrentUserId() - val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() + val employee = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() commandUserPort.save( - user.copy( - nickname = request.nickname - ) + employee.changeNickname(request.nickname) ) } } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt index ff2ebb58..398faddb 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCase.kt @@ -13,28 +13,27 @@ import team.comit.simtong.global.annotation.UseCase * * @author Chokyunghyeon * @date 2022/10/14 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class ChangePasswordUseCase( private val queryUserPort: QueryUserPort, - private val userSecurityPort: UserSecurityPort, + private val securityPort: UserSecurityPort, private val commandUserPort: CommandUserPort ) { fun execute(request: ChangePasswordRequest) { - val currentUserId = userSecurityPort.getCurrentUserId() + val currentUserId = securityPort.getCurrentUserId() val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() - if (!userSecurityPort.compare(request.password, user.password)) { + if (!securityPort.compare(request.password, user.password.value)) { throw UserExceptions.DifferentPassword() } commandUserPort.save( - user.copy( - password = userSecurityPort.encode(request.newPassword) + user.changePassword( + password = securityPort.encode(request.newPassword) ) ) } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt index 2b174310..c80255a8 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCase.kt @@ -15,7 +15,7 @@ import team.comit.simtong.global.annotation.UseCase * * @author Chokyunghyeon * @date 2022/10/03 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class ChangeProfileImageUseCase( @@ -34,10 +34,9 @@ class ChangeProfileImageUseCase( val user = queryUserPort.queryUserById(currentUserId) ?: throw UserExceptions.NotFound() commandUserPort.save( - user.copy( + user.changeProfileImage( profileImagePath = request.profileImagePath ) ) } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt index 2336c910..3a7a1348 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCase.kt @@ -15,7 +15,7 @@ import java.util.UUID * * @author kimbeomjin * @date 2022/10/15 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class ChangeSpotUseCase( @@ -34,10 +34,9 @@ class ChangeSpotUseCase( } commandUserPort.save( - user.copy( + user.changeSpot( spotId = newSpotId ) ) } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt index ed84637a..5b23f27a 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt @@ -22,5 +22,4 @@ class CheckEmailDuplicationUseCase( throw AuthExceptions.AlreadyUsedEmail() } } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt index 3d7c296c..34600ab9 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckMatchedAccountUseCase.kt @@ -24,5 +24,4 @@ class CheckMatchedAccountUseCase( throw UserExceptions.NotFound() } } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt index 9f53e311..f1eaafc2 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckNicknameDuplicationUseCase.kt @@ -22,5 +22,4 @@ class CheckNicknameDuplicationUseCase( throw UserExceptions.AlreadyUsedNickname() } } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt index 41108351..e092415c 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCase.kt @@ -11,7 +11,7 @@ import team.comit.simtong.global.annotation.ReadOnlyUseCase * * @author Chokyunghyeon * @date 2022/12/05 - * @version 1.0.0 + * @version 1.2.5 **/ @ReadOnlyUseCase class ComparePasswordUseCase( @@ -23,9 +23,8 @@ class ComparePasswordUseCase( val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) ?: throw UserExceptions.NotFound() - if (!securityPort.compare(password, user.password)) { + if (!securityPort.compare(password, user.password.value)) { throw UserExceptions.DifferentPassword() } } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt index de06dcd6..e1c8701e 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCase.kt @@ -11,7 +11,7 @@ import team.comit.simtong.global.annotation.UseCase * * @author Chokyunghyeon * @date 2022/09/11 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class FindEmployeeNumberUseCase( @@ -22,7 +22,6 @@ class FindEmployeeNumberUseCase( val user = queryUserPort.queryUserByNameAndSpotAndEmail(request.name, request.spotId, request.email) ?: throw UserExceptions.NotFound() - return user.employeeNumber + return user.employeeNumber.value } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt index ecdf4797..adc20ccb 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCase.kt @@ -14,7 +14,7 @@ import team.comit.simtong.global.annotation.ReadOnlyUseCase * * @author Chokyunghyeon * @date 2022/12/11 - * @version 1.0.0 + * @version 1.2.5 **/ @ReadOnlyUseCase class QueryAdminInfoUseCase( @@ -33,7 +33,7 @@ class QueryAdminInfoUseCase( return QueryAdminInfoResponse( name = user.name, email = user.email, - nickname = user.nickname, + nickname = user.nickname.value, spot = QueryAdminInfoResponse.SpotResponse( id = spot.id, name = spot.name diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt index 0f935a4b..72c0aeba 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCase.kt @@ -14,7 +14,7 @@ import team.comit.simtong.global.annotation.ReadOnlyUseCase * * @author Chokyunghyeon * @date 2022/09/27 - * @version 1.0.0 + * @version 1.2.5 **/ @ReadOnlyUseCase class QueryUserInfoUseCase( @@ -32,7 +32,7 @@ class QueryUserInfoUseCase( return QueryUserInfoResponse( name = user.name, email = user.email, - nickname = user.nickname, + nickname = user.nickname.value, spot = spot.name, profileImagePath = user.profileImagePath ) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt index c2b77cbb..a21d9444 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCase.kt @@ -16,7 +16,7 @@ import team.comit.simtong.global.annotation.UseCase * * @author Chokyunghyeon * @date 2022/09/27 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class ResetPasswordUseCase( @@ -39,7 +39,7 @@ class ResetPasswordUseCase( ?: throw UserExceptions.NotFound() commandUserPort.save( - user.copy( + user.changePassword( password = securityPort.encode(request.newPassword) ) ) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt index 93cb85f6..c5e5b4ca 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCase.kt @@ -17,39 +17,35 @@ import team.comit.simtong.global.annotation.UseCase * * @author kimbeomjin * @date 2022/09/08 - * @version 1.0.0 + * @version 1.2.5 **/ @UseCase class SignInUseCase( private val queryUserPort: QueryUserPort, - private val userSecurityPort: UserSecurityPort, - private val userJwtPort: UserJwtPort, + private val securityPort: UserSecurityPort, + private val jwtPort: UserJwtPort, private val commandDeviceTokenPort: CommandDeviceTokenPort ) { fun execute(request: UserSignInRequest): TokenResponse { - val user = queryUserPort.queryUserByEmployeeNumber(request.employeeNumber) + val employee = queryUserPort.queryUserByEmployeeNumber(request.employeeNumber) + ?.apply { checkAuthority(Authority.ROLE_COMMON) } ?: throw UserExceptions.NotFound() - if (Authority.ROLE_COMMON != user.authority) { - throw UserExceptions.DifferentPermissionAccount("사원 계정이 아닙니다.") - } - - if (!userSecurityPort.compare(request.password, user.password)) { + if (!securityPort.compare(request.password, employee.password.value)) { throw UserExceptions.DifferentPassword() } commandDeviceTokenPort.save( - DeviceToken( - userId = user.id, + DeviceToken.of( + userId = employee.id, token = request.deviceToken ) ) - return userJwtPort.receiveToken( - userId = user.id, + return jwtPort.receiveToken( + userId = employee.id, authority = Authority.ROLE_COMMON ) } - } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt index f3e3d03a..e5561f57 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCase.kt @@ -21,6 +21,7 @@ import team.comit.simtong.domain.user.spi.UserQuerySpotPort import team.comit.simtong.domain.user.spi.UserQueryTeamPort import team.comit.simtong.domain.user.spi.UserSecurityPort import team.comit.simtong.global.annotation.UseCase +import java.util.UUID /** * @@ -29,7 +30,7 @@ import team.comit.simtong.global.annotation.UseCase * @author Chokyunghyeon * @author kimbeomjin * @date 2022/09/04 - * @version 1.2.1 + * @version 1.2.5 **/ @UseCase class SignUpUseCase( @@ -46,62 +47,66 @@ class SignUpUseCase( ) { fun execute(request: SignUpRequest): TokenResponse { - val (name, email, password, nickname, employeeNumber, profileImagePath) = request - - when { - queryUserPort.existsUserByEmail(email) -> - throw AuthExceptions.AlreadyUsedEmail() - - queryUserPort.existsUserByEmployeeNumber(employeeNumber) -> - throw AuthExceptions.AlreadyUsedEmployeeNumber() - - queryUserPort.existsUserByNickname(nickname) -> - throw UserExceptions.AlreadyUsedNickname() - } - - val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(email) + val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(request.email) ?: throw AuthExceptions.RequiredNewEmailAuthentication() if (!authCodeLimit.verified) { throw AuthExceptions.UncertifiedEmail() } - val employeeCertificate = queryEmployeeCertificatePort.queryEmployeeCertificateByNameAndEmployeeNumber(name, employeeNumber) - ?: throw FileExceptions.NotExistsEmployee() + val user = create(request) + + commandAuthCodeLimitPort.delete(authCodeLimit) + + return jwtPort.receiveToken( + userId = user.id, + authority = user.authority + ) + } + + private fun create(request: SignUpRequest): User { + checkAlreadyExists(request.email, request.employeeNumber, request.nickname) - val spot = querySpotPort.querySpotByName(employeeCertificate.spotName) - ?: throw SpotExceptions.NotFound() + val employeeCertificate = queryEmployeeCertificatePort.queryEmployeeCertificateByNameAndEmployeeNumber( + request.name, request.employeeNumber + ) ?: throw FileExceptions.NotExistsEmployee() - val team = queryTeamPort.queryTeamByName(employeeCertificate.teamName) - ?: throw TeamExceptions.NotFound() + val spot = querySpotPort.querySpotByName(employeeCertificate.spotName) ?: throw SpotExceptions.NotFound() + val team = queryTeamPort.queryTeamByName(employeeCertificate.teamName) ?: throw TeamExceptions.NotFound() - val user = commandUserPort.save( - User( - nickname = nickname, - name = name, - email = email, - password = securityPort.encode(password), - employeeNumber = employeeNumber, + return commandUserPort.save( + User.of( + nickname = request.nickname, + name = request.name, + email = request.email, + password = securityPort.encode(request.password), + employeeNumber = request.employeeNumber, authority = Authority.ROLE_COMMON, spotId = spot.id, teamId = team.id, - profileImagePath = profileImagePath ?: User.DEFAULT_IMAGE + profileImagePath = request.profileImagePath ?: User.DEFAULT_IMAGE ) - ) - - commandAuthCodeLimitPort.delete(authCodeLimit) + ).apply { + createdDeviceToken(id, request.deviceToken) + } + } + private fun createdDeviceToken(userId: UUID, token: String) { commandDeviceTokenPort.save( - DeviceToken( - userId = user.id, - token = request.deviceToken + DeviceToken.of( + userId = userId, + token = token ) ) - - return jwtPort.receiveToken( - userId = user.id, - authority = user.authority - ) } + private fun checkAlreadyExists(email: String, employeeNumber: Int, nickname: String) { + when { + queryUserPort.existsUserByEmail(email) -> throw AuthExceptions.AlreadyUsedEmail() + + queryUserPort.existsUserByEmployeeNumber(employeeNumber) -> throw AuthExceptions.AlreadyUsedEmployeeNumber() + + queryUserPort.existsUserByNickname(nickname) -> throw UserExceptions.AlreadyUsedNickname() + } + } } \ No newline at end of file diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointAnnualUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointAnnualUseCaseTests.kt index 0002a181..b4404749 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointAnnualUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointAnnualUseCaseTests.kt @@ -43,7 +43,7 @@ class AppointAnnualUseCaseTests { private val date: LocalDate = LocalDate.MAX private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", @@ -133,14 +133,6 @@ class AppointAnnualUseCaseTests { @Test fun `이미 연차일때`() { // given - val annualStub = Holiday( - date = date, - spotId = id, - type = HolidayType.ANNUAL, - employeeId = id, - status = HolidayStatus.COMPLETED - ) - given(securityPort.getCurrentUserId()) .willReturn(id) diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayPeriodUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayPeriodUseCaseTests.kt index bf34bb4d..5237e1d6 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayPeriodUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayPeriodUseCaseTests.kt @@ -34,7 +34,7 @@ class AppointHolidayPeriodUseCaseTests { private val id: UUID = UUID.randomUUID() private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", email = "test@test.com", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt index e8ac96cc..e0143c4a 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/AppointHolidayUseCaseTests.kt @@ -49,7 +49,7 @@ class AppointHolidayUseCaseTests { private val date: LocalDate = LocalDate.now() private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ChangeEmployeeHolidayUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ChangeEmployeeHolidayUseCaseTests.kt index 9d399894..a7d70cbf 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ChangeEmployeeHolidayUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ChangeEmployeeHolidayUseCaseTests.kt @@ -44,7 +44,7 @@ class ChangeEmployeeHolidayUseCaseTests { private val spotId = UUID.randomUUID() private val userStub by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCaseTests.kt index 4efd0cdc..a5da76c4 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCaseTests.kt @@ -36,7 +36,7 @@ class CheckHolidayPeriodUseCaseTests { private val date: LocalDate = LocalDate.now() private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryEmployeeHolidayUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryEmployeeHolidayUseCaseTests.kt index 60ea3398..17db5092 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryEmployeeHolidayUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryEmployeeHolidayUseCaseTests.kt @@ -39,7 +39,7 @@ class QueryEmployeeHolidayUseCaseTests { private val teamId = UUID.randomUUID() private val userStub by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryMonthHolidayPeriodUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryMonthHolidayPeriodUseCaseTests.kt index 70ac0084..a2c8cc13 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryMonthHolidayPeriodUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/QueryMonthHolidayPeriodUseCaseTests.kt @@ -46,7 +46,7 @@ class QueryMonthHolidayPeriodUseCaseTests { private val endAt: LocalDate = LocalDate.now() private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", email = "test@test.com", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ShareHolidayUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ShareHolidayUseCaseTests.kt index 867572fc..5af1d4d9 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ShareHolidayUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/holiday/usecase/ShareHolidayUseCaseTests.kt @@ -41,7 +41,7 @@ class ShareHolidayUseCaseTests { private val spotId: UUID = UUID.randomUUID() private val userStub by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt index 1e53fdca..08e4633c 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt @@ -36,7 +36,7 @@ class QueryMenuByMonthUseCaseTests { private val now = LocalDate.now() private val userStub: User by lazy { - User( + User.of( id = currentUserId, name = "test name", nickname = "test nickname", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt index 39a69df1..7233b5a6 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddIndividualScheduleUseCaseTests.kt @@ -34,7 +34,7 @@ class AddIndividualScheduleUseCaseTests { private val id: UUID = UUID.randomUUID() private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt index f535933a..f1fa194b 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/AddSpotScheduleUseCaseTests.kt @@ -54,7 +54,7 @@ class AddSpotScheduleUseCaseTests { @Test fun `지점 일정 추가 성공`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -82,7 +82,7 @@ class AddSpotScheduleUseCaseTests { @Test fun `지점 변경 권한 부족`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -110,7 +110,7 @@ class AddSpotScheduleUseCaseTests { @Test fun `최고 관리자 계정`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt index 97e3918e..98c76ad3 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCaseTest.kt @@ -57,7 +57,7 @@ class ChangeIndividualScheduleUseCaseTest { private val scheduleId= UUID.randomUUID() private val userStub: User by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt index 5dd9cee5..d00c011e 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeSpotScheduleUseCaseTests.kt @@ -79,7 +79,7 @@ class ChangeSpotScheduleUseCaseTests { @Test fun `지점 일정 변경 성공`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -110,7 +110,7 @@ class ChangeSpotScheduleUseCaseTests { @Test fun `지점 일정이 아님`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -152,7 +152,7 @@ class ChangeSpotScheduleUseCaseTests { @Test fun `권한이 부족함`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -183,7 +183,7 @@ class ChangeSpotScheduleUseCaseTests { @Test fun `최고 관리자 계정`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -214,7 +214,7 @@ class ChangeSpotScheduleUseCaseTests { @Test fun `일정을 찾을 수 없음`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt index 367b04df..772d9416 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/QueryIndividualSpotScheduleUseCaseTests.kt @@ -47,7 +47,7 @@ class QueryIndividualSpotScheduleUseCaseTests { private val scheduleId: UUID = UUID.randomUUID() private val userStub: User by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt index b12b659c..e752773e 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveIndividualScheduleUseCaseTests.kt @@ -57,7 +57,7 @@ class RemoveIndividualScheduleUseCaseTests { } private val userStub by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", @@ -84,7 +84,7 @@ class RemoveIndividualScheduleUseCaseTests { @Test fun `지점 일정 삭제 성공`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt index 826eb3fe..48d0694e 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/schedule/usecase/RemoveSpotScheduleUseCaseTests.kt @@ -69,7 +69,7 @@ class RemoveSpotScheduleUseCaseTests { @Test fun `지점 일정 삭제 성공`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -100,7 +100,7 @@ class RemoveSpotScheduleUseCaseTests { @Test fun `최고 관리자 계정`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -131,7 +131,7 @@ class RemoveSpotScheduleUseCaseTests { @Test fun `권한이 부족함`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -162,7 +162,7 @@ class RemoveSpotScheduleUseCaseTests { @Test fun `일정 범위가 다름`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", @@ -204,7 +204,7 @@ class RemoveSpotScheduleUseCaseTests { @Test fun `일정을 찾을 수 없음`() { // given - val userStub = User( + val userStub = User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt index 601b4fdf..2fd8e6fa 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/AdminSignInUseCaseTests.kt @@ -35,7 +35,7 @@ class AdminSignInUseCaseTests { private val employeeNumber: Int = 1234567891 private val adminStub: User by lazy { - User( + User.of( id = UUID.randomUUID(), nickname = "test nickname", name = "test name", @@ -50,7 +50,7 @@ class AdminSignInUseCaseTests { } private val userStub: User by lazy { - User( + User.of( id = UUID.randomUUID(), nickname = "test nickname", name = "test name", @@ -94,7 +94,7 @@ class AdminSignInUseCaseTests { given(queryUserPort.queryUserByEmployeeNumber(employeeNumber)) .willReturn(adminStub) - given(userSecurityPort.compare(requestStub.password, adminStub.password)) + given(userSecurityPort.compare(requestStub.password, adminStub.password.value)) .willReturn(true) given(userJwtPort.receiveToken(adminStub.id, adminStub.authority)) @@ -113,7 +113,7 @@ class AdminSignInUseCaseTests { given(queryUserPort.queryUserByEmployeeNumber(employeeNumber)) .willReturn(adminStub) - given(userSecurityPort.compare(requestStub.password, adminStub.password)) + given(userSecurityPort.compare(requestStub.password, adminStub.password.value)) .willReturn(false) // when & then diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt index ff807f13..9f230c4e 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeEmailUseCaseTests.kt @@ -57,7 +57,7 @@ class ChangeEmailUseCaseTests { } private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt index 6c33f469..0227be8f 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeNicknameUseCaseTests.kt @@ -39,7 +39,7 @@ class ChangeNicknameUseCaseTests { } private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt index 09aedf79..0c620538 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangePasswordUseCaseTests.kt @@ -33,7 +33,7 @@ class ChangePasswordUseCaseTests { private val id = UUID.randomUUID() private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", @@ -72,7 +72,7 @@ class ChangePasswordUseCaseTests { given(queryUserPort.queryUserById(id)) .willReturn(userStub) - given(userSecurityPort.compare(requestStub.password, userStub.password)) + given(userSecurityPort.compare(requestStub.password, userStub.password.value)) .willReturn(true) given(userSecurityPort.encode(requestStub.newPassword)) @@ -108,7 +108,7 @@ class ChangePasswordUseCaseTests { given(queryUserPort.queryUserById(id)) .willReturn(userStub) - given(userSecurityPort.compare(requestStub.password, userStub.password)) + given(userSecurityPort.compare(requestStub.password, userStub.password.value)) .willReturn(false) // when & then diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt index ff51ac0a..159cd8cc 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeProfileImageUseCaseTests.kt @@ -44,7 +44,7 @@ class ChangeProfileImageUseCaseTests { } private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt index 38bd9af9..55af3721 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ChangeSpotUseCaseTests.kt @@ -42,7 +42,7 @@ class ChangeSpotUseCaseTests { private val spotId = UUID.randomUUID() private val userStub: User by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt index 58dbd985..841f143f 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ComparePasswordUseCaseTests.kt @@ -30,7 +30,7 @@ class ComparePasswordUseCaseTests { private val passwordStub: String = "test password" private val userStub: User by lazy { - User( + User.of( id = userId, nickname = "test nickname", name = "test name", @@ -61,7 +61,7 @@ class ComparePasswordUseCaseTests { given(queryUserPort.queryUserById(userId)) .willReturn(userStub) - given(securityPort.compare(passwordStub, userStub.password)) + given(securityPort.compare(passwordStub, userStub.password.value)) .willReturn(true) // when & then @@ -79,7 +79,7 @@ class ComparePasswordUseCaseTests { given(queryUserPort.queryUserById(userId)) .willReturn(userStub) - given(securityPort.compare(passwordStub, userStub.password)) + given(securityPort.compare(passwordStub, userStub.password.value)) .willReturn(false) // when & then diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt index d94cd89f..a60f51bd 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/FindEmployeeNumberUseCaseTests.kt @@ -31,7 +31,7 @@ class FindEmployeeNumberUseCaseTests { private val employeeNumber: Int = 1234567891 private val userStub: User by lazy { - User( + User.of( nickname = "test nickname", name = "test name", email = "test email", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt index 0bf9c626..c3c6fdad 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryAdminInfoUseCaseTests.kt @@ -47,7 +47,7 @@ class QueryAdminInfoUseCaseTests { private val profileImagePath = "test profile image" private val userStub: User by lazy { - User( + User.of( id = id, nickname = nickname, name = name, diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt index a19e8dda..cf709890 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/QueryUserInfoUseCaseTests.kt @@ -43,7 +43,7 @@ class QueryUserInfoUseCaseTests { private val profileImagePath = "test path" private val userStub: User by lazy { - User( + User.of( id = id, nickname = nickname, name = name, diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt index 82fd6cc0..4c766fe9 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/ResetPasswordUseCaseTests.kt @@ -63,7 +63,7 @@ class ResetPasswordUseCaseTests { } private val userStub: User by lazy { - User( + User.of( id = id, nickname = "test nickname", name = "test name", diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt index 8fa183ae..ed20d021 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignInUseCaseTests.kt @@ -39,7 +39,7 @@ class SignInUseCaseTests { private val employeeNumber: Int = 1234567891 private val userStub: User by lazy { - User( + User.of( id = UUID.randomUUID(), nickname = "test nickname", name = "test name", @@ -54,7 +54,7 @@ class SignInUseCaseTests { } private val adminStub: User by lazy { - User( + User.of( id = UUID.randomUUID(), nickname = "test nickname", name = "test name", @@ -95,7 +95,7 @@ class SignInUseCaseTests { given(queryUserPort.queryUserByEmployeeNumber(employeeNumber)) .willReturn(userStub) - given(userSecurityPort.compare(requestStub.password, userStub.password)) + given(userSecurityPort.compare(requestStub.password, userStub.password.value)) .willReturn(true) given(userJwtPort.receiveToken(userStub.id, userStub.authority)) @@ -114,7 +114,7 @@ class SignInUseCaseTests { given(queryUserPort.queryUserByEmployeeNumber(employeeNumber)) .willReturn(userStub) - given(userSecurityPort.compare(requestStub.password, userStub.password)) + given(userSecurityPort.compare(requestStub.password, userStub.password.value)) .willReturn(false) // when & then diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt index 465a188c..1e130fb3 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/user/usecase/SignUpUseCaseTests.kt @@ -99,7 +99,7 @@ class SignUpUseCaseTests { } private val saveUserStub: User by lazy { - User( + User.of( id = UUID.randomUUID(), name = name, nickname = nickname, @@ -170,7 +170,7 @@ class SignUpUseCaseTests { @Test fun `회원가입 성공`() { // given - val userStub = User( + val userStub = User.of( nickname = nickname, name = name, email = email, @@ -204,7 +204,7 @@ class SignUpUseCaseTests { .willReturn(teamStub) given(userSecurityPort.encode(requestStub.password)) - .willReturn(userStub.password) + .willReturn(userStub.password.value) given(commandUserPort.save(userStub)) .willReturn(saveUserStub) @@ -232,7 +232,7 @@ class SignUpUseCaseTests { deviceToken = "test device token" ) - val userStub = User( + val userStub = User.of( nickname = nickname, name = name, email = email, @@ -266,7 +266,7 @@ class SignUpUseCaseTests { .willReturn(teamStub) given(userSecurityPort.encode(requestStub.password)) - .willReturn(userStub.password) + .willReturn(userStub.password.value) given(commandUserPort.save(userStub)) .willReturn(saveUserStub) diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/DeviceToken.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/DeviceToken.kt index f4281651..e2d7c4a8 100644 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/DeviceToken.kt +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/DeviceToken.kt @@ -9,11 +9,16 @@ import java.util.UUID * * @author kimbeomjin * @date 2023/01/01 - * @version 1.1.0 + * @version 1.2.5 **/ @Aggregate data class DeviceToken( val userId: UUID, val token: String -) +) { + + companion object { + fun of(userId: UUID, token: String) = DeviceToken(userId, token) + } +} diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/EmployeeNumber.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/EmployeeNumber.kt new file mode 100644 index 00000000..720689dc --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/EmployeeNumber.kt @@ -0,0 +1,22 @@ +package team.comit.simtong.domain.user.model + +/** + * + * User Aggregate 중 사원번호를 담당하는 EmployeeNumber + * + * @author kimbeomjin + * @date 2023/01/10 + * @version 1.2.5 + **/ +@JvmInline +value class EmployeeNumber( + val value: Int +) { + + companion object { + const val MIN_VALUE: Long = 1200000000 + const val MAX_VALUE: Long = 1299999999 + + fun of(employeeNumber: Int) = EmployeeNumber(employeeNumber) + } +} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/NickName.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/NickName.kt new file mode 100644 index 00000000..6a529abc --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/NickName.kt @@ -0,0 +1,29 @@ +package team.comit.simtong.domain.user.model + +/** + * + * User Aggregate 중 닉네임을 담당하는 NickName + * + * @author kimbeomjin + * @date 2023/01/10 + * @version 1.2.5 + **/ +@JvmInline +value class NickName( + val value: String +) { + + companion object { + const val MIN_LENGTH = 1 + const val MAX_LENGTH = 20 + + /** + * first word & Last word - space X + * + * space , _ , . , a ~ z , A ~ Z , 가 ~ 힣 , 0 ~ 9 + */ + const val PATTERN = """(?=^\S)(?=^[\w\s가-힣.]{$MIN_LENGTH,$MAX_LENGTH}$).*(?=\S$).""" + + fun of(nickName: String) = NickName(nickName) + } +} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/Password.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/Password.kt new file mode 100644 index 00000000..3839fea6 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/Password.kt @@ -0,0 +1,29 @@ +package team.comit.simtong.domain.user.model + +/** + * + * User Aggregate 중 비밀번호를 담당하는 Password + * + * @author kimbeomjin + * @date 2023/01/10 + * @version 1.2.5 + **/ +@JvmInline +value class Password( + val value: String +) { + + companion object { + const val MIN_LENGTH = 8 + const val MAX_LENGTH = 20 + + /** + * a ~ z or A ~ Z & 0 ~ 9 - must more than once + * + * non-space, $ , + , - , _ , a ~ z , A ~ Z , 0 ~ 9 + */ + const val PATTERN = """(?=.*[a-zA-Z])(?=.*\d)(?=^[\w$+-]{$MIN_LENGTH,$MAX_LENGTH$).*""" + + fun of(password: String) = Password(password) + } +} \ No newline at end of file diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/User.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/User.kt index 02d70913..f03560ea 100644 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/User.kt +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/User.kt @@ -1,5 +1,6 @@ package team.comit.simtong.domain.user.model +import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.global.DomainProperties.getProperty import team.comit.simtong.global.DomainPropertiesPrefix import team.comit.simtong.global.annotation.Aggregate @@ -13,21 +14,21 @@ import java.util.UUID * @author Chokyunghyeon * @author kimbeomjin * @date 2022/09/04 - * @version 1.0.0 + * @version 1.2.5 **/ @Aggregate data class User( - val id: UUID = UUID(0, 0), + val id: UUID, - val nickname: String, + val nickname: NickName, val name: String, val email: String, - val password: String, + val password: Password, - val employeeNumber: Int, + val employeeNumber: EmployeeNumber, val authority: Authority, @@ -37,12 +38,60 @@ data class User( val profileImagePath: String, - val deletedAt: LocalDateTime? = null + val deletedAt: LocalDateTime? ) { companion object { + @JvmField val DEFAULT_IMAGE = getProperty(DomainPropertiesPrefix.USER_DEFAULT_IMAGE) + + fun of( + id: UUID = UUID(0, 0), + nickname: String, + name: String, + email: String, + password: String, + employeeNumber: Int, + authority: Authority, + spotId: UUID, + teamId: UUID, + profileImagePath: String, + deletedAt: LocalDateTime? = null + ) = User( + id = id, + nickname = NickName.of(nickname), + name = name, + email = email, + password = Password.of(password), + employeeNumber = EmployeeNumber.of(employeeNumber), + authority = authority, + spotId = spotId, + teamId = teamId, + profileImagePath = profileImagePath, + deletedAt = deletedAt + ) + } + + fun checkAuthority(authority: Authority) { + when(authority) { + Authority.ROLE_COMMON -> if (!isEmployee()) throw UserExceptions.DifferentPermissionAccount("사원 계정이 아닙니다.") + + Authority.ROLE_SUPER, Authority.ROLE_ADMIN -> if (!isAdmin()) throw UserExceptions.DifferentPermissionAccount("관리자 계정이 아닙니다.") + } } + fun isAdmin() = (this.authority == Authority.ROLE_ADMIN) || (this.authority == Authority.ROLE_SUPER) + + fun isEmployee() = this.authority == Authority.ROLE_COMMON + + fun changeEmail(email: String) = this.copy(email = email) + + fun changeNickname(nickname: String) = this.copy(nickname = NickName.of(nickname)) + + fun changePassword(password: String) = this.copy(password = Password.of(password)) + + fun changeProfileImage(profileImagePath: String) = this.copy(profileImagePath = profileImagePath) + + fun changeSpot(spotId: UUID) = this.copy(spotId = spotId) } \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/UserMapper.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/UserMapper.kt index 9ce8221a..c26199cd 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/UserMapper.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/UserMapper.kt @@ -29,12 +29,12 @@ class UserMapper( return UserJpaEntity( id = model.id, - employeeNumber = model.employeeNumber, + employeeNumber = model.employeeNumber.value, email = model.email, authority = model.authority, name = model.name, - nickname = model.nickname, - password = model.password, + nickname = model.nickname.value, + password = model.password.value, spot = spot, team = team, profileImagePath = model.profileImagePath, @@ -43,25 +43,11 @@ class UserMapper( } override fun toDomain(entity: UserJpaEntity?): User? { - return entity?.let { - User( - id = it.id!!, - nickname = it.nickname, - name = it.name, - email = it.email, - password = it.password, - employeeNumber = it.employeeNumber, - authority = it.authority, - spotId = it.spot.id!!, - teamId = it.team.id!!, - profileImagePath = it.profileImagePath, - deletedAt = it.deletedAt - ) - } + return entity?.let(::toDomainNotNull) } override fun toDomainNotNull(entity: UserJpaEntity): User { - return User( + return User.of( id = entity.id!!, nickname = entity.nickname, name = entity.name,