From f10836799f44b16908c7e48617f0de489742bfce Mon Sep 17 00:00:00 2001 From: Jo Kyung Hyeon Date: Sat, 14 Jan 2023 23:26:28 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20(#281)=20Data=20=EC=9D=B8=EC=9E=90?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/auth/usecase/CheckAuthCodeUseCase.kt | 9 +++++---- .../domain/auth/usecase/SendAuthCodeUseCase.kt | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt index af53bf70..5f9d543a 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/CheckAuthCodeUseCase.kt @@ -1,5 +1,6 @@ package team.comit.simtong.domain.auth.usecase +import team.comit.simtong.domain.auth.dto.request.CheckAuthCodeData import team.comit.simtong.domain.auth.exception.AuthExceptions import team.comit.simtong.domain.auth.model.AuthCodeLimit import team.comit.simtong.domain.auth.spi.CommandAuthCodeLimitPort @@ -21,16 +22,16 @@ class CheckAuthCodeUseCase( private val queryAuthCodePort: QueryAuthCodePort ) { - fun execute(email: String, code: String) { - val authCode = queryAuthCodePort.queryAuthCodeByEmail(email) + fun execute(request: CheckAuthCodeData) { + val authCode = queryAuthCodePort.queryAuthCodeByEmail(request.email) ?: throw AuthExceptions.RequiredNewEmailAuthentication() - if (!authCode.code.match(code)) { + if (!authCode.code.match(request.code)) { throw AuthExceptions.DifferentAuthCode() } commandAuthCodeLimitPort.save( - AuthCodeLimit.certified(email) + AuthCodeLimit.certified(request.email) ) } } \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt index 8820da58..d83b5dd1 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/auth/usecase/SendAuthCodeUseCase.kt @@ -1,5 +1,6 @@ package team.comit.simtong.domain.auth.usecase +import team.comit.simtong.domain.auth.dto.request.SendAuthCodeData import team.comit.simtong.domain.auth.model.AuthCode import team.comit.simtong.domain.auth.model.AuthCodeLimit import team.comit.simtong.domain.auth.spi.CommandAuthCodeLimitPort @@ -24,18 +25,18 @@ class SendAuthCodeUseCase( private val sendEmailPort: SendEmailPort ) { - fun execute(email: String) { - val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(email) - ?: AuthCodeLimit.issue(email) + fun execute(request: SendAuthCodeData) { + val authCodeLimit = queryAuthCodeLimitPort.queryAuthCodeLimitByEmail(request.email) + ?: AuthCodeLimit.issue(request.email) commandAuthCodeLimitPort.save( authCodeLimit.increaseCount() ) val authCode = commandAuthCodePort.save( - AuthCode.issue(email) + AuthCode.issue(request.email) ) - sendEmailPort.sendAuthCode(authCode.code.value, email) + sendEmailPort.sendAuthCode(authCode.code.value, request.email) } } \ No newline at end of file