-
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
1 parent
0e4f5a2
commit 24aad6c
Showing
11 changed files
with
64 additions
and
29 deletions.
There are no files selected for viewing
20 changes: 14 additions & 6 deletions
20
...gym-application/src/main/kotlin/com/info/maeumgagym/domain/user/UserPersistenceAdapter.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,23 +1,31 @@ | ||
package com.info.maeumgagym.domain.user | ||
|
||
import com.info.common.PersistenceAdapter | ||
import com.info.maeumgagym.domain.user.exception.UserNotFoundException | ||
import com.info.maeumgagym.domain.user.mapper.UserMapper | ||
import com.info.maeumgagym.domain.user.repository.UserRepository | ||
import com.info.maeumgagym.user.model.User | ||
import com.info.maeumgagym.user.port.out.CreateUserPort | ||
import com.info.maeumgagym.user.port.out.FindUserByOAuthIdPort | ||
import com.info.maeumgagym.user.port.out.FindUserPort | ||
import org.springframework.data.repository.findByIdOrNull | ||
import java.util.* | ||
|
||
@PersistenceAdapter | ||
class UserPersistenceAdapter() : FindUserPort, CreateUserPort, FindUserByOAuthIdPort { | ||
class UserPersistenceAdapter( | ||
private val userRepository: UserRepository, | ||
private val userMapper: UserMapper | ||
) : FindUserPort, CreateUserPort, FindUserByOAuthIdPort { | ||
override fun findUserById(userId: UUID): User { | ||
TODO("Not yet implemented") | ||
val user = userRepository.findByIdOrNull(userId) ?: throw UserNotFoundException | ||
return userMapper.toDomain(user) | ||
} | ||
|
||
override fun createUser(user: User): User { | ||
TODO("Not yet implemented") | ||
val userJpaEntity = userRepository.save(userMapper.toEntity(user)) | ||
return userMapper.toDomain(userJpaEntity) | ||
} | ||
|
||
override fun findUserByOAuthId(oauthId: String): User? { | ||
TODO("Not yet implemented") | ||
} | ||
override fun findUserByOAuthId(oauthId: String): User? = | ||
userRepository.findByOauthId(oauthId)?.let { userMapper.toDomain(it) } | ||
} |
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
26 changes: 26 additions & 0 deletions
26
maeumgagym-application/src/main/kotlin/com/info/maeumgagym/domain/user/mapper/UserMapper.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,26 @@ | ||
package com.info.maeumgagym.domain.user.mapper | ||
|
||
import com.info.maeumgagym.domain.user.entity.UserJpaEntity | ||
import com.info.maeumgagym.user.model.User | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class UserMapper { | ||
fun toEntity(user: User): UserJpaEntity { | ||
return UserJpaEntity( | ||
id = user.id, | ||
nickname = user.nickname, | ||
oauthId = user.oauthId, | ||
roles = user.roles | ||
) | ||
} | ||
|
||
fun toDomain(userJpaEntity: UserJpaEntity): User { | ||
return User( | ||
id = userJpaEntity.id!!, | ||
nickname = userJpaEntity.nickname, | ||
oauthId = userJpaEntity.oauthId, | ||
roles = userJpaEntity.roles | ||
) | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
maeumgagym-application/src/main/kotlin/com/info/maeumgagym/domain/user/role/Role.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
maeumgagym-core/src/main/kotlin/com/info/maeumgagym/auth/dto/response/KakaoInfoResponse.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
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