From 006449db3bbfba87fe63a8f69cd64af17b755338 Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Sun, 1 Jan 2023 22:37:19 +0900 Subject: [PATCH 01/11] =?UTF-8?q?chore:=20(#264)=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EA=B0=92=EC=97=90=20deviceToken=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/dto/AdminSignInRequest.kt | 15 +++++++++++++ .../simtong/domain/user/dto/SignInRequest.kt | 15 ------------- .../simtong/domain/user/dto/SignUpRequest.kt | 4 +++- .../domain/user/dto/UserSignInRequest.kt | 17 +++++++++++++++ .../domain/user/usecase/AdminSignInUseCase.kt | 4 ++-- .../user/usecase/AdminSignInUseCaseTests.kt | 6 +++--- .../simtong/domain/admin/WebAdminAdapter.kt | 6 +++--- .../admin/dto/request/SignInWebRequest.kt | 21 +++++++++++++++++++ .../simtong/domain/user/WebUserAdapter.kt | 10 +++++---- .../user/dto/request/SignInWebRequest.kt | 7 +++++-- .../user/dto/request/SignUpWebRequest.kt | 5 ++++- 11 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/AdminSignInRequest.kt delete mode 100644 simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignInRequest.kt create mode 100644 simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/UserSignInRequest.kt create mode 100644 simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/dto/request/SignInWebRequest.kt diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/AdminSignInRequest.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/AdminSignInRequest.kt new file mode 100644 index 00000000..fe39328b --- /dev/null +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/AdminSignInRequest.kt @@ -0,0 +1,15 @@ +package team.comit.simtong.domain.user.dto + +/** + * + * 관리자의 로그인을 정보를 전달하는 AdminSignInRequest + * + * @author kimbeomjin + * @date 2023/01/01 + * @version 1.1.0 + **/ +data class AdminSignInRequest( + val employeeNumber: Int, + + val password: String +) \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignInRequest.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignInRequest.kt deleted file mode 100644 index 179e17be..00000000 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignInRequest.kt +++ /dev/null @@ -1,15 +0,0 @@ -package team.comit.simtong.domain.user.dto - -/** - * - * 로그인을 정보를 전달하는 SignInRequest - * - * @author kimbeomjin - * @date 2022/09/08 - * @version 1.0.0 - **/ -data class SignInRequest( - val employeeNumber: Int, - - val password: String -) \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignUpRequest.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignUpRequest.kt index a29ba2e5..8096f872 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignUpRequest.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/SignUpRequest.kt @@ -20,5 +20,7 @@ data class SignUpRequest( val employeeNumber: Int, - val profileImagePath: String? + val profileImagePath: String?, + + val deviceToken: String ) \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/UserSignInRequest.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/UserSignInRequest.kt new file mode 100644 index 00000000..541b6c3b --- /dev/null +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/dto/UserSignInRequest.kt @@ -0,0 +1,17 @@ +package team.comit.simtong.domain.user.dto + +/** + * + * 일반 사용자의 로그인을 정보를 전달하는 UserSignInRequest + * + * @author kimbeomjin + * @date 2022/09/08 + * @version 1.0.0 + **/ +data class UserSignInRequest( + val employeeNumber: Int, + + val password: String, + + val deviceToken: String +) \ No newline at end of file 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 94052289..77f80fa5 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 @@ -1,7 +1,7 @@ package team.comit.simtong.domain.user.usecase import team.comit.simtong.domain.auth.dto.TokenResponse -import team.comit.simtong.domain.user.dto.SignInRequest +import team.comit.simtong.domain.user.dto.AdminSignInRequest import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.spi.QueryUserPort @@ -24,7 +24,7 @@ class AdminSignInUseCase( private val securityPort: UserSecurityPort ) { - fun execute(request: SignInRequest): TokenResponse { + fun execute(request: AdminSignInRequest): TokenResponse { val admin = queryUserPort.queryUserByEmployeeNumber(request.employeeNumber) ?: throw UserExceptions.NotFound("관리자가 존재하지 않습니다.") 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 147b2f5c..601b4fdf 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 @@ -7,7 +7,7 @@ import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.auth.dto.TokenResponse -import team.comit.simtong.domain.user.dto.SignInRequest +import team.comit.simtong.domain.user.dto.AdminSignInRequest import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User @@ -64,8 +64,8 @@ class AdminSignInUseCaseTests { ) } - private val requestStub: SignInRequest by lazy { - SignInRequest( + private val requestStub: AdminSignInRequest by lazy { + AdminSignInRequest( employeeNumber = employeeNumber, password = "test password" ) diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/WebAdminAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/WebAdminAdapter.kt index c757e801..5c31502c 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/WebAdminAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/WebAdminAdapter.kt @@ -5,10 +5,10 @@ import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController +import team.comit.simtong.domain.admin.dto.request.SignInWebRequest import team.comit.simtong.domain.auth.dto.TokenResponse +import team.comit.simtong.domain.user.dto.AdminSignInRequest import team.comit.simtong.domain.user.dto.QueryAdminInfoResponse -import team.comit.simtong.domain.user.dto.SignInRequest -import team.comit.simtong.domain.user.dto.request.SignInWebRequest import team.comit.simtong.domain.user.usecase.AdminSignInUseCase import team.comit.simtong.domain.user.usecase.QueryAdminInfoUseCase import javax.validation.Valid @@ -31,7 +31,7 @@ class WebAdminAdapter( @PostMapping("/tokens") fun signIn(@Valid @RequestBody request: SignInWebRequest): TokenResponse { return adminSignInUseCase.execute( - SignInRequest( + AdminSignInRequest( employeeNumber = request.employeeNumber, password = request.password ) diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/dto/request/SignInWebRequest.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/dto/request/SignInWebRequest.kt new file mode 100644 index 00000000..d3a68582 --- /dev/null +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/admin/dto/request/SignInWebRequest.kt @@ -0,0 +1,21 @@ +package team.comit.simtong.domain.admin.dto.request + +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull + +/** + * + * 관리자가 로그인을 요청하는 SignInWebRequest + * + * @author kimbeomjin + * @date 2023/01/01 + * @version 1.1.0 + **/ +data class SignInWebRequest( + + @field:NotNull + val employeeNumber: Int, + + @field:NotBlank + val password: String +) \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt index 2d03ed56..a723a098 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt @@ -16,7 +16,7 @@ import team.comit.simtong.domain.user.dto.ChangeEmailRequest import team.comit.simtong.domain.user.dto.ChangeNicknameRequest import team.comit.simtong.domain.user.dto.ChangeProfileImageRequest import team.comit.simtong.domain.user.dto.QueryUserInfoResponse -import team.comit.simtong.domain.user.dto.SignInRequest +import team.comit.simtong.domain.user.dto.UserSignInRequest import team.comit.simtong.domain.user.dto.SignUpRequest import team.comit.simtong.domain.user.dto.request.ChangeEmailWebRequest import team.comit.simtong.domain.user.dto.request.ChangeNicknameWebRequest @@ -70,7 +70,8 @@ class WebUserAdapter( password = request.password, nickname = request.nickname, profileImagePath = request.profileImagePath, - employeeNumber = request.employeeNumber + employeeNumber = request.employeeNumber, + deviceToken = request.deviceToken ) ) } @@ -78,9 +79,10 @@ class WebUserAdapter( @PostMapping("/tokens") fun signIn(@Valid @RequestBody request: SignInWebRequest): TokenResponse { return signInUseCase.execute( - SignInRequest( + UserSignInRequest( employeeNumber = request.employeeNumber, - password = request.password + password = request.password, + deviceToken = request.deviceToken ) ) } diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignInWebRequest.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignInWebRequest.kt index b117423e..6c9d309e 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignInWebRequest.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignInWebRequest.kt @@ -5,7 +5,7 @@ import javax.validation.constraints.NotNull /** * - * 로그인을 요청하는 SignInWebRequest + * 일반 사용자가 로그인을 요청하는 SignInWebRequest * * @author kimbeomjin * @date 2022/09/08 @@ -17,5 +17,8 @@ data class SignInWebRequest( val employeeNumber: Int, @field:NotBlank - val password: String + val password: String, + + @field:NotBlank + val deviceToken: String ) \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignUpWebRequest.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignUpWebRequest.kt index b0205aa9..2397f68f 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignUpWebRequest.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/dto/request/SignUpWebRequest.kt @@ -37,5 +37,8 @@ data class SignUpWebRequest( @field:Pattern(regexp = RegexUtils.NICKNAME_PATTERN) val nickname: String?, - val profileImagePath: String? + val profileImagePath: String?, + + @field:NotBlank + val deviceToken: String ) From 8907b8fd55dbef39b5449797d127b83b25bae16c Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Sun, 1 Jan 2023 22:37:42 +0900 Subject: [PATCH 02/11] add: (#264) DeviceToken Aggregate --- .../simtong/domain/user/model/DeviceToken.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/DeviceToken.kt 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 new file mode 100644 index 00000000..66feb969 --- /dev/null +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/user/model/DeviceToken.kt @@ -0,0 +1,16 @@ +package team.comit.simtong.domain.user.model + +import java.util.UUID + +/** + * + * User Aggregate의 디바이스 토큰 관리를 담당하는 DeviceToken + * + * @author kimbeomjin + * @date 2023/01/01 + * @version 1.1.0 + **/ +data class DeviceToken( + val userId: UUID, + val token: String +) From 2b5b5835de2dd83c770f09968926cbb8a4b23fa4 Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Sun, 1 Jan 2023 22:37:50 +0900 Subject: [PATCH 03/11] add: (#264) DeviceTokenMapper --- .../user/mapper/DeviceTokenMapper.kt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/DeviceTokenMapper.kt diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/DeviceTokenMapper.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/DeviceTokenMapper.kt new file mode 100644 index 00000000..61eae966 --- /dev/null +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/mapper/DeviceTokenMapper.kt @@ -0,0 +1,27 @@ +package team.comit.simtong.persistence.user.mapper + +import org.mapstruct.Mapper +import org.mapstruct.Mapping +import org.springframework.beans.factory.annotation.Autowired +import team.comit.simtong.domain.user.model.DeviceToken +import team.comit.simtong.persistence.GenericMapper +import team.comit.simtong.persistence.user.entity.DeviceTokenJpaEntity +import team.comit.simtong.persistence.user.repository.UserJpaRepository + +/** + * + * DeviceToken Entity와 DeviceToken Aggregate를 변환하는 DeviceTokenMapper + * + * @author kimbeomjin + * @date 2023/01/01 + * @version 1.1.0 + **/ +@Mapper +abstract class DeviceTokenMapper : GenericMapper { + + @Autowired + protected lateinit var userRepository: UserJpaRepository + + @Mapping(target = "user", expression = "java(userRepository.findById(model.getUserId()).orElse(null))") + abstract override fun toEntity(model: DeviceToken): DeviceTokenJpaEntity +} \ No newline at end of file From b012e1749fbe23423184541b41de494fb997fd6f Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Sun, 1 Jan 2023 22:38:07 +0900 Subject: [PATCH 04/11] add: (#264) CommandDeviceTokenPort --- .../domain/user/spi/CommandDeviceTokenPort.kt | 17 +++++++++++++++++ .../comit/simtong/domain/user/spi/UserPort.kt | 2 +- .../persistence/user/UserPersistenceAdapter.kt | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/CommandDeviceTokenPort.kt diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/CommandDeviceTokenPort.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/CommandDeviceTokenPort.kt new file mode 100644 index 00000000..d1b1d8aa --- /dev/null +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/CommandDeviceTokenPort.kt @@ -0,0 +1,17 @@ +package team.comit.simtong.domain.user.spi + +import team.comit.simtong.domain.user.model.DeviceToken + +/** + * + * DeviceToken Domain에 관한 명령을 하는 CommandDeviceTokenPort + * + * @author kimbeomjin + * @date 2022/12/31 + * @version 1.1.0 + **/ +interface CommandDeviceTokenPort { + + fun save(deviceToken: DeviceToken): DeviceToken + +} \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/UserPort.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/UserPort.kt index 732dc2c5..9bcbd2d2 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/UserPort.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/user/spi/UserPort.kt @@ -13,4 +13,4 @@ import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort * @date 2022/09/18 * @version 1.0.0 **/ -interface UserPort : QueryUserPort, CommandUserPort, MenuQueryUserPort, ScheduleQueryUserPort, HolidayQueryUserPort, NotificationQueryUserPort \ No newline at end of file +interface UserPort : QueryUserPort, CommandUserPort, CommandDeviceTokenPort, MenuQueryUserPort, ScheduleQueryUserPort, HolidayQueryUserPort, NotificationQueryUserPort \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/UserPersistenceAdapter.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/UserPersistenceAdapter.kt index 98404bc1..bd46d9e2 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/UserPersistenceAdapter.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/user/UserPersistenceAdapter.kt @@ -2,8 +2,10 @@ package team.comit.simtong.persistence.user import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Component +import team.comit.simtong.domain.user.model.DeviceToken import team.comit.simtong.domain.user.model.User import team.comit.simtong.domain.user.spi.UserPort +import team.comit.simtong.persistence.user.mapper.DeviceTokenMapper import team.comit.simtong.persistence.user.mapper.UserMapper import team.comit.simtong.persistence.user.repository.DeviceTokenJpaRepository import team.comit.simtong.persistence.user.repository.UserJpaRepository @@ -22,6 +24,7 @@ import java.util.UUID class UserPersistenceAdapter( private val userMapper: UserMapper, private val userJpaRepository: UserJpaRepository, + private val deviceTokenMapper: DeviceTokenMapper, private val deviceTokenRepository: DeviceTokenJpaRepository ) : UserPort { @@ -77,6 +80,12 @@ class UserPersistenceAdapter( ).let { userMapper.toDomain(it)!! } } + override fun save(deviceToken: DeviceToken): DeviceToken { + return deviceTokenRepository.save( + deviceTokenMapper.toEntity(deviceToken) + ).let { deviceTokenMapper.toDomain(it)!! } + } + override fun queryDeviceTokenByUserId(userId: UUID): String? { return deviceTokenRepository.findByUserId(userId)?.token } From 5680a42410260504e1f1a9ffa355ad28e3bf812d Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Sun, 1 Jan 2023 22:38:51 +0900 Subject: [PATCH 05/11] =?UTF-8?q?chore:=20(#264)=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EB=A1=9C=EA=B7=B8=EC=9D=B8,=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EB=A1=9C=EC=A7=81=EC=97=90=20=EB=94=94?= =?UTF-8?q?=EB=B0=94=EC=9D=B4=EC=8A=A4=20=ED=86=A0=ED=81=B0=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simtong/domain/user/usecase/SignInUseCase.kt | 16 +++++++++++++--- .../simtong/domain/user/usecase/SignUpUseCase.kt | 10 ++++++++++ .../domain/user/usecase/SignInUseCaseTests.kt | 15 ++++++++++----- .../domain/user/usecase/SignUpUseCaseTests.kt | 11 +++++++++-- 4 files changed, 42 insertions(+), 10 deletions(-) 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 a41f6cfb..93cb85f6 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 @@ -1,9 +1,11 @@ package team.comit.simtong.domain.user.usecase import team.comit.simtong.domain.auth.dto.TokenResponse -import team.comit.simtong.domain.user.dto.SignInRequest +import team.comit.simtong.domain.user.dto.UserSignInRequest import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority +import team.comit.simtong.domain.user.model.DeviceToken +import team.comit.simtong.domain.user.spi.CommandDeviceTokenPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserJwtPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -21,10 +23,11 @@ import team.comit.simtong.global.annotation.UseCase class SignInUseCase( private val queryUserPort: QueryUserPort, private val userSecurityPort: UserSecurityPort, - private val userJwtPort: UserJwtPort + private val userJwtPort: UserJwtPort, + private val commandDeviceTokenPort: CommandDeviceTokenPort ) { - fun execute(request: SignInRequest): TokenResponse { + fun execute(request: UserSignInRequest): TokenResponse { val user = queryUserPort.queryUserByEmployeeNumber(request.employeeNumber) ?: throw UserExceptions.NotFound() @@ -36,6 +39,13 @@ class SignInUseCase( throw UserExceptions.DifferentPassword() } + commandDeviceTokenPort.save( + DeviceToken( + userId = user.id, + token = request.deviceToken + ) + ) + return userJwtPort.receiveToken( userId = user.id, authority = Authority.ROLE_COMMON 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 75403886..2b182db5 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 @@ -8,7 +8,9 @@ import team.comit.simtong.domain.team.exception.TeamExceptions import team.comit.simtong.domain.user.dto.SignUpRequest import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority +import team.comit.simtong.domain.user.model.DeviceToken import team.comit.simtong.domain.user.model.User +import team.comit.simtong.domain.user.spi.CommandDeviceTokenPort import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserCommandAuthCodeLimitPort @@ -33,6 +35,7 @@ import team.comit.simtong.global.annotation.UseCase class SignUpUseCase( private val jwtPort: UserJwtPort, private val commandUserPort: CommandUserPort, + private val commandDeviceTokenPort: CommandDeviceTokenPort, private val queryUserPort: QueryUserPort, private val queryAuthCodeLimitPort: UserQueryAuthCodeLimitPort, private val commandAuthCodeLimitPort: UserCommandAuthCodeLimitPort, @@ -88,6 +91,13 @@ class SignUpUseCase( commandAuthCodeLimitPort.delete(authCodeLimit) + commandDeviceTokenPort.save( + DeviceToken( + userId = user.id, + token = request.deviceToken + ) + ) + return jwtPort.receiveToken( userId = user.id, authority = user.authority 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 9a11128a..8fa183ae 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 @@ -7,10 +7,11 @@ import org.junit.jupiter.api.assertThrows import org.mockito.BDDMockito.given import org.springframework.boot.test.mock.mockito.MockBean import team.comit.simtong.domain.auth.dto.TokenResponse -import team.comit.simtong.domain.user.dto.SignInRequest +import team.comit.simtong.domain.user.dto.UserSignInRequest import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User +import team.comit.simtong.domain.user.spi.CommandDeviceTokenPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserJwtPort import team.comit.simtong.domain.user.spi.UserSecurityPort @@ -30,6 +31,9 @@ class SignInUseCaseTests { @MockBean private lateinit var userJwtPort: UserJwtPort + @MockBean + private lateinit var commandDeviceTokenPort: CommandDeviceTokenPort + private lateinit var signInUseCase: SignInUseCase private val employeeNumber: Int = 1234567891 @@ -64,10 +68,11 @@ class SignInUseCaseTests { ) } - private val requestStub: SignInRequest by lazy { - SignInRequest( + private val requestStub: UserSignInRequest by lazy { + UserSignInRequest( employeeNumber = employeeNumber, - password = "test password" + password = "test password", + deviceToken = "test device token" ) } @@ -81,7 +86,7 @@ class SignInUseCaseTests { @BeforeEach fun setUp() { - signInUseCase = SignInUseCase(queryUserPort, userSecurityPort, userJwtPort) + signInUseCase = SignInUseCase(queryUserPort, userSecurityPort, userJwtPort, commandDeviceTokenPort) } @Test 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 6b3e639d..cd1037ed 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 @@ -19,6 +19,7 @@ import team.comit.simtong.domain.user.dto.SignUpRequest import team.comit.simtong.domain.user.exception.UserExceptions import team.comit.simtong.domain.user.model.Authority import team.comit.simtong.domain.user.model.User +import team.comit.simtong.domain.user.spi.CommandDeviceTokenPort import team.comit.simtong.domain.user.spi.CommandUserPort import team.comit.simtong.domain.user.spi.QueryUserPort import team.comit.simtong.domain.user.spi.UserCommandAuthCodeLimitPort @@ -41,6 +42,9 @@ class SignUpUseCaseTests { @MockBean private lateinit var commandUserPort: CommandUserPort + @MockBean + private lateinit var commandDeviceTokenPort: CommandDeviceTokenPort + @MockBean private lateinit var userSecurityPort: UserSecurityPort @@ -134,7 +138,8 @@ class SignUpUseCaseTests { email = email, password = "test password", employeeNumber = employeeNumber, - profileImagePath = profileImagePath + profileImagePath = profileImagePath, + deviceToken = "test device token" ) } @@ -151,6 +156,7 @@ class SignUpUseCaseTests { signUpUseCase = SignUpUseCase( userJwtPort, commandUserPort, + commandDeviceTokenPort, queryUserPort, userQueryAuthCodeLimitPort, commandAuthCodeLimitPort, @@ -222,7 +228,8 @@ class SignUpUseCaseTests { email = email, password = "test password", employeeNumber = employeeNumber, - profileImagePath = null + profileImagePath = null, + deviceToken = "test device token" ) val userStub = User( From d0d8b9b842f6dbae2bfb3f7777add23716c3d73b Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Sun, 1 Jan 2023 22:40:56 +0900 Subject: [PATCH 06/11] =?UTF-8?q?chore:=20(#261)=20Notification=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20API=20permission?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/comit/simtong/global/security/SecurityConfig.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt index 28370746..87d55655 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt @@ -109,6 +109,10 @@ class SecurityConfig( .antMatchers(HttpMethod.POST, "/admins/tokens").permitAll() .antMatchers(HttpMethod.GET, "/admins/information").hasAnyRole(ROLE_ADMIN.role, ROLE_SUPER.role) + // notifications + .antMatchers(HttpMethod.POST, "/notifications").permitAll() + .antMatchers(HttpMethod.POST, "/notifications/list").permitAll() + .anyRequest().authenticated() http From c28a08065eedfa724d6e5f8e9d5e9fec74265fc8 Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Mon, 2 Jan 2023 10:27:24 +0900 Subject: [PATCH 07/11] refactor: stage -> dev --- .github/workflows/{stage-cd.yml => dev-cd.yml} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{stage-cd.yml => dev-cd.yml} (97%) diff --git a/.github/workflows/stage-cd.yml b/.github/workflows/dev-cd.yml similarity index 97% rename from .github/workflows/stage-cd.yml rename to .github/workflows/dev-cd.yml index 8fbeb03d..8570a553 100644 --- a/.github/workflows/stage-cd.yml +++ b/.github/workflows/dev-cd.yml @@ -1,13 +1,13 @@ -name: CD for Stage +name: CD for Dev on: push: branches: - - main + - develop jobs: build: - environment: stage + environment: dev runs-on: ubuntu-latest steps: From 0d3f5af32dd5c022d149d06ecc0ccf05dbb2fc9f Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Mon, 2 Jan 2023 10:34:03 +0900 Subject: [PATCH 08/11] =?UTF-8?q?chore:=20develop=20=EB=B8=8C=EB=A0=8C?= =?UTF-8?q?=EC=B9=98=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 2 ++ .github/workflows/build.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7fe6d570..343d2d58 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,9 +4,11 @@ on: push: branches: - main + - develop pull_request: branches: - main + - develop jobs: build: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7c0660c..7725622d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,9 +4,11 @@ on: push: branches: - main + - develop pull_request: branches: - main + - develop jobs: build: From afca4f4287fb70d4db2bf01be7d34fa3c0b96f3d Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Mon, 2 Jan 2023 14:32:20 +0900 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EA=B5=AC=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 7 +------ .github/workflows/build.yml | 7 +------ .github/workflows/dev-cd.yml | 1 + 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 343d2d58..7313d42b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -3,12 +3,7 @@ name: CI on: push: branches: - - main - - develop - pull_request: - branches: - - main - - develop + - * jobs: build: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7725622d..6233c48e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,12 +3,7 @@ name: Build with Gradle on: push: branches: - - main - - develop - pull_request: - branches: - - main - - develop + - * jobs: build: diff --git a/.github/workflows/dev-cd.yml b/.github/workflows/dev-cd.yml index 8570a553..28a26c20 100644 --- a/.github/workflows/dev-cd.yml +++ b/.github/workflows/dev-cd.yml @@ -8,6 +8,7 @@ on: jobs: build: environment: dev + if: "github.event.pull_request.base.ref != 'develop'" runs-on: ubuntu-latest steps: From fadaa8160bded0ffe38f07b57294f95fa087c620 Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Mon, 2 Jan 2023 14:54:56 +0900 Subject: [PATCH 10/11] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EA=B5=AC=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CI.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/dev-cd.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7313d42b..4547dc7f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - * + - "*" jobs: build: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6233c48e..771fde56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build with Gradle on: push: branches: - - * + - "*" jobs: build: diff --git a/.github/workflows/dev-cd.yml b/.github/workflows/dev-cd.yml index 28a26c20..d935486f 100644 --- a/.github/workflows/dev-cd.yml +++ b/.github/workflows/dev-cd.yml @@ -8,7 +8,7 @@ on: jobs: build: environment: dev - if: "github.event.pull_request.base.ref != 'develop'" + if: github.event.pull_request.base.ref != 'develop' runs-on: ubuntu-latest steps: From 52ef024f75d56dace19b647046aa496ef7ae597a Mon Sep 17 00:00:00 2001 From: KimBeomJin Date: Mon, 2 Jan 2023 15:01:40 +0900 Subject: [PATCH 11/11] =?UTF-8?q?chore:=20dev=20cd,=20main=20=EB=B8=8C?= =?UTF-8?q?=EB=A0=8C=EC=B9=98=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dev-cd.yml b/.github/workflows/dev-cd.yml index d935486f..fee9c93f 100644 --- a/.github/workflows/dev-cd.yml +++ b/.github/workflows/dev-cd.yml @@ -4,6 +4,7 @@ on: push: branches: - develop + - main jobs: build: