package com.sckw.usual.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: lt
 * @date: 2024/4/3 9:43
 */
@AllArgsConstructor
@Getter
public enum WayBillTypeEnum {
    ONE(1, "陆运"),   //装货
    TWO(2, "轿运");   //卸货

    private final Integer code;
    private final String msg;


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

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