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

@AllArgsConstructor
@Getter
public enum OrderSourceEnum {
    SELF_BUILD_NORMAL_LAND_ORDER(1, "物流自建-普货-陆运"),
    SELF_BUILD_CAR_LAND_ORDER(2, "物流自建-轿运-陆运"),
    PRODUCTION_TRANSPORTATION(3, "生产运输"),
    LOGISTICS_CONSIGN(4, "物流托运");

    private final Integer code;
    private final String msg;


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

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