package org.dromara.zhishu.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.dromara.common.core.exception.ServiceException;

import java.util.ArrayList;
import java.util.List;

@Getter
@AllArgsConstructor
public enum IsJoinDistributionEnum {

    YES(1, "是"),

    NO(0, "否");

    /**
     * code
     */
    private final Integer code;

    /**
     * message
     */
    private final String msg;

    public static List<Integer> getIsJoinDistributionEnumList() {
        List<Integer> isJoinDistributionEnumList = new ArrayList<>();
        for (IsJoinDistributionEnum item : values()) {
            isJoinDistributionEnumList.add(item.getCode());
        }
        return isJoinDistributionEnumList;
    }

    public static IsJoinDistributionEnum valueOfCode(Integer code) {
        for (IsJoinDistributionEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new ServiceException("未知操作库存类型code: " + code);
    }

}
