Skip to content

Commit

Permalink
Feat: 회원 탈퇴
Browse files Browse the repository at this point in the history
  • Loading branch information
adorableco committed Sep 10, 2024
1 parent c576c3a commit 3d32364
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 13 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.swm_standard.phote.controller

import com.swm_standard.phote.common.resolver.memberId.MemberId
import com.swm_standard.phote.common.responsebody.BaseResponse
import com.swm_standard.phote.service.MemberService
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.util.UUID

@RestController
@RequestMapping("/api")
class MemberController(
private val memberService: MemberService,
) {
@DeleteMapping("/member")
fun deleteMember(
@MemberId memberId: UUID,
): BaseResponse<UUID> {
val uuid = memberService.deleteMember(memberId)

return BaseResponse(msg = "멤버 탈퇴 성공", data = uuid)
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/swm_standard/phote/entity/Exam.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.util.UUID

@Entity
data class Exam(
@ManyToOne
@ManyToOne(cascade = [(CascadeType.REMOVE)])
@JoinColumn(name = "member_id")
val member: Member,
@ManyToOne
Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/com/swm_standard/phote/entity/Member.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.swm_standard.phote.entity

import jakarta.persistence.*
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import jakarta.persistence.Id
import java.util.UUID

@Entity
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/swm_standard/phote/entity/Question.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.UUID
data class Question(
@Id @Column(name = "question_uuid", nullable = false, unique = true)
val id: UUID = UUID.randomUUID(),
@ManyToOne
@ManyToOne(cascade = [(CascadeType.REMOVE)])
@JoinColumn(name = "member_id")
@JsonIgnore
val member: Member,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.springframework.data.redis.core.RedisHash
import java.time.LocalDateTime
import java.util.UUID

@RedisHash(value = "refreshToken", timeToLive = 1296000)
@RedisHash(value = "refreshToken", timeToLive = 12960000)
data class RefreshToken(
@Id
val refreshToken: UUID,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/swm_standard/phote/entity/Workbook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.util.UUID
data class Workbook(
var title: String,
var description: String?,
@ManyToOne
@ManyToOne(cascade = [(CascadeType.REMOVE)])
@JoinColumn(name = "member_id")
@JsonIgnore
val member: Member,
Expand Down
19 changes: 19 additions & 0 deletions src/main/kotlin/com/swm_standard/phote/service/MemberService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.swm_standard.phote.service

import com.swm_standard.phote.repository.MemberRepository
import org.springframework.stereotype.Service
import java.util.UUID

@Service
class MemberService(
private val memberRepository: MemberRepository,
) {
fun deleteMember(memberId: UUID): UUID {
memberRepository.deleteById(memberId)
if (memberRepository.existsById(memberId)) {
throw IllegalStateException()
}

return memberId
}
}

0 comments on commit 3d32364

Please sign in to comment.