package cn.axzo.msg.center.service.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @description
 *
 * @author cold_blade
 * @date 2023/9/20
 * @version 1.0
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum PendingMessageStateEnum implements CodeDefinition<String> {

    CREATED(0, "创建"),
    UNSENT(1, "未发送"),
    HAS_BEEN_SENT(2, "代办"),
    COMPLETED(5, "已办"),
    RETRACT(6, "已撤回"),
    DELETED(7, "已删除"),
    READ(8, "已读"),
    PROCESSING(9, "处理中")
    ;

    private final Integer deprecatedCode;
    private final String message;

    public static PendingMessageStateEnum codeOf(Integer code) {
        return Arrays.stream(values())
                .filter(e -> Objects.equals(e.deprecatedCode, code))
                .findFirst()
                .orElse(HAS_BEEN_SENT);
    }

    @Override
    public String getCode() {
        return name();
    }
}
