Skip to content

Commit

Permalink
Merge pull request #19 from TeamTroublePainter/feature/DRAW-443
Browse files Browse the repository at this point in the history
DRAW-443 탈퇴 시 소셜 플랫폼 정보 제거 로직 추가
  • Loading branch information
comforest authored Nov 25, 2024
2 parents 8677787 + 77243be commit 98a05ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package com.xorker.draw.auth

import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param

internal interface AuthUserJpaRepository : JpaRepository<AuthUserJpaEntity, Long> {

@Query(
"SELECT au FROM AuthUserJpaEntity au " +
"JOIN FETCH au.user " +
"WHERE au.platformUserId = :platformUserId " +
"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?
fun findByUserId(userId: Long): AuthUserJpaEntity

@Modifying
@Query(
"delete from AuthUserJpaEntity au " +
"where au.user.id = :userId",
)
fun deleteAllByUserId(@Param(value = "userId") userId: Long)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal class UserAdapter(
private val userJpaRepository: UserJpaRepository,
private val authUserJpaRepository: AuthUserJpaRepository,
) : UserRepository {

override fun getUser(platform: AuthPlatform, platformUserId: String): UserInfo? =
authUserJpaRepository.find(platform, platformUserId)?.user?.toDomain()

Expand All @@ -40,6 +41,9 @@ internal class UserAdapter(
override fun withdrawal(userId: UserId) {
val user = userJpaRepository.findByIdOrNull(userId.value) ?: throw NotFoundUserException
user.withdrawal()

authUserJpaRepository.deleteAllByUserId(userId.value)

userJpaRepository.save(user)
}

Expand Down

0 comments on commit 98a05ab

Please sign in to comment.