package com.qmth.sop.common.enums;

import java.util.Objects;

/**
 * @Description: 流程状态 enum
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/8/2
 */
public enum FlowStatusEnum {

    START("提交"),

    DRAFT("草稿"),

    AUDITING("审核中"),

    REJECT("已驳回"),

    CANCEL("已撤回"),

    END("已终止"),

    FINISH("已结束");

    private String title;

    private FlowStatusEnum(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    /**
     * 状态转换 toName
     *
     * @param title
     * @return
     */
    public static String convertToName(String title) {
        for (FlowStatusEnum e : FlowStatusEnum.values()) {
            if (Objects.equals(title, e.getTitle())) {
                return e.name();
            }
        }
        return null;
    }

    /**
     * 状态转换 toEnum
     *
     * @param name
     * @return
     */
    public static FlowStatusEnum convertToEnum(String name) {
        for (FlowStatusEnum e : FlowStatusEnum.values()) {
            if (Objects.equals(name, e.name())) {
                return e;
            }
        }
        return null;
    }
}
