Skip to content

Commit

Permalink
Merge pull request #40 from Leets-Official/refactor/#39
Browse files Browse the repository at this point in the history
refactor: 초대장 생성/상세조회 요청, 응답 DTO 수정 및 초대장 엔티티 추가
  • Loading branch information
1winhyun authored Feb 3, 2025
2 parents dcfe859 + 7c975a2 commit 1581657
Show file tree
Hide file tree
Showing 35 changed files with 150 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ interface GuestUseCase {
fun getNotAttendGuestsByInvitation(invitation: Invitation): List<Guest>

fun getInvitationAttendance(memberId: UUID, invitationId: UUID): Boolean?

fun getOwnerNickname(invitationId: UUID, memberId: UUID): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ interface GuestPersistencePort {
fun findNotAttendGuestsByInvitation(invitation: Invitation): List<Guest>

fun findAttendanceByMemberAndInvitation(memberId: UUID, invitationId: UUID): Boolean?

fun findOwnerNickname(invitationId: UUID, memberId: UUID): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class GuestService(
override fun getInvitationAttendance(memberId: UUID, invitationId: UUID): Boolean? =
guestPersistencePort.findAttendanceByMemberAndInvitation(memberId, invitationId)

override fun getOwnerNickname(invitationId: UUID, memberId: UUID): String =
guestPersistencePort.findOwnerNickname(invitationId, memberId)

private fun updateAttendance(guestId: UUID, attendance: Boolean) {
val guest = guestPersistencePort.findById(guestId)
?: throw GuestNotFoundException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Invitation(
val id: UUID,
val member: Member,
var qrUrl: String,
var templateKey: String?,
var deleted: Boolean,
createdAt: LocalDateTime?,
modifiedAt: LocalDateTime?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import site.yourevents.member.domain.Member
data class InvitationVO(
val member: Member,
val qrUrl: String,
val templateKey: String?,
val deleted: Boolean,
) {
companion object {
fun of(member: Member, qrUrl: String, deleted: Boolean): InvitationVO = InvitationVO(
member = member,
qrUrl = qrUrl,
deleted = deleted
fun of(
member: Member,
qrUrl: String,
templateKey: String?,
deleted: Boolean): InvitationVO =
InvitationVO(
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface InvitationUseCase {

fun countByMember(member: Member): Int

fun createInvitation(memberId: UUID, qrUrl: String): Invitation
fun createInvitation(memberId: UUID, qrUrl: String, templateKey: String?): Invitation

fun updateQrCode(invitationId: UUID): Invitation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class InvitationService(

override fun countByMember(member: Member) = invitationPersistencePort.countByMember(member)

override fun createInvitation(memberId: UUID, qrUrl: String): Invitation {
override fun createInvitation(memberId: UUID, qrUrl: String, templateKey: String?): Invitation {
val member = memberUseCase.findById(memberId)
?: throw MemberNotFountException()


return invitationPersistencePort.save(
InvitationVO.of(
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = false
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class GuestTest : DescribeSpec({

val invitationId = UUID.randomUUID()
val qrUrl = "http://example.com"
val templateKey = "templateKey"
val deleted = false

val invitation = Invitation(
id = invitationId,
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ class GuestVOTest : DescribeSpec({

val invitationId = UUID.randomUUID()
val qrUrl = "http://example.com"
val templateKey = "templateKey"
val deleted = false
invitation = Invitation(
id = invitationId,
member = member,
qrUrl = qrUrl,
deleted = false,
templateKey = templateKey,
deleted = deleted,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GuestServiceTest : DescribeSpec({
id = invitationId,
member = member,
qrUrl = "https://qrUrl.com",
templateKey = null,
deleted = false,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ class InvitationTest : DescribeSpec({

val invitationId = UUID.randomUUID()
val qrUrl = "http://example.com"
val templateKey = "templateKey"
val deleted = false
val invitation = Invitation(
id = invitationId,
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand All @@ -40,6 +42,7 @@ class InvitationTest : DescribeSpec({
id shouldBe invitationId
member shouldBe member
qrUrl shouldBe qrUrl
templateKey shouldBe templateKey
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import java.util.UUID
class InvitationVOTest : DescribeSpec({
lateinit var member: Member
lateinit var qrUrl: String
lateinit var templateKey: String
var deleted = false

beforeTest {
Expand All @@ -22,6 +23,7 @@ class InvitationVOTest : DescribeSpec({
modifiedAt = LocalDateTime.now()
)
qrUrl = "http://example.com"
templateKey = "templateKey"
deleted = false
}

Expand All @@ -31,6 +33,7 @@ class InvitationVOTest : DescribeSpec({
val invitationVO = InvitationVO(
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted
)

Expand All @@ -46,10 +49,16 @@ class InvitationVOTest : DescribeSpec({
val originalInvitationVO = InvitationVO(
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted
)

val transformedInvitationVO = InvitationVO.of( originalInvitationVO.member, originalInvitationVO.qrUrl, originalInvitationVO.deleted)
val transformedInvitationVO = InvitationVO.of(
originalInvitationVO.member,
originalInvitationVO.qrUrl,
originalInvitationVO.templateKey,
originalInvitationVO.deleted
)

transformedInvitationVO.apply {
member shouldBe originalInvitationVO.member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class InvitationServiceTest : DescribeSpec({
lateinit var nickname: String
lateinit var email: String
lateinit var qrUrl: String
lateinit var templateKey: String
lateinit var member: Member
var deleted = false

Expand All @@ -36,6 +37,7 @@ class InvitationServiceTest : DescribeSpec({
nickname = "seunghyun"
email = "seunghyun@naver.com"
qrUrl = "http://example.com"
templateKey = "templateKey"
deleted = false

member = Member(
Expand Down Expand Up @@ -63,6 +65,7 @@ class InvitationServiceTest : DescribeSpec({
id = invitationId,
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down Expand Up @@ -101,13 +104,14 @@ class InvitationServiceTest : DescribeSpec({
id = invitationId,
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
)
every { invitationPersistencePort.save(any<InvitationVO>()) } returns savedInvitation

val result = invitationService.createInvitation(memberId, qrUrl)
val result = invitationService.createInvitation(memberId, qrUrl, templateKey)

result shouldBe savedInvitation

Expand All @@ -127,6 +131,7 @@ class InvitationServiceTest : DescribeSpec({
id = invitationId,
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down Expand Up @@ -163,6 +168,7 @@ class InvitationServiceTest : DescribeSpec({
id = invitationId,
member = member,
qrUrl = qrUrl,
templateKey = templateKey,
deleted = false,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class InvitationInformationTest : DescribeSpec({
id = UUID.randomUUID(),
member = member,
qrUrl = "http://example.com",
templateKey = "templateKey",
deleted = false,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class InvitationInformationVOTest : DescribeSpec({
id = UUID.randomUUID(),
member = member,
qrUrl = "http://example.com",
templateKey = null,
deleted = false,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class InvitationInformationServiceTest : DescribeSpec({
id = invitationId,
member = member,
qrUrl = "http://example.com",
templateKey = null,
deleted = false,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ class InvitationThumbnailTest : DescribeSpec({

val invitationId = UUID.randomUUID()
val qrUrl = "http://example.com"
val templateKey = null
val deleted = false
val invitation = Invitation(invitationId, member, qrUrl, deleted, LocalDateTime.now(), LocalDateTime.now())
val invitation = Invitation(
invitationId,
member,
qrUrl,
templateKey,
deleted,
LocalDateTime.now(),
LocalDateTime.now()
)

val thumbnailId = UUID.randomUUID()
val url = "http://example.com/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ class InvitationThumbnailVOTest : DescribeSpec({

val invitationId = UUID.randomUUID()
val qrUrl = "http://example.com"
val templateKey = null
val deleted = false
invitation = Invitation(invitationId, member, qrUrl, deleted, LocalDateTime.now(), LocalDateTime.now())
invitation = Invitation(
invitationId,
member,
qrUrl,
templateKey,
deleted,
LocalDateTime.now(),
LocalDateTime.now()
)

url = "http://example.com/"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class InvitationThumbnailServiceTest : DescribeSpec({
id = invitationId,
member = member,
qrUrl = "http://example.com",
templateKey = null,
deleted = false,
createdAt = LocalDateTime.now(),
modifiedAt = LocalDateTime.now()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ interface GuestJPARepository : JpaRepository<GuestEntity, UUID> {

@Query(
"SELECT DISTINCT i " +
"FROM guest g " +
"JOIN g.invitation i " +
"WHERE g.member = :memberEntity " +
"AND i.member <> :memberEntity " +
"AND i.deleted = false"
"FROM guest g " +
"JOIN g.invitation i " +
"WHERE g.member = :memberEntity " +
"AND i.member <> :memberEntity " +
"AND i.deleted = false"
)
fun getReceivedInvitations(memberEntity: MemberEntity): List<InvitationEntity>

Expand All @@ -46,4 +46,10 @@ interface GuestJPARepository : JpaRepository<GuestEntity, UUID> {
"WHERE g.member.id = :memberId " +
"AND g.invitation.id = :invitationId")
fun findAttendanceByMemberIdAndInvitationId(memberId: UUID, invitationId: UUID): Boolean?

@Query("SELECT g.nickname " +
"FROM guest g " +
"WHERE g.member.id = :memberId " +
"AND g.invitation.id = :invitationId")
fun findOwnerNickname(invitationId: UUID, memberId: UUID): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ class GuestRepository(
override fun findAttendanceByMemberAndInvitation(memberId: UUID, invitationId: UUID): Boolean? {
return guestJPARepository.findAttendanceByMemberIdAndInvitationId(memberId, invitationId)
}

override fun findOwnerNickname(invitationId: UUID, memberId: UUID): String =
guestJPARepository.findOwnerNickname(invitationId, memberId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ class InvitationEntity(
@Column
val qrUrl: String,

@Column
val templateKey: String?,

@Column
val deleted: Boolean,
) : BaseTimeEntity() {
fun toDomain(): Invitation = Invitation(
id = id!!,
member = member.toDomain(),
qrUrl = qrUrl,
templateKey = templateKey,
deleted = deleted,
createdAt = createdAt,
modifiedAt = modifiedAt
Expand All @@ -43,12 +47,14 @@ class InvitationEntity(
id = invitation.id,
member = MemberEntity.from(invitation.member),
qrUrl = invitation.qrUrl,
templateKey = invitation.templateKey,
deleted = invitation.deleted
)

fun from(invitationVO: InvitationVO): InvitationEntity = InvitationEntity(
member = MemberEntity.from(invitationVO.member),
qrUrl = invitationVO.qrUrl,
templateKey = invitationVO.templateKey,
deleted = invitationVO.deleted
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class GuestRepositoryTest(
invitationEntity = InvitationEntity(
member = memberEntity,
qrUrl = "http://example.com",
templateKey = null,
deleted = false
)
invitationJPARepository.save(invitationEntity)
Expand Down
Loading

0 comments on commit 1581657

Please sign in to comment.