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

fix: Alone event status #88

Merged
merged 3 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -7,6 +7,7 @@ import java.time.temporal.ChronoUnit

object GroupViewStatusUtil {
private const val PIC_ON_PROGRESS = "μ‰Ώ PICν•˜λŠ” 쀑"
private const val RECENT_UPDATE = "졜근 μ—…λ°μ΄νŠΈ"
private const val DAYS_AGO_UPDATE = "%d일 μ „ μ—…λ°μ΄νŠΈ"
private const val WEEK_AGO_UPDATE = "일주일 μ „ μ—…λ°μ΄νŠΈ"
private const val TWO_WEEKS_AGO_UPDATE = "이주일 μ „ μ—…λ°μ΄νŠΈ"
Expand All @@ -18,9 +19,9 @@ object GroupViewStatusUtil {
return PIC_ON_PROGRESS
}

val daysSinceUpdate = ChronoUnit.DAYS.between(lastEvent.date.toLocalDate(), LocalDateTime.now().toLocalDate())

val daysSinceUpdate = ChronoUnit.DAYS.between(lastEvent.createdAt.toLocalDate(), LocalDateTime.now().toLocalDate())
return when {
daysSinceUpdate == 0L -> RECENT_UPDATE.format(daysSinceUpdate)
daysSinceUpdate in 1..6 -> DAYS_AGO_UPDATE.format(daysSinceUpdate)
daysSinceUpdate == 7L -> WEEK_AGO_UPDATE
daysSinceUpdate in 8..13 -> DAYS_AGO_UPDATE.format(daysSinceUpdate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class EventService(
groupId = groupId,
description = description,
date = date,
eventStatus = EventStatus.VOTING
eventStatus = EventStatus.VOTING,
uploadingEndDate = LocalDateTime.now()
)
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ class GroupService(
groupId: Long
) {
if (!groupJoinRepository.existsByUserIdAndGroupId(userId, groupId)) {
throw PicException.of(PicExceptionType.NOT_EXIST, "μ°Έμ—¬ν•˜κ³  μžˆλŠ” 그룹이 μ•„λ‹™λ‹ˆλ‹€")
throw PicException.of(PicExceptionType.NOT_EXIST, "$groupId λŠ” μ°Έμ—¬ν•˜κ³  μžˆλŠ” 그룹이 μ•„λ‹™λ‹ˆλ‹€")
}

groupJoinRepository.deleteByUserIdAndGroupId(userId, groupId)
}

private fun getEventById(eventId: Long): Event {
return eventRepository.findByIdOrNull(eventId)
?: throw PicException.of(PicExceptionType.ARGUMENT_NOT_VALID, "μ—†λŠ” 이벀트")
?: throw PicException.of(PicExceptionType.ARGUMENT_NOT_VALID, "μ—†λŠ” 이벀트 $eventId")
}

private fun validateUser(userId: Long) {
Expand Down Expand Up @@ -105,7 +105,7 @@ class GroupService(
groupId: Long
) {
if (hadAlreadyJoined(userId, groupId)) {
throw PicException.of(PicExceptionType.ARGUMENT_NOT_VALID, "이미 μ°Έμ—¬")
throw PicException.of(PicExceptionType.ARGUMENT_NOT_VALID, "이미 μ°Έμ—¬ 쀑인 κ·Έλ£Ή $groupId")
}
}

Expand All @@ -129,6 +129,6 @@ class GroupService(
}

companion object {
const val GROUP_MEMBER_MAX_COUNT = 4
const val GROUP_MEMBER_MAX_COUNT = 6
}
}
Loading