package cn.iocoder.lyzsys.module.tjt.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 合约规划归属类型枚举。
 */
@Getter
@AllArgsConstructor
public enum ProjectPlanningOwnershipTypeEnum {

    MAJOR("major", "专业所"),
    COMPREHENSIVE("comprehensive", "综合所"),
    SPECIAL_SUBCONTRACT_MAJOR("special_subcontract_major", "专项分包-专业所"),
    SPECIAL_SUBCONTRACT_SOURCE_COOP("special_subcontract_source_coop", "专项分包-源头合作分包"),
    SPECIAL_SUBCONTRACT_COMPREHENSIVE("special_subcontract_comprehensive", "专项分包-综合所");

    private final String code;
    private final String label;

    public static ProjectPlanningOwnershipTypeEnum of(String code) {
        return Arrays.stream(values())
                .filter(item -> item.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }

    public static boolean contains(String code) {
        return of(code) != null;
    }

    public static String labelOf(String code) {
        ProjectPlanningOwnershipTypeEnum item = of(code);
        return item == null ? code : item.getLabel();
    }

}
