package com.sckw.order.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-09-19 9:42
 */
@AllArgsConstructor
@Getter
public enum TransportDemandStatusEnum {

    /**
     * 运需状态枚举
     */
    SAVED(0, "已保存"),
    PUT_ON_SHELVES(1, "已上架"),
    TAKE_OFF_SHELVES(2, "已下架");

    private final Integer code;
    private final String msg;


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

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