diff --git a/src/main/java/page/clab/api/domain/memberManagement/executive/application/service/ExecutiveRetrievalService.java b/src/main/java/page/clab/api/domain/memberManagement/executive/application/service/ExecutiveRetrievalService.java index 4aae2ef4b..2a762d925 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/executive/application/service/ExecutiveRetrievalService.java +++ b/src/main/java/page/clab/api/domain/memberManagement/executive/application/service/ExecutiveRetrievalService.java @@ -4,6 +4,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -13,6 +14,7 @@ import page.clab.api.domain.memberManagement.executive.application.port.in.RetrieveExecutiveUseCase; import page.clab.api.domain.memberManagement.executive.application.port.out.RetrieveExecutivePort; import page.clab.api.domain.memberManagement.executive.domain.Executive; +import page.clab.api.domain.memberManagement.position.domain.PositionType; import page.clab.api.external.memberManagement.position.application.port.ExternalRetrievePositionUseCase; @Service @@ -22,11 +24,6 @@ public class ExecutiveRetrievalService implements RetrieveExecutiveUseCase { private final RetrieveExecutivePort retrieveExecutivePort; private final ExternalRetrievePositionUseCase externalRetrievePositionUseCase; private final ExecutiveDtoMapper mapper; - private static final Map PRIORITY = Map.of( - "PRESIDENT", 1, - "VICE_PRESIDENT", 2, - "OPERATION", 3 - ); @Transactional(readOnly = true) @Override @@ -44,11 +41,16 @@ private List sortExecutives(List executives, Map - PRIORITY.getOrDefault(positionMap.get(executive.getId()), Integer.MAX_VALUE)) + getPriority(positionMap.get(executive.getId()))) .thenComparing(Executive::getId)) .toList(); } + private int getPriority(String positionKey) { + return Optional.ofNullable(PositionType.getPriorityByKey(positionKey)) + .orElse(Integer.MAX_VALUE); + } + private Map getPositionMap(List executives) { return executives.stream() .collect(Collectors.toMap( diff --git a/src/main/java/page/clab/api/domain/memberManagement/position/domain/PositionType.java b/src/main/java/page/clab/api/domain/memberManagement/position/domain/PositionType.java index 674479ddf..46062f396 100644 --- a/src/main/java/page/clab/api/domain/memberManagement/position/domain/PositionType.java +++ b/src/main/java/page/clab/api/domain/memberManagement/position/domain/PositionType.java @@ -9,13 +9,23 @@ @AllArgsConstructor public enum PositionType { - PRESIDENT("PRESIDENT", "회장"), - VICE_PRESIDENT("VICE_PRESIDENT", "부회장"), - OPERATION("OPERATION", "운영진"), - CORE_TEAM("CORE_TEAM", "코어팀"), - MEMBER("MEMBER", "일반회원"); + PRESIDENT("PRESIDENT", "회장", 1), + VICE_PRESIDENT("VICE_PRESIDENT", "부회장", 2), + OPERATION("OPERATION", "운영진", 3), + CORE_TEAM("CORE_TEAM", "코어팀", null), + MEMBER("MEMBER", "일반회원", null); @Enumerated(EnumType.STRING) private final String key; private final String description; + private final Integer priority; + + public static Integer getPriorityByKey(String key) { + for (PositionType positionType : values()) { + if (positionType.getKey().equals(key)) { + return positionType.getPriority(); + } + } + throw new IllegalArgumentException("Invalid PositionType key: " + key); + } }