diff --git a/user-api/src/main/kotlin/com/sns/user/component/authcode/domain/AuthCode.kt b/user-api/src/main/kotlin/com/sns/user/component/authcode/domain/AuthCode.kt index 5c300e2..c283c6e 100644 --- a/user-api/src/main/kotlin/com/sns/user/component/authcode/domain/AuthCode.kt +++ b/user-api/src/main/kotlin/com/sns/user/component/authcode/domain/AuthCode.kt @@ -4,6 +4,7 @@ import kotlin.random.Random import java.sql.ResultSet import java.time.Instant import javax.validation.constraints.NotBlank +import org.springframework.jdbc.core.DataClassRowMapper import org.springframework.jdbc.core.RowMapper data class AuthCode( @@ -26,7 +27,7 @@ data class AuthCode( private const val CODE_LENGTH = 10; private val charPool: List = ('a'..'z') + ('A'..'Z') + ('0'..'9') fun createSignUp(userId: String) = AuthCode(purpose = Purpose.SIGN_UP, userId = userId) - val MAPPER: RowMapper = AuthCodeRowMapper() + val MAPPER: RowMapper = DataClassRowMapper(AuthCode::class.java) } } diff --git a/user-api/src/main/kotlin/com/sns/user/component/user/domains/User.kt b/user-api/src/main/kotlin/com/sns/user/component/user/domains/User.kt index a17a405..60651bd 100644 --- a/user-api/src/main/kotlin/com/sns/user/component/user/domains/User.kt +++ b/user-api/src/main/kotlin/com/sns/user/component/user/domains/User.kt @@ -4,12 +4,17 @@ import com.sns.commons.DomainEvent import com.sns.user.component.user.dtos.FriendRequestedEvent import com.sns.user.component.user.events.UserStatusChangedEvent import com.sns.user.core.exceptions.AlreadyExistException + +import java.time.Instant +import javax.validation.constraints.Max +import javax.validation.constraints.NotBlank import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.Id import org.springframework.data.annotation.LastModifiedDate import org.springframework.data.annotation.Transient import org.springframework.data.domain.Persistable import org.springframework.data.relational.core.mapping.MappedCollection +import org.springframework.jdbc.core.DataClassRowMapper import org.springframework.jdbc.core.RowMapper import java.sql.ResultSet import java.time.Instant @@ -87,7 +92,7 @@ data class User( } companion object { - val MAPPER: RowMapper = UserRowMapper() + val MAPPER: RowMapper = DataClassRowMapper(User::class.java) fun create( id: String, @@ -112,21 +117,6 @@ data class User( } } -// purpose enum 매핑이 안되서 수동으로 작성함. 확인필요. -class UserRowMapper : RowMapper { - override fun mapRow(rs: ResultSet, rowNum: Int): User? { - return User( - id = rs.getString("id"), - password = rs.getString("password"), - name = rs.getString("name"), - infoEmailAddress = rs.getString("info_email_address"), - status = Status.valueOf(rs.getString("status")), - createdAt = Instant.ofEpochMilli(rs.getTimestamp("created_at").time), - updatedAt = Instant.ofEpochMilli(rs.getTimestamp("updated_at").time), - ) - } -} - enum class Status { CREATED, ACTIVATED; diff --git a/user-api/src/main/kotlin/com/sns/user/component/user/events/UserStatusChangedEvent.kt b/user-api/src/main/kotlin/com/sns/user/component/user/events/UserStatusChangedEvent.kt index 473a85f..60a4e54 100644 --- a/user-api/src/main/kotlin/com/sns/user/component/user/events/UserStatusChangedEvent.kt +++ b/user-api/src/main/kotlin/com/sns/user/component/user/events/UserStatusChangedEvent.kt @@ -4,9 +4,4 @@ import com.sns.commons.DomainEvent import com.sns.user.component.user.domains.User import com.sns.user.core.config.IntegrationConfig -class UserStatusChangedEvent(val user: User) : DomainEvent { - override val eventId: String - get() = "$channel-$user.id-${System.currentTimeMillis()}" - - override val channel = IntegrationConfig.Channels.USER_STATUS -} +class UserStatusChangedEvent(val user: User) : DomainEvent(IntegrationConfig.Channels.USER_STATUS, user.id) diff --git a/user-api/src/test/resources/application.yml b/user-api/src/test/resources/application.yml index 9407c56..f3a6db3 100644 --- a/user-api/src/test/resources/application.yml +++ b/user-api/src/test/resources/application.yml @@ -3,10 +3,10 @@ server: logging: level: root: info - org: trace - # springframework: - # jdbc: - # core: debug + org: + springframework: + jdbc: + core: debug pattern: console: "%d{HH:mm:ss} [%t][%-5level] %msg \\(%F:%L\\)%n" spring: