package cn.palmte.work.config.activiti;


import cn.palmte.work.exception.ResponseException;
import lombok.Getter;

/**
 * 审批人设置枚举
 */
@Getter
public enum ActCandidateTypeEnum {
    USER(0, "按用户设置审批人"),
    ROLE(1, "按角色设置审批人"),
    STARTER_LEADER(2, "按发起人部门领导设置审批人"),
    DEPT_LEADER(3, "按指定的部门领导设置审批人");


    private int type;
    private String name;

    ActCandidateTypeEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }

    public static ActCandidateTypeEnum ofType(int type) {
        if (type == USER.getType()) {
            return USER;
        } else if (type == ROLE.getType()) {
            return ROLE;
        } else if (type == STARTER_LEADER.getType()) {
            return STARTER_LEADER;
        } else if (type == DEPT_LEADER.getType()) {
            return DEPT_LEADER;
        } else {
            throw new ResponseException("不支持的类型【" + type + "】");
        }
    }
}
