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

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 专业内/项目负责人角色编码枚举。
 */
@Getter
@AllArgsConstructor
public enum OutputSplitRoleEnum {

    DIRECTOR("director", "专业负责人", 1, false),
    CHECK("check", "校对", 2, false),
    REVIEW("review", "审核", 3, false),
    APPROVE("approve", "审定", 4, false),
    DESIGN("design", "设计", 5, false),
    PROJECT_MANAGER("project_manager", "项目经理", 1, true),
    ENGINEERING_PRINCIPAL("engineering_principal", "工程负责人", 2, true);

    private final String code;
    private final String label;
    private final Integer sortNo;
    private final boolean projectLeadRole;

    public static OutputSplitRoleEnum 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) {
        OutputSplitRoleEnum item = of(code);
        return item == null ? code : item.getLabel();
    }

}
