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

import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.utils.StringKit;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/***
* 厂商设备参数   飞鹅云打印
*
* @author zx
*
* @date 2021/12/30 9:01
*/
@Data
public class FePrinterParams extends DeviceParams {

    public ProviderParams providerParams;

    public DeviceParams deviceParams;

    public BizConfigParams bizConfigParams;

    public FePrinterParams(ProviderParams providerParams) {
        this.providerParams = providerParams;
    }

    public FePrinterParams(ProviderParams providerParams, DeviceParams deviceParams, BizConfigParams bizConfigParams) {
        this.providerParams = providerParams;
        this.deviceParams = deviceParams;
        this.bizConfigParams = bizConfigParams;
    }

    @Data
    public static class ProviderParams {
        /**
         * 飞鹅云后台帐号名USER
         */
        private String user;

        /**
         * 飞鹅云后台帐号UKEY
         */
        private String ukey;
    }

    @Data
    public static class DeviceParams {

        /**
         * 设备号
         */
        private String deviceNo;

        /**
         * 设备key
         */
        private String deviceKey;

        /**
         * 设备名称
         */
        private String deviceName;

    }

    @Data
    public static class BizConfigParams {

        /**
         * 打印联数
         */
        private Integer printNum;

        /**
         * 打印机模式
         */
        private Byte printMode;

    }

    @Override
    public String deSenData() {
        ProviderParams params = this.getProviderParams();
        if (params != null && StringUtils.isNotBlank(params.getUkey())) {
            params.setUkey(StringKit.autoDesensitization(params.getUkey()));
        }

        return JSONObject.toJSONString(params);
    }

}
