Skip to content

Commit

Permalink
refactor: (#286) AuthCodeMapper 직접 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
softpeanut committed Jan 9, 2023
1 parent 512ac92 commit d9b0c05
Showing 1 changed file with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package team.comit.simtong.persistence.auth.mapper

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

Expand All @@ -10,9 +11,36 @@ import team.comit.simtong.persistence.auth.entity.AuthCodeEntity
* AuthCodeEntity와 DomainAuthCode를 변환하는 AuthCodeMapper
*
* @author Chokyunghyeon
* @author kimbeomjin
* @date 2022/09/25
* @version 1.0.0
* @version 1.2.5
**/
@Mapper
abstract class AuthCodeMapper : GenericMapper<AuthCodeEntity, AuthCode> {
@Component
class AuthCodeMapper : GenericMapper<AuthCodeEntity, AuthCode> {

override fun toEntity(model: AuthCode): AuthCodeEntity {
return AuthCodeEntity(
key = model.key,
code = model.code.value,
expirationTime = model.expirationTime
)
}

override fun toDomain(entity: AuthCodeEntity?): AuthCode? {
return entity?.let {
AuthCode.of(
key = it.key,
code = Code.of(it.code),
expirationTime = it.expirationTime
)
}
}

override fun toDomainNotNull(entity: AuthCodeEntity): AuthCode {
return AuthCode.of(
key = entity.key,
code = Code.of(entity.code),
expirationTime = entity.expirationTime
)
}
}

0 comments on commit d9b0c05

Please sign in to comment.