package com.gree.mall.manager.enums;

import cn.hutool.core.util.EnumUtil;
import lombok.Getter;

import java.util.Map;

@Getter
public enum UMSDiscountCodeEnum {
    GDYJKT(1, "一级能效空调", "GDYJKT"),
    GDEJKT(2, "二级能效空调", "GDEJKT"),
    GDYJDS(3, "一级能效电视", "GDYJDS"),
    GENERAL(4, "二级能效电视", "GDEJDS"),
    GDEJDS(5, "一级能效冰箱", "GDYJBX"),
    GDEJBX(6, "二级能效冰箱", "GDEJBX"),
    GDYJXYJ(7, "一级能效洗衣机", "GDYJXYJ"),
    GDEJXYJ(8, "二级能效洗衣机", "GDEJXYJ"),
    GDYJXYYJ(9, "一级能效吸油烟机", "GDYJXYYJ"),
    GDEJXYYJ(10, "二级能效吸油烟机", "GDEJXYYJ"),
    GDYJDZ(11, "一级能效家用灶具", "GDYJDZ"),
    GDEJDZ(12, "二级能效家用灶具", "GDEJDZ"),
    GDYJRSQ(13, "一级能效热水器", "GDYJRSQ"),
    GDEJRSQ(14, "二级能效热水器", "GDEJRSQ"),
    GDYJDN(15, "一级能效电脑", "GDYJDN"),
    GDEJDN(16, "二级能效电脑", "GDEJDN"),
    ;

    UMSDiscountCodeEnum(Integer index, String name, String code) {
        this.index = index;
        this.name = name;
        this.code = code;
    }

    private Integer index;
    private String name;
    private String code;

    public static boolean existDiscountCodeByCode(String code) {
        return EnumUtil.getFieldValues(UMSDiscountCodeEnum.class, "code").contains(code);
    }

    public static String findNameByCode(String code) {
        final Map<String, Object> fieldMap = EnumUtil.getNameFieldMap(UMSDiscountCodeEnum.class, "name");

        return fieldMap.containsKey(code) ? fieldMap.get(code).toString() : "";
    }
}
