package com.yuchen.saas.device.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.nest.springwrap.core.log.exception.ServiceException;

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

@Getter
@AllArgsConstructor
public enum NetProductEnum {

    RAIN_SENSOR("m2CyX1ygxWSbcivH", "rainSensor","雨量传感器"),
    WIND_SPEED_SENSOR("NbhjLj9ESs4Rsjgh", "windSpeedSensor","风速传感器"),
    WIND_DIRECTION_SENSOR("QrwddMUmmfycC1uU", "windDirectionSensor","风向传感器"),
    WEATHER_STATION("5RczFvFljRepi3zh", "weatherStation","气象站"),
    TEMPERATURE_HUMIDITY_SENSOR("rFnZHulB0Z9PRHV7", "temperatureHumiditySensor","室内温湿度传感器"),
    WATER_IMMERSION_SENSOR("uzOe6B5YF1YWDJ4D", "waterImmersionSensor","水浸传感器"),
    LIQUID_LEVEL_SENSOR("5vn3a7NtwJNed8CL", "liquidLevelSensor","液位传感器"),
    UNIVIEW_CAMERA("ssq9Uk4tKlSumHHB", "univiewCamera","宇视视像头"),

    ;

    /**
     * 产品key
     */
    private final String key;
    /**
     * 产品对应服务名前缀
     */
    private final String serviceNamePrefix;
    /**
     * 产品描述
     */
    private final String desc;

    /**
     * 枚举转换
     * @param key
     * @return
     */
    public static NetProductEnum convert(String key) {
        NetProductEnum[] allEnums = NetProductEnum.values();
        for (NetProductEnum enu : allEnums) {
            if (enu.key.equals(key)) {
                return enu;
            }
        }
        throw new ServiceException("NetProductEnum 非法枚举参数值 key="+key);
    }

    /**
     * 获取所有产品key
     * @return
     */
    public static List<String> productKeyList() {
        List<String> productKeyList = new ArrayList<>();
        NetProductEnum[] allEnums = NetProductEnum.values();
        for (NetProductEnum enu : allEnums) {
            productKeyList.add(enu.key);
        }
        return productKeyList;
    }


//    /**
//     * 根据账单类型获取对应服务
//     * @param productKey
//     * @return
//     */
//    public static String getPropertyBizService(String productKey) {
//        NetProductEnum[] allEnums = NetProductEnum.values();
//        for (NetProductEnum enu : allEnums) {
//            if (enu.serviceNamePrefix.equals(productKey)) {
//                return enu.serviceNamePrefix;
//            }
//        }
//
//    }

}
