package com.sckw.message.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @desc: 消息状态枚举
 * @author: yzc
 * @date: 2023-08-22 11:43
 */
@Getter
@AllArgsConstructor
public enum MsgStatusEnum {

    /**
     * 产品状态枚举
     */
    UN_READ(0, "未读"),
    READ(1, "已读");

    private final Integer code;
    private final String msg;


    public static String getNameByCode(Integer code) {
        MsgStatusEnum[] enums = MsgStatusEnum.values();
        for (MsgStatusEnum instance : enums) {
            if (Objects.equals(instance.getCode(), code)) {
                return instance.getMsg();
            }
        }
        return null;
    }

    public static List<MsgStatusEnum> getSortList() {
        MsgStatusEnum[] enums = MsgStatusEnum.values();
        return Arrays.stream(enums).sorted(Comparator.comparingInt(MsgStatusEnum::getCode)).collect(Collectors.toList());
    }
}
