-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
94 additions
and
15 deletions.
There are no files selected for viewing
32 changes: 17 additions & 15 deletions
32
adapter/rdb/src/main/kotlin/com/xorker/draw/auth/AuthUserJpaRepository.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,15 +1,17 @@ | ||
package com.xorker.draw.auth | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
|
||
internal interface AuthUserJpaRepository : JpaRepository<AuthUserJpaEntity, Long> { | ||
|
||
@Query( | ||
"SELECT au FROM AuthUserJpaEntity au " + | ||
"JOIN FETCH au.user " + | ||
"WHERE au.platformUserId = :platformUserId " + | ||
"and au.platform=:platform ", | ||
) | ||
fun find(platform: AuthPlatform, platformUserId: String): AuthUserJpaEntity? | ||
} | ||
package com.xorker.draw.auth | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
import org.springframework.data.jpa.repository.Query | ||
|
||
internal interface AuthUserJpaRepository : JpaRepository<AuthUserJpaEntity, Long> { | ||
|
||
@Query( | ||
"SELECT au FROM AuthUserJpaEntity au " + | ||
"JOIN FETCH au.user " + | ||
"WHERE au.platformUserId = :platformUserId " + | ||
"and au.platform=:platform ", | ||
) | ||
fun find(platform: AuthPlatform, platformUserId: String): AuthUserJpaEntity? | ||
|
||
fun findByUserId(userId: Long): AuthUserJpaEntity? | ||
} |
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,5 +1,6 @@ | ||
package com.xorker.draw.user | ||
|
||
import com.xorker.draw.auth.AuthInfo | ||
import com.xorker.draw.auth.AuthPlatform | ||
import com.xorker.draw.auth.AuthUserJpaEntity | ||
import com.xorker.draw.auth.AuthUserJpaRepository | ||
|
@@ -19,6 +20,10 @@ internal class UserAdapter( | |
override fun getUser(userId: UserId): UserInfo? = | ||
userJpaRepository.findByIdOrNull(userId.value)?.toDomain() | ||
|
||
override fun getAuthInfo(userId: UserId): AuthInfo? { | ||
return authUserJpaRepository.findByUserId(userId.value)?.toDomain() | ||
} | ||
|
||
override fun createUser(platform: AuthPlatform, platformUserId: String, userName: String): UserInfo { | ||
val user = UserJpaEntity() | ||
val authUser = authUserJpaRepository.save(AuthUserJpaEntity.of(platform, platformUserId, user)) | ||
|
@@ -45,4 +50,9 @@ internal class UserAdapter( | |
user.name = nickname | ||
return userJpaRepository.save(user).toUser() | ||
} | ||
|
||
private fun AuthUserJpaEntity.toDomain(): AuthInfo = AuthInfo( | ||
this.platform, | ||
"[email protected]", // TODO | ||
) | ||
} |
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
22 changes: 22 additions & 0 deletions
22
app/api/src/main/kotlin/com/xorker/draw/user/dto/UserDetailResponse.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,22 @@ | ||
package com.xorker.draw.user.dto | ||
|
||
import com.xorker.draw.auth.AuthPlatform | ||
import com.xorker.draw.user.UserDetail | ||
import com.xorker.draw.user.UserId | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class UserDetailResponse( | ||
val id: UserId, | ||
val nickname: String?, | ||
|
||
@Schema(description = "null 일 경우 게스트") | ||
val authPlatform: AuthPlatform?, | ||
val email: String?, | ||
) | ||
|
||
fun UserDetail.toResponse(): UserDetailResponse = UserDetailResponse( | ||
id = this.id, | ||
nickname = this.name, | ||
authPlatform = this.authPlatform, | ||
email = this.email, | ||
) |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.xorker.draw.user | ||
|
||
interface UserUseCase { | ||
fun getUserDetail(userId: UserId): UserDetail | ||
|
||
fun updateUser(userId: UserId, nickname: String): User | ||
} |
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,6 @@ | ||
package com.xorker.draw.auth | ||
|
||
data class AuthInfo( | ||
val authPlatform: AuthPlatform, | ||
val email: String, | ||
) |
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
3 changes: 3 additions & 0 deletions
3
domain/src/main/kotlin/com/xorker/draw/user/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