package cn.axzo.msg.center.service.enums;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;

/**
 * @author yanglin
 */
@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public enum CardBizState implements CodeDefinition<String> {

    PENDING("待处理", true, ""),
    AGREED("已同意", true, "https://static.axzo.cn/fe-static/uni-icon/public/seal-4%23_%241699341908374.png"),
    REJECTED("已拒绝", true, "https://static.axzo.cn/fe-static/uni-icon/public/seal-2%23_%241699341908381.png"),
    REVOKED("已撤销", true, "https://static.axzo.cn/fe-static/uni-icon/native/%E5%8E%9F%E7%A8%BF%23_%241711338477975.png"),
    ABORTED("已中止", true, "https://axzo-public.oss-cn-chengdu.aliyuncs.com/%E5%8D%B0%E7%AB%A0-%E8%AF%A6%E6%83%85end.png"),
    COMPLETED("已处理", true, "https://static.axzo.cn/fe-static/uni-icon/public/seal-1%23_%241699341908382.png"),
    END("已完结", true, ""),
    IN_PROGRESS("进行中", false, null)

    ;

    private final String description;
    private final boolean imageConfigurable;
    private final String defaultImageUrl;


    private static Map<String, CardBizState> codeMap = Arrays.stream(values()).collect(Collectors.toMap(CardBizState::name, Function.identity()));

    @Override
    public String getCode() {
        return name();
    }

    public static List<CardBizState> imageConfigurableStates() {
        return Arrays.stream(values())
                .filter(CardBizState::isImageConfigurable)
                .collect(toList());
    }

    /**
     * 通过code获取枚举
     */
    public static CardBizState getByCode(String code) {
        return codeMap.get(code);
    }

}