package com.sckw.mine.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;

/**
 * @author lt
 * @desc: 订单状态枚举
 */
@AllArgsConstructor
@Getter
public enum MineStatusEnum {
    ZERO(0, "已保存"),
    FIFTEEN(15, "已驳回"),
    TWENTY(20, "取消订单"),
    ;

    private final Integer code;
    private final String msg;


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

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