package com.greenorange.promotion.model.enums;

import com.greenorange.promotion.annotation.BaseEnum;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 审核状态枚举
 */
@Getter
public enum ReviewStatusEnum implements BaseEnum {

    PENDING("待审核"),
    APPROVED("已通过"),
    REJECTED("已拒绝"),
    WITHDRAWN("已撤回");

    private final String value;

    ReviewStatusEnum(String value) {
        this.value = value;
    }

    /**
     * BaseEnum 要求的方法：返回枚举对应的校验值
     */
    @Override
    public String getValue() {
        return this.value;
    }

    /**
     * 获取所有枚举值列表
     */
    public static List<String> getValues() {
        return Arrays.stream(values())
                     .map(ReviewStatusEnum::getValue)
                     .collect(Collectors.toList());
    }

    /**
     * 根据值获取对应的枚举对象
     */
    public static ReviewStatusEnum getEnumByValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (ReviewStatusEnum status : ReviewStatusEnum.values()) {
            if (status.value.equals(value)) {
                return status;
            }
        }
        return null;
    }
}
