Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAW-443 탈퇴 시 소셜 플랫폼 정보 제거 로직 추가 #19

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = :userId",
)
fun deleteAllByUserId(@Param(value = "userId") userId: Long)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p1. 둘 중 하나의 방법을 취하면 될 것 같습니다

Suggested change
@Modifying
@Query(
"delete from AuthUserJpaEntity au " +
"where au.user = :userId",
)
fun deleteAllByUserId(@Param(value = "userId") userId: Long)
@Modifying
@Query(
"delete from AuthUserJpaEntity au " +
"where au.user.id = :userId",
)
fun deleteAllByUserId(@Param(value = "userId") userId: Long)
Suggested change
@Modifying
@Query(
"delete from AuthUserJpaEntity au " +
"where au.user = :userId",
)
fun deleteAllByUserId(@Param(value = "userId") userId: Long)
fun deleteByUser_Id(userId: Long)

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.xorker.draw.auth.token

import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying

internal interface RefreshTokenJpaRepository : JpaRepository<RefreshTokenJpaEntity, ByteArray> {
@Modifying
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3. JPA 쓴다면 그냥 써도 되지 않나요?

fun deleteByUserId(userId: Long)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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
Loading