package kr.itn.itnhub.org; /** * 기관 담당자 및 채널 정보에서 파생되는 운영 상태. * 상태 판정과 채널 보유 여부가 항상 같은 공백 처리 규칙을 사용하도록 한곳에서 계산한다. */ public record OrgOperationalState(OrgStatus status, boolean hasChannel) { public static OrgOperationalState from(Long applicantContactId, String channelIdMj, String channelIdLaw) { boolean mjActive = filled(channelIdMj); boolean lawActive = filled(channelIdLaw); OrgStatus status; if (mjActive && lawActive) { status = OrgStatus.ACTIVE; } else if (mjActive || lawActive) { status = OrgStatus.PARTIAL; } else if (applicantContactId != null) { status = OrgStatus.READY; } else { status = OrgStatus.INFO_PENDING; } return new OrgOperationalState(status, mjActive || lawActive); } private static boolean filled(String value) { return value != null && !value.isBlank(); } }