package com.yuchen.saas.park.service.iot;

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 NetParkProductEnum {

    ELEVATOR_MONITOR("ZdeLdKGCsgNcM6Pw", "elevatorMonitor","梯控"),
    ACCESS_CONTROL("ARZueO1QNfnv5lEe", "accessControl","通用门禁"),
    //PARKING_GATE("lGEo5Xi5mDniPVHC", "parkingGate","停车道闸"),
    ELECTRONIC_FENCE("LZ53DDaeYnOrwb5f", "electronicFence","电子围栏"),

    ;

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

    /**
     * 枚举转换
     * @param key
     * @return
     */
    public static NetParkProductEnum convert(String key) {
        NetParkProductEnum[] allEnums = NetParkProductEnum.values();
        for (NetParkProductEnum 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<>();
        NetParkProductEnum[] allEnums = NetParkProductEnum.values();
        for (NetParkProductEnum 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;
//            }
//        }
//
//    }

}
