Skip to content

Commit 1e3a8b9

Browse files
authored
release : invitees automation refactor (#418)
* add response field (memberId, cohortId) (#391) * initiation of new member and new announcement (#393) * appleOAuth name resolution (#395) * whitelist email -> memberId parameter changing (#398) * whitelist email login (parameter email -> memberId) (#399) * whitelist email -> memberId parameter changing * whitelist email -> memberId parameter changing * refactor/#397 (#400) * whitelist email -> memberId parameter changing * whitelist email -> memberId parameter changing * whitelist email -> memberId parameter changing * whitelist email -> memberId parameter changing (#402) * member_roles auto align (#405) * re-sync member_roles after whitelist (#407) * filtered member overview by cohort (#412) * filtered member overview by cohort * after_party_invitees 보상로직 * AFTERPARTY_COMPENSATIONRESPONSE * feat: member overview true/false of latest cohort (#414) * feat: member overview true/false of latest cohort * feat: member overview true/false of latest cohort * feat: invitees invitation iniation (#417)
1 parent 4d9aa99 commit 1e3a8b9

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

application/src/main/kotlin/core/application/afterParty/application/service/AfterPartyCommandService.kt

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package core.application.afterParty.application.service
22

33
import core.application.afterParty.application.exception.AfterPartyNotFoundException
44
import core.application.afterParty.application.exception.InviteTagNameNotFoundException
5+
import core.application.member.application.service.authority.MemberAuthorityService
56
import core.application.afterParty.presentation.response.AfterPartyInviteeCompensationResponse
67
import core.application.member.application.exception.MemberNotFoundException
78
import core.domain.afterParty.aggregate.AfterParty
@@ -14,14 +15,12 @@ import core.domain.afterParty.port.inbound.AfterPartyInviteeCommandUseCase
1415
import core.domain.afterParty.port.outbound.AfterPartyInviteePersistencePort
1516
import core.domain.afterParty.port.outbound.AfterPartyInviteTagPersistencePort
1617
import core.domain.afterParty.port.outbound.AfterPartyPersistencePort
17-
import core.domain.authorization.port.inbound.RoleQueryUseCase
1818
import core.domain.authorization.vo.RoleType
1919
import core.domain.cohort.port.outbound.CohortPersistencePort
2020
import core.domain.cohort.vo.CohortId
2121
import core.domain.member.aggregate.Member
2222
import core.domain.member.aggregate.MemberCohort
2323
import core.domain.member.port.inbound.MemberQueryUseCase
24-
import core.domain.member.port.outbound.query.MemberNameRoleQueryModel
2524
import core.domain.member.enums.MemberStatus
2625
import core.domain.member.vo.MemberId
2726
import org.springframework.stereotype.Service
@@ -38,7 +37,7 @@ class AfterPartyCommandService(
3837
val afterPartyInviteTagQueryUseCase: AfterPartyInviteTagQueryUseCase,
3938
val afterPartyInviteePersistencePort: AfterPartyInviteePersistencePort,
4039
val cohortPersistencePort: CohortPersistencePort,
41-
val roleQueryUseCase: RoleQueryUseCase,
40+
val memberAuthorityService: MemberAuthorityService,
4241
) : AfterPartyCommandUseCase {
4342
override fun createAfterParty(
4443
afterParty: AfterParty,
@@ -99,15 +98,9 @@ class AfterPartyCommandService(
9998
cohortId: CohortId,
10099
): Int {
101100
val now = Instant.now()
102-
val memberRoleIds =
103-
memberQueryUseCase
104-
.getMemberNameRoleByMemberId(memberId)
105-
.mapNotNull(MemberNameRoleQueryModel::role)
106-
.mapNotNull { roleName ->
107-
runCatching { roleQueryUseCase.findIdByName(roleName) }.getOrNull()
108-
}.toSet()
109-
110-
if (memberRoleIds.isEmpty()) {
101+
val memberAuthorityIds = memberAuthorityService.getActiveAuthorityIdsByMemberId(memberId).toSet()
102+
103+
if (memberAuthorityIds.isEmpty()) {
111104
return 0
112105
}
113106

@@ -123,7 +116,7 @@ class AfterPartyCommandService(
123116
val inviteTags = afterPartyInviteTagPersistencePort.findByAfterPartyId(afterPartyId)
124117
val shouldInvite =
125118
inviteTags.any { inviteTag ->
126-
inviteTag.cohortId == cohortId && inviteTag.authorityId in memberRoleIds
119+
inviteTag.cohortId == cohortId && inviteTag.authorityId in memberAuthorityIds
127120
}
128121

129122
if (!shouldInvite) {
@@ -272,10 +265,10 @@ class AfterPartyCommandService(
272265
}
273266

274267
val authorityId =
275-
try {
276-
roleQueryUseCase.findIdByName(roleType.code)
277-
} catch (ex: IllegalArgumentException) {
278-
throw InviteTagNameNotFoundException(tagName)
268+
when (roleType) {
269+
RoleType.Deeper -> DEEPER_AUTHORITY_ID
270+
RoleType.Organizer -> ORGANIZER_AUTHORITY_ID
271+
RoleType.Core, RoleType.Guest -> throw InviteTagNameNotFoundException(tagName)
279272
}
280273

281274
return InviteTagSpec(
@@ -306,4 +299,9 @@ class AfterPartyCommandService(
306299
val authorityId: Long,
307300
val tagName: String,
308301
)
302+
303+
companion object {
304+
private const val DEEPER_AUTHORITY_ID = 1L
305+
private const val ORGANIZER_AUTHORITY_ID = 2L
306+
}
309307
}

0 commit comments

Comments
 (0)