package com.bocloud.cmp.entity.enums.jumpserver;

import java.util.Arrays;

/**
 * 对于字符会话, 1->active; 2->disconnected; 3->killed
 * 对于图形会话, 0->init; 1->prepared; 2->open/active；3->closing; 4->closed
 * 对于文件传输, 0->success; 1->fail
 */
public enum AuditStatus {
    UNKNOWN(999999, "未知"),
    // gui图形会话 1010开头
    INIT(101000, "初始化"),
    PREPARED(101001, "已就绪"),
    OPEN(101002, "开启/活动"),
    CLOSING(101003, "关闭中"),
    CLOSED(101004, "已关闭"),
    // tui字符会话 1011开头
    ACTIVE(101101, "活动"),
    DISCONNECTED(101102, "已断开"),
    KILLED(101103, "已停止"),
    // file 文件传输 1012开头
    SUCCESS(101200, "成功"),
    FAIL(101201, "失败");

    private final int value;
    private final String text; // 前端显示内容

    AuditStatus(int value, String text) {
        this.value = value;
        this.text = text;
    }

    public static AuditStatus byValue(int value) {
        return Arrays.stream(AuditStatus.values()).filter(o -> o.value == value).findFirst().orElse(AuditStatus.UNKNOWN);
    }

    public int getValue() {
        return value;
    }

    public String getText() {
        return text;
    }}
