package com.ruoyi.project.business.enums;

import com.ruoyi.common.exception.ServiceException;
import java.util.Arrays;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum NodeRoleEnum {
    SALES1(111, "议价审批(销售)", 108L),
    SALES2(112, "议价审批(区总)", 105L),
    SALES3(113, "议价审批(总监)", 103L),
    SALES4(114, "议价审批(总经理)", 101L),
    ;

    private Integer nodeValue;

    private String name;

    private Long roleId;

    public static NodeRoleEnum fromAuditStatusEnum(AuditStatusEnum auditStatusEnum) {
        Optional<NodeRoleEnum> first = Arrays.stream(NodeRoleEnum.values())
            .filter(a -> a.getNodeValue().equals(auditStatusEnum.getValue())).findFirst();
        if (first.isPresent()) {
            return first.get();
        } else {
            throw new ServiceException();
        }
    }


}
