-
Notifications
You must be signed in to change notification settings - Fork 0
π :: νμνμμ μΈμΆ μνλ₯Ό κ΄λ¦¬νλ κΈ°λ₯ ꡬν #8
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
base: main
Are you sure you want to change the base?
Changes from all commits
65a3c33
f6a8549
3559f95
4d5964f
a7eefac
7444e20
46ebf71
cf379b6
736be46
b04e145
6e4abd0
275c672
fc2439e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| package com.project.goms.domain.account.entity | ||
|
|
||
| enum class Authority{ | ||
|
|
||
| ROLE_STUDENT, | ||
| ROLE_STUDENT_COUNCIL; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.project.goms.domain.outing.common.exception | ||
|
|
||
| import com.project.goms.global.error.ErrorCode | ||
| import com.project.goms.global.error.exception.GomsException | ||
|
|
||
| class PublicHolidayException : GomsException(ErrorCode.PUBLIC_HOLIDAY_EXCEPTION) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.project.goms.domain.outing.entity | ||
|
|
||
| enum class OutingStatus { | ||
| AVAILABLE, | ||
| UNAVAILABLE, | ||
| PUBLIC_HOLIDAY | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.project.goms.domain.studentCouncil.common.property | ||
|
|
||
| import org.springframework.boot.context.properties.ConfigurationProperties | ||
| import org.springframework.boot.context.properties.ConstructorBinding | ||
|
|
||
| @ConstructorBinding | ||
| @ConfigurationProperties("outing.status") | ||
| class OutingStatusExpTimeProperties ( | ||
| val expiredAt : Int | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| package com.project.goms.domain.studentCouncil.common.util | ||
|
|
||
| import com.project.goms.domain.studentCouncil.presentation.data.request.GrantAuthorityRequest | ||
| import com.project.goms.domain.studentCouncil.presentation.data.request.OutingBanRequest | ||
| import com.project.goms.domain.studentCouncil.presentation.data.response.AllAccountResponse | ||
| import com.project.goms.domain.studentCouncil.usecase.dto.AllAccountDto | ||
| import com.project.goms.domain.studentCouncil.usecase.dto.GrantAuthorityDto | ||
| import com.project.goms.domain.studentCouncil.usecase.dto.OutingBanDto | ||
|
|
||
| interface StudentCouncilConverter { | ||
|
|
||
| fun toDto(request: GrantAuthorityRequest): GrantAuthorityDto | ||
| fun toDto(request: OutingBanRequest): OutingBanDto | ||
| fun toResponse(dto: List<AllAccountDto>): List<AllAccountResponse> | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.project.goms.domain.studentCouncil.entity | ||
|
|
||
| import org.springframework.data.annotation.Id | ||
| import org.springframework.data.redis.core.RedisHash | ||
| import org.springframework.data.redis.core.TimeToLive | ||
| import java.util.* | ||
| import java.util.concurrent.TimeUnit | ||
|
|
||
| @RedisHash("outing_status") | ||
| data class OutingStatus ( | ||
| @Id | ||
| val outingStatusUUID: UUID, | ||
|
|
||
| @TimeToLive(unit = TimeUnit.SECONDS) | ||
| val expiredAt: Int | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.project.goms.domain.studentCouncil.entity.repository | ||
|
|
||
| import com.project.goms.domain.studentCouncil.entity.OutingStatus | ||
| import org.springframework.data.repository.CrudRepository | ||
| import java.util.UUID | ||
|
|
||
| interface OutingStatusRepository: CrudRepository<OutingStatus, UUID> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.project.goms.domain.studentCouncil.presentation.data.request | ||
|
|
||
| import org.jetbrains.annotations.NotNull | ||
|
|
||
| data class OutingBanRequest( | ||
| @field:NotNull | ||
| val status: Boolean | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.project.goms.domain.studentCouncil.usecase | ||
|
|
||
| import com.project.goms.domain.studentCouncil.common.property.OutingStatusExpTimeProperties | ||
| import com.project.goms.domain.studentCouncil.entity.OutingStatus | ||
| import com.project.goms.domain.studentCouncil.entity.repository.OutingStatusRepository | ||
| import com.project.goms.domain.studentCouncil.usecase.dto.OutingBanDto | ||
| import com.project.goms.global.annotation.UseCaseWithTransaction | ||
| import mu.KotlinLogging | ||
| import java.util.* | ||
|
|
||
| private val log = KotlinLogging.logger {} | ||
|
|
||
| @UseCaseWithTransaction | ||
| class OutingBanUseCase( | ||
| private val outingStatusRepository: OutingStatusRepository, | ||
| private val outingStatusExpTimeProperties: OutingStatusExpTimeProperties | ||
| ) { | ||
|
|
||
| fun execute(outingBanDto: OutingBanDto) { | ||
| when (outingBanDto.status) { | ||
| true -> { | ||
| val outingStatus = OutingStatus( | ||
| outingStatusUUID = UUID.randomUUID(), | ||
| expiredAt = outingStatusExpTimeProperties.expiredAt | ||
| ) | ||
| log.info("μ΄λ²μ£Όλ μΈμΆ λΆκ°λ₯ μν μ λλ€.") | ||
| outingStatusRepository.save(outingStatus) | ||
| } | ||
|
|
||
| false -> { | ||
| log.info("μ΄λ²μ£Όλ μΈμΆ κ°λ₯ν μνμ λλ€.") | ||
| outingStatusRepository.deleteAll() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.project.goms.domain.studentCouncil.usecase.dto | ||
|
|
||
| data class OutingBanDto( | ||
| val status : Boolean | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| package com.project.goms.infrastructure.discord.usecase | ||
|
|
||
| import com.project.goms.domain.late.entity.repository.LateRepository | ||
| import com.project.goms.domain.outing.common.exception.PublicHolidayException | ||
| import com.project.goms.domain.outing.entity.OutingStatus | ||
| import com.project.goms.domain.outing.usecase.SendMessageUseCase | ||
| import com.project.goms.domain.studentCouncil.entity.repository.OutingStatusRepository | ||
| import com.project.goms.infrastructure.discord.usecase.dto.DiscordDto | ||
| import com.project.goms.infrastructure.feign.client.DiscordFeignClient | ||
| import mu.KotlinLogging | ||
|
|
@@ -13,17 +16,23 @@ private val log = KotlinLogging.logger {} | |
| @Component | ||
| class SendDiscordUseCase( | ||
| private val discordFeignClient: DiscordFeignClient, | ||
| private val lateRepository: LateRepository | ||
| ): SendMessageUseCase { | ||
| private val lateRepository: LateRepository, | ||
| private val outingStatusRepository: OutingStatusRepository | ||
| ) : SendMessageUseCase { | ||
|
|
||
| override fun sendMessage() { | ||
| var content = "" | ||
| var outingStatus: OutingStatus = OutingStatus.AVAILABLE | ||
| val lateOneWeekAgoCount = lateRepository.lateCountOntWeekAgo(LocalDate.now().minusWeeks(1)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ κ° μμ μ μμ±ν μ½λλ₯Ό 보면μ λλκ±΄λ° 7μ 40λΆμ μ§κ°μμ μ μ₯νλ μ€μΌμ₯΄λ¬μμ 3λͺ
μ΄μ, λ―Έλ§ μΌλ κ°κ° OutingStatus(Redis)μ OutingStatus(enum)μ μ μ₯νλ©΄ μ λ κ² μΏΌλ¦¬λ¬Έ(μ λ²μ£Όμ μΈμΆμκ° 3λͺ
μ΄μ κ²μ¦)μ λ 릴 νμκ° μκ³ |
||
|
|
||
| log.info { "one week ago late count is $lateOneWeekAgoCount" } | ||
|
|
||
| when (lateOneWeekAgoCount < 3) { | ||
| true -> { | ||
| if (lateOneWeekAgoCount > 2) outingStatus = OutingStatus.UNAVAILABLE | ||
| if (outingStatusRepository.count().toInt() != 0) outingStatus = OutingStatus.UNAVAILABLE | ||
|
|
||
| log.info { outingStatus } | ||
| when (outingStatus) { | ||
| OutingStatus.AVAILABLE -> { | ||
| content = "@everyone \n" | ||
| content += "\uD83D\uDCE2 μ€λμ μμμΌ μ λλ€. \uD83D\uDCE2 \n" | ||
| content += "> κΈμΌ μμμΈμΆμ λ₯Ό ν΅ν΄ μΈμΆμ ν νμλ€μ λ°λμ μ λ μ λ¨Ήκ³ 7μλΆν° μμ λ‘κ² μΈμΆ ν΄μ£Όμκ³ , \n" | ||
|
|
@@ -32,12 +41,16 @@ class SendDiscordUseCase( | |
| content += "> μΈμΆ μ κΌ μ΄λν μ°©μ© λΆνλ립λλ€!\n" | ||
| } | ||
|
|
||
| false -> { | ||
| OutingStatus.UNAVAILABLE -> { | ||
| content = "@everyone \n" | ||
| content += "\uD83D\uDCE2 μ€λμ μμμΌ μ λλ€. \uD83D\uDCE2 \n" | ||
| content += "> μ λ²μ£Ό μΈμΆμ μ§κ°μμ΄ ${lateOneWeekAgoCount}λͺ μ΄μ¬μ μΈμΆμ λ μ§ννμ§ μμ΅λλ€. \n" | ||
| content += "> μ€λ μΈμΆνλ€ κ±Έλ¦΄μ λ¬΄λ¨ μΈμΆμ λλ€. \n" | ||
| } | ||
|
|
||
| OutingStatus.PUBLIC_HOLIDAY -> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μμ μ²λ¦¬ λ°©μμ 보면 λ€ OUTING_AVAILABLE, OUTING_UNAVAILABLE μΌλλ§ μ²λ¦¬ νλλ° κ³΅ν΄μΌ(PUBLIC_HOLIDAY)μΌλλ μ΄λ»κ² ꡬλΆνκ³ μ²λ¦¬ ν κΉμ? |
||
| throw PublicHolidayException() | ||
| } | ||
| } | ||
|
|
||
| discordFeignClient.sendDiscord(DiscordDto(content = content)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.