Skip to content

Commit

Permalink
[IDLE-512] 센터 관리자 인증 요청 event 변경 및 NotificationInfo 인터페이스 패키지 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou committed Nov 12, 2024
1 parent b2cbfe7 commit 4e925f2
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swm.idle.application.applys.domain
package com.swm.idle.application.applys.event

import com.swm.idle.domain.applys.event.ApplyEvent
import org.springframework.context.ApplicationEventPublisher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.swm.idle.application.applys.facade

import com.swm.idle.application.applys.domain.CarerApplyEventPublisher
import com.swm.idle.application.applys.domain.CarerApplyService
import com.swm.idle.application.applys.event.CarerApplyEventPublisher
import com.swm.idle.application.applys.vo.CarerApplyNotificationInfo
import com.swm.idle.application.common.security.getUserAuthentication
import com.swm.idle.application.jobposting.domain.JobPostingService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.swm.idle.application.applys.vo

import com.swm.idle.domain.notification.enums.NotificationType
import com.swm.idle.domain.notification.jpa.NotificationInfo
import com.swm.idle.domain.notification.event.NotificationInfo
import java.util.*

data class CarerApplyNotificationInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class DeviceTokenService(
return deviceTokenJpaRepository.findAllByUserId(userId)
}

fun findByUserId(userId: UUID): DeviceToken? {
return deviceTokenJpaRepository.findByUserId(userId)
}

@Transactional
fun updateDeviceTokenUserId(
deviceToken: DeviceToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.swm.idle.application.notification.domain

import com.swm.idle.domain.common.dto.NotificationQueryDto
import com.swm.idle.domain.common.exception.PersistenceException
import com.swm.idle.domain.notification.event.NotificationInfo
import com.swm.idle.domain.notification.jpa.Notification
import com.swm.idle.domain.notification.jpa.NotificationInfo
import com.swm.idle.domain.notification.repository.jpa.NotificationJpaRepository
import com.swm.idle.domain.notification.repository.querydsl.NotificationQueryRepository
import org.springframework.data.repository.findByIdOrNull
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.swm.idle.application.user.center.service.event

import com.swm.idle.domain.user.center.event.CenterManagerVerificationRequestEvent
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Service

@Service
class CenterManagerVerificationRequestEventPublisher(
private val eventPublisher: ApplicationEventPublisher,
) {

fun publish(centerManagerVerificationRequestEvent: CenterManagerVerificationRequestEvent) {
eventPublisher.publishEvent(centerManagerVerificationRequestEvent)
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.swm.idle.domain.applys.event

import com.swm.idle.domain.notification.event.NotificationInfo
import com.swm.idle.domain.notification.jpa.DeviceToken
import com.swm.idle.domain.notification.jpa.NotificationInfo
import java.util.*

data class ApplyEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package com.swm.idle.domain.notification.enums

enum class NotificationType {
APPLICANT,
CENTER_AUTHENTICATION,
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.swm.idle.domain.notification.jpa
package com.swm.idle.domain.notification.event

import com.swm.idle.domain.notification.enums.NotificationType
import java.util.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,16 @@ class CenterManager(
return status == CenterManagerAccountStatus.NEW
}

fun isPending(): Boolean {
return status == CenterManagerAccountStatus.PENDING
}

fun updateStatusToApproved() {
this.status = CenterManagerAccountStatus.APPROVED
}

fun updateStatusToRejected() {
this.status = CenterManagerAccountStatus.REJECTED
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ enum class CenterManagerAccountStatus {
NEW,
PENDING,
APPROVED,
REJECTED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.swm.idle.domain.user.center.event

import com.swm.idle.domain.user.center.entity.jpa.CenterManager

data class CenterManagerVerifyEvent(
data class CenterManagerVerificationRequestEvent(
val centerManager: CenterManager,
) {

companion object {

fun CenterManager.createVerifyEvent(): CenterManagerVerifyEvent {
fun CenterManager.createVerifyEvent(): CenterManagerVerificationRequestEvent {
require(isNew()) { "인증 요청이 가능한 상태가 아닙니다." }

return CenterManagerVerifyEvent(this)
return CenterManagerVerificationRequestEvent(this)
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.swm.idle.infrastructure.client.discord.user.center.listener

import com.swm.idle.domain.user.center.event.CenterManagerVerifyEvent
import com.swm.idle.domain.user.center.event.CenterManagerVerificationRequestEvent
import com.swm.idle.infrastructure.client.discord.user.center.service.CenterManagerVerifyEventService
import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component

@Component
class CenterManagerEventListener(
class CenterManagerVerificationRequestEventListener(
private val centerManagerVerifyEventService: CenterManagerVerifyEventService,
) {

@EventListener
fun handleCenterManagerVerifyEvent(centerManagerVerifyEvent: CenterManagerVerifyEvent) {
centerManagerVerifyEventService.sendVerifyMessage(centerManagerVerifyEvent)
fun handleCenterManagerVerifyEvent(centerManagerVerificationRequestEvent: CenterManagerVerificationRequestEvent) {
centerManagerVerifyEventService.sendVerifyMessage(centerManagerVerificationRequestEvent)
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.swm.idle.infrastructure.client.discord.user.center.service

import com.swm.idle.domain.user.center.event.CenterManagerVerifyEvent
import com.swm.idle.domain.user.center.event.CenterManagerVerificationRequestEvent
import com.swm.idle.infrastructure.client.discord.common.event.EventType
import com.swm.idle.infrastructure.client.discord.common.properties.DiscordClientProperties
import com.swm.idle.infrastructure.client.discord.common.utils.DiscordMessageClient
Expand All @@ -17,13 +17,15 @@ class CenterManagerVerifyEventService(

private val logger = KotlinLogging.logger { }

fun sendVerifyMessage(centerManagerVerifyEvent: CenterManagerVerifyEvent) {
fun sendVerifyMessage(centerManagerVerificationRequestEvent: CenterManagerVerificationRequestEvent) {

if (this.discordClientProperties.events.getValue(EventType.CENTER_MANAGER_VERIFICATION).active) {
val discordUri =
URI(this.discordClientProperties.events.getValue(EventType.CENTER_MANAGER_VERIFICATION).url)
val message =
"[🌟새로운 센터 관리자 ${centerManagerVerifyEvent.centerManager.name} 님이 관리자 인증 요청을 보냈어요! 빠르게 확인해주세요 :)"
"[🌟새로운 센터 관리자 ${centerManagerVerificationRequestEvent.centerManager.name} 님이 관리자 인증 요청을 보냈어요! 빠르게 확인해주세요 :) \n" +
"사업자 등록번호 [${centerManagerVerificationRequestEvent.centerManager.centerBusinessRegistrationNumber}]\n " +
"연락처는 [${centerManagerVerificationRequestEvent.centerManager.phoneNumber} 이에요."

runCatching {
discordMessageClient.send(
Expand Down

0 comments on commit 4e925f2

Please sign in to comment.