diff --git a/src/main/kotlin/com/wafflestudio/spring2025/common/email/service/EmailService.kt b/src/main/kotlin/com/wafflestudio/spring2025/common/email/service/EmailService.kt
index e6ce680..f05cf47 100644
--- a/src/main/kotlin/com/wafflestudio/spring2025/common/email/service/EmailService.kt
+++ b/src/main/kotlin/com/wafflestudio/spring2025/common/email/service/EmailService.kt
@@ -99,6 +99,7 @@ class EmailService(
val registrationStartsAt: Instant?,
val registrationEndsAt: Instant?,
val description: String?,
+ val publicId: String?,
)
data class EventCancellationEmailData(
@@ -120,6 +121,7 @@ class EmailService(
val endsAt: Instant?,
val location: String?,
val newCapacity: Int,
+ val totalCount: Int,
val registrationStartsAt: Instant?,
val registrationEndsAt: Instant,
val description: String?,
@@ -138,8 +140,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
- .replace("{totalCount}", data.totalCount?.toString() ?: "null")
- .replace("{capacity}", data.capacity?.toString() ?: "null")
+ .replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
@@ -165,8 +166,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
- .replace("{totalCount}", data.totalCount?.toString() ?: "null")
- .replace("{capacity}", data.capacity?.toString() ?: "null")
+ .replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
@@ -189,8 +189,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
- .replace("{totalCount}", data.totalCount?.toString() ?: "null")
- .replace("{capacity}", data.capacity?.toString() ?: "null")
+ .replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
@@ -213,16 +212,17 @@ class EmailService(
fun sendRegistrationDeleteEmail(data: RegistrationDeleteEmailData) {
val htmlContent =
loadTemplate("registration-delete.html")
+ .replace("{serviceDomain}", emailConfig.serviceDomain)
.replace("{name}", data.name)
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
- .replace("{totalCount}", data.totalCount?.toString() ?: "null")
- .replace("{capacity}", data.capacity?.toString() ?: "null")
+ .replace("{capacityDisplay}", formatCapacity(data.totalCount, data.capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(data.registrationStartsAt, data.registrationEndsAt),
).replace("{description}", formatDescription(data.description))
+ .replace("{publicId}", data.publicId ?: "-")
sendHtmlEmail(
to = data.toEmail,
@@ -258,7 +258,7 @@ class EmailService(
.replace("{serviceDomain}", emailConfig.serviceDomain)
.replace("{name}", data.name)
.replace("{waitingNum}", data.waitingNum?.toString() ?: "-")
- .replace("{newCapacity}", data.newCapacity.toString())
+ .replace("{capacityDisplay}", formatCapacity(data.totalCount, data.newCapacity))
.replace("{eventTitle}", formatEventTitle(data.eventTitle))
.replace("{eventDateRange}", formatEventDateRange(data.startsAt, data.endsAt, "-"))
.replace("{location}", formatLocation(data.location))
@@ -302,8 +302,7 @@ class EmailService(
.replace("{eventTitle}", formatEventTitle(eventTitle))
.replace("{eventDateRange}", formatEventDateRange(startsAt, endsAt, "~"))
.replace("{location}", formatLocation(location))
- .replace("{totalCount}", totalCount?.toString() ?: "null")
- .replace("{capacity}", capacity?.toString() ?: "null")
+ .replace("{capacityDisplay}", formatCapacity(totalCount, capacity))
.replace(
"{registrationDateRange}",
formatRegistrationDateRange(registrationStartsAt, registrationEndsAt),
@@ -368,6 +367,20 @@ class EmailService(
}
}
+ private fun formatCapacity(
+ totalCount: Int?,
+ capacity: Int?,
+ ): String {
+ if (capacity == null) return "${totalCount ?: "-"}명"
+ val confirmed = if (totalCount != null) minOf(totalCount, capacity) else capacity
+ val waitlisted = if (totalCount != null) maxOf(0, totalCount - capacity) else 0
+ return if (waitlisted > 0) {
+ "$confirmed/${capacity}명 (대기자 ${waitlisted}명)"
+ } else {
+ "$confirmed/${capacity}명"
+ }
+ }
+
private fun formatDescription(description: String?): String {
if (description == null) return "-"
return description.replace("\r\n", "\n").replace("\n", "
")
diff --git a/src/main/kotlin/com/wafflestudio/spring2025/domain/registration/service/RegistrationService.kt b/src/main/kotlin/com/wafflestudio/spring2025/domain/registration/service/RegistrationService.kt
index 46ea8c7..6aff4dd 100644
--- a/src/main/kotlin/com/wafflestudio/spring2025/domain/registration/service/RegistrationService.kt
+++ b/src/main/kotlin/com/wafflestudio/spring2025/domain/registration/service/RegistrationService.kt
@@ -273,6 +273,7 @@ RegistrationService(
registrationStartsAt = event.registrationStartsAt,
registrationEndsAt = event.registrationEndsAt,
description = event.description,
+ publicId = event.publicId,
)
afterCommit {
@@ -673,6 +674,9 @@ RegistrationService(
toDemote.forEach { it.status = RegistrationStatus.WAITLISTED }
registrationRepository.saveAll(toDemote)
+ val waitlistedCount = registrationRepository.countByEventIdAndStatus(eventId, RegistrationStatus.WAITLISTED).toInt()
+ val totalCount = newCapacity + waitlistedCount
+
val demotedPublicIds = toDemote.map { it.registrationPublicId }
val waitlistPositions =
registrationRepository
@@ -698,6 +702,7 @@ RegistrationService(
endsAt = event.endsAt,
location = event.location,
newCapacity = newCapacity,
+ totalCount = totalCount,
registrationStartsAt = event.registrationStartsAt,
registrationEndsAt = event.registrationEndsAt,
description = event.description,
diff --git a/src/main/resources/com/wafflestudio/spring2025/common/email/template/registration-banned.html b/src/main/resources/com/wafflestudio/spring2025/common/email/template/registration-banned.html
index 7bd8a68..573ae04 100644
--- a/src/main/resources/com/wafflestudio/spring2025/common/email/template/registration-banned.html
+++ b/src/main/resources/com/wafflestudio/spring2025/common/email/template/registration-banned.html
@@ -73,7 +73,7 @@
alt="user" width="20" style="display: block; border: 0;">