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 14:20
 */
@AllArgsConstructor
@Getter
public enum PerBillingCycleEnum {
    WEEK(1, "周结"),
    MONTH(2, "月结"),
    SEASON(3,"季结");

    private final Integer code;
    private final String msg;


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

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