package com.hz.pm.api.meeting.entity.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * <p>
 * MeetingReviewTypeEnum
 * </p>
 *
 * @author WendyYang
 * @since 16:32 2023/3/15
 */
@Getter
@AllArgsConstructor
public enum MeetingReviewTypeEnum {

    /**
     * 会议评审类型
     */
    PRELIMINARY_SCHEME_REVIEW("初步方案评审", "1"),

    CONSTRUCTION_SCHEME_REVIEW("建设方案评审", "2"),

    ACCEPTANCE_SCHEME_REVIEW("验收方案评审", "3"),

    DEPT_JOIN_REVIEW("部门联审", "4"),

    FAIRNESS_REVIEW( "公平性审查","5");

    private final String value;
    private final String code;

    public boolean eq(String code) {
        return this.getCode().equals(code);
    }

    public static MeetingReviewTypeEnum getByCode(String code) {
        return Arrays.stream(values())
                .filter(w -> w.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("无效的会议评审类型编码"));
    }

    public static String getValue(String code) {
        return Arrays.stream(values())
                .filter(w -> w.getCode().equals(code))
                .map(MeetingReviewTypeEnum::getValue)
                .findFirst()
                .orElse("未知");
    }

}
