-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User bounded context에서 JPA 사용하도록 수정 (#348)
* User bounded context에서 JPA 사용하도록 수정 * 리뷰: JpaRepository 구현체를 따로 두지 않기 * json list로 변경하는 건 나중에
- Loading branch information
Showing
44 changed files
with
420 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
app-server/subprojects/bounded_context/user/application/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
dependencies { | ||
implementation(projects.crossCuttingConcern.application.serverEvent) | ||
|
||
implementation("org.springframework.boot:spring-boot-starter-data-jpa") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
.../kotlin/club/staircrusher/user/application/port/out/persistence/UserAuthInfoRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package club.staircrusher.user.application.port.out.persistence | ||
|
||
import club.staircrusher.stdlib.domain.repository.EntityRepository | ||
import club.staircrusher.user.domain.model.UserAuthInfo | ||
import club.staircrusher.user.domain.model.UserAuthProviderType | ||
import org.springframework.data.repository.CrudRepository | ||
import org.springframework.stereotype.Repository | ||
|
||
interface UserAuthInfoRepository : EntityRepository<UserAuthInfo, String> { | ||
fun findByExternalId(authProviderType: UserAuthProviderType, externalId: String): UserAuthInfo? | ||
@Repository | ||
interface UserAuthInfoRepository : CrudRepository<UserAuthInfo, String> { | ||
fun findFirstByAuthProviderTypeAndExternalId(authProviderType: UserAuthProviderType, externalId: String): UserAuthInfo? | ||
fun findByUserId(userId: String): List<UserAuthInfo> | ||
fun removeByUserId(userId: String) | ||
} |
13 changes: 7 additions & 6 deletions
13
...src/main/kotlin/club/staircrusher/user/application/port/out/persistence/UserRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies { | ||
implementation("jakarta.persistence:jakarta.persistence-api") | ||
} |
31 changes: 30 additions & 1 deletion
31
...s/bounded_context/user/domain/src/main/kotlin/club/staircrusher/user/domain/model/User.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,51 @@ | ||
package club.staircrusher.user.domain.model | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Convert | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import jakarta.persistence.Table | ||
import jakarta.persistence.Transient | ||
import java.time.Instant | ||
|
||
data class User( | ||
@Entity | ||
@Table(name = "scc_user") | ||
class User( | ||
@Id | ||
val id: String, | ||
var nickname: String, | ||
@Deprecated("닉네임 로그인은 사라질 예정") var encryptedPassword: String?, | ||
var instagramId: String?, | ||
var email: String?, // FIXME: 레거시 계정이 모두 사라지면 non-nullable로 변경 | ||
@Column(columnDefinition = "TEXT") | ||
@Convert(converter = UserMobilityToolListToTextAttributeConverter::class) | ||
val mobilityTools: MutableList<UserMobilityTool>, | ||
val createdAt: Instant, | ||
) { | ||
var deletedAt: Instant? = null // private으로 둘 방법이 없을까? 지금은 persistence_model 모듈에서 써야 해서 안 된다. | ||
|
||
@get:Transient | ||
val isDeleted: Boolean | ||
get() = deletedAt != null | ||
|
||
fun delete(deletedAt: Instant) { | ||
this.deletedAt = deletedAt | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as User | ||
|
||
return id == other.id | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return id.hashCode() | ||
} | ||
|
||
override fun toString(): String { | ||
return "User(nickname='$nickname', id='$id', encryptedPassword=$encryptedPassword, instagramId=$instagramId, email=$email, mobilityTools=$mobilityTools, createdAt=$createdAt, deletedAt=$deletedAt, isDeleted=$isDeleted)" | ||
} | ||
} |
8 changes: 7 additions & 1 deletion
8
...d_context/user/domain/src/main/kotlin/club/staircrusher/user/domain/model/UserAuthInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...otlin/club/staircrusher/user/domain/model/UserMobilityToolListToTextAttributeConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package club.staircrusher.user.domain.model | ||
|
||
import club.staircrusher.stdlib.jpa.ListToTextAttributeConverter | ||
import jakarta.persistence.Converter | ||
|
||
@Converter | ||
object UserMobilityToolListToTextAttributeConverter : ListToTextAttributeConverter<UserMobilityTool>() { | ||
override fun convertElementToTextColumn(element: UserMobilityTool): String { | ||
return element.name | ||
} | ||
|
||
override fun convertElementFromTextColumn(text: String): UserMobilityTool { | ||
return UserMobilityTool.valueOf(text) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.