package com.yhy.module.core.enums.infoprice;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 信息价发布状态枚举
 *
 * @author yhy
 */
@Getter
@AllArgsConstructor
public enum InfoPricePublishStatusEnum implements ArrayValuable<Integer> {

    COMPLETED(1, "completed", "已完成"),
    UNCOMPLETED(2, "uncompleted", "未完成"),
    PUBLISHED(3, "published", "已发布"),
    UNPUBLISHED(4, "unpublished", "未发布");

    public static final Integer[] ARRAYS = Arrays.stream(values()).map(InfoPricePublishStatusEnum::getStatus).toArray(Integer[]::new);

    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 编码
     */
    private final String code;
    /**
     * 名称
     */
    private final String name;

    @Override
    public Integer[] array() {
        return ARRAYS;
    }

    public static InfoPricePublishStatusEnum valueOfStatus(Integer status) {
        return ArrayUtil.firstMatch(o -> o.getStatus().equals(status), values());
    }

    public static InfoPricePublishStatusEnum valueOfCode(String code) {
        return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
    }
}
