package com.jeequan.jeepay.core.model.device;

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.constants.CS;

/**
 * 抽象类 设备参数定义
 *
 * @author zx
 *
 * @date 2021/6/8 16:33
 */
public abstract class DeviceParams {

    public final static byte MODE_PRINT = 1; // 仅打印
    public final static byte MODE_SPEAK = 2; // 仅播报
    public final static byte MODE_PRINT_AND_SPEAK = 3; // 打印并播报

    public static DeviceParams factory(String provider, String providerParamStr){

        if(CS.DEVICE_PROVIDER.BSJ.equals(provider)){
            BsjParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, BsjParams.ProviderParams.class);
            return new BsjParams(providerParams);
        }else if(CS.DEVICE_PROVIDER.PS.equals(provider)){
            PsSpeakerParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, PsSpeakerParams.ProviderParams.class);
            return new PsSpeakerParams(providerParams);
        }else if(CS.DEVICE_PROVIDER.ZGWL.equals(provider)){
            ZgwlParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, ZgwlParams.ProviderParams.class);
            return new ZgwlParams(providerParams);
        }else if(CS.DEVICE_PROVIDER.FE.equals(provider)){
            FePrinterParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, FePrinterParams.ProviderParams.class);
            return new FePrinterParams(providerParams);
        }else if(CS.DEVICE_PROVIDER.ZW.equals(provider)){
            ZwParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, ZwParams.ProviderParams.class);
            return new ZwParams(providerParams);
        }else if(CS.DEVICE_PROVIDER.JSD.equals(provider)){
            JsdParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, JsdParams.ProviderParams.class);
            return new JsdParams(providerParams);
        }else if(CS.DEVICE_PROVIDER.LLZN.equals(provider)){
            LlznParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, LlznParams.ProviderParams.class);
            return new LlznParams(providerParams);
        } else if (CS.DEVICE_PROVIDER.YLY.equals(provider)) {
            YlyParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, YlyParams.ProviderParams.class);
            return new YlyParams(providerParams);
        }else if (CS.DEVICE_PROVIDER.LKLS.equals(provider)) {
            LklsParams.ProviderParams providerParams = JSONObject.parseObject(providerParamStr, LklsParams.ProviderParams.class);
            return new LklsParams(providerParams);
        }
        return null;
    }

    /**
     *  敏感数据脱敏
    */
    public abstract String deSenData();

}
