Skip to content

Commit

Permalink
add: #(78) 이메일 인증 외부 영역 설계
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Sep 25, 2022
1 parent bad95f6 commit 5418d5d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package team.comit.simtong.persistence.auth

import org.springframework.stereotype.Component
import team.comit.simtong.domain.auth.model.AuthCodeLimit
import team.comit.simtong.domain.auth.spi.AuthCodeLimitPort
import team.comit.simtong.persistence.auth.mapper.AuthCodeLimitMapper
import team.comit.simtong.persistence.auth.repository.AuthCodeLimitRepository
Expand All @@ -24,4 +25,10 @@ class AuthCodeLimitPersistenceAdapter(
authCodeLimitRepository.queryAuthCodeLimitEntityByKey(email)
)

override fun save(authCodeLimit: AuthCodeLimit) = authCodeLimitMapper.toDomain(
authCodeLimitRepository.save(
authCodeLimitMapper.toEntity(authCodeLimit)
)
)!!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package team.comit.simtong.persistence.auth

import org.springframework.stereotype.Component
import team.comit.simtong.domain.auth.model.AuthCode
import team.comit.simtong.domain.auth.spi.AuthCodePort
import team.comit.simtong.persistence.auth.mapper.AuthCodeMapper
import team.comit.simtong.persistence.auth.repository.AuthCodeRepository

/**
*
* AuthCode를 관리하는 AuthCodePersistenceAdapter
*
* @author Chokyunghyeon
* @date 2022/09/25
* @version 1.0.0
**/
@Component
class AuthCodePersistenceAdapter(
private val authCodeMapper: AuthCodeMapper,
private val authCodeRepository: AuthCodeRepository
): AuthCodePort {

override fun existsAuthCodeByEmailAndCode(email: String, code: String) =
authCodeRepository.existsAuthCodeEntityByKeyAndCode(email, code)

override fun save(authCode: AuthCode) = authCodeMapper.toDomain(
authCodeRepository.save(
authCodeMapper.toEntity(authCode)
)
)!!

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.hibernate.validator.constraints.Length
import org.springframework.data.annotation.Id
import org.springframework.data.redis.core.RedisHash
import org.springframework.data.redis.core.TimeToLive
import org.springframework.data.redis.core.index.Indexed
import javax.validation.constraints.NotNull

/**
Expand All @@ -22,6 +23,7 @@ class AuthCodeEntity(

@field:NotNull
@field:Length(max = 6)
@Indexed
val code: String,

@field:NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class AuthCodeLimitEntity(

@field:NotNull
@TimeToLive
val expirationTime: Int
) {
val expirationTime: Int,

@field:NotNull
@ColumnDefault("1")
val attemptCount: Short = 1
val attemptCount: Short = 1,

@field:NotNull
@ColumnDefault("false")
val isVerified: Boolean = false
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package team.comit.simtong.persistence.auth.mapper

import org.mapstruct.Mapper
import team.comit.simtong.domain.auth.model.AuthCode
import team.comit.simtong.persistence.GenericMapper
import team.comit.simtong.persistence.auth.entity.AuthCodeEntity

/**
*
* AuthCodeEntity와 DomainAuthCode를 변환하는 AuthCodeMapper
*
* @author Chokyunghyeon
* @date 2022/09/25
* @version 1.0.0
**/
@Mapper
abstract class AuthCodeMapper : GenericMapper<AuthCodeEntity, AuthCode> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ import team.comit.simtong.persistence.auth.entity.AuthCodeEntity
**/
@Repository
interface AuthCodeRepository : CrudRepository<AuthCodeEntity, String> {

fun existsAuthCodeEntityByKeyAndCode(key: String, code: String): Boolean

}

0 comments on commit 5418d5d

Please sign in to comment.