package com.prolog.rdc.tms.rmi.hystrix;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.product.core.tools.util.LogUtils;
import com.prolog.rdc.tms.model.dto.print.PrinterBatchConfigInfoDTO;
import com.prolog.rdc.tms.model.dto.print.PrinterConfigInfoDTO;
import com.prolog.rdc.tms.model.dto.print.PrinterTemplateDTO;
import com.prolog.rdc.tms.model.vo.print.PrinterBatchConfigInfoVO;
import com.prolog.rdc.tms.model.vo.print.PrinterConfigInfoVO;
import com.prolog.rdc.tms.rmi.feign.PrintFeign;

import feign.hystrix.FallbackFactory;

/**
 * 
 *
 * 打印服务调用
 *
 * @className :PrintHystrix
 * @author :fanzw
 * @creationTime :2022/05/17
 * @description :
 *
 * @modifier :fanzw
 * @modifyTime :2022/05/17
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Component
public class PrintHystrix implements FallbackFactory<PrintFeign> {

	private final Logger logger = LoggerFactory.getLogger(PrintHystrix.class);

	@Override
	public PrintFeign create(Throwable cause) {
		if (null != cause && StringUtils.hasLength(cause.getMessage())) {
			LogUtils.error(logger, cause.getMessage(), cause);
		}

		return new PrintFeign() {
			@Override
			public RestMessage<PrinterTemplateDTO> detail(Long id) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-maindata-service|打印模板查询|detail】请求服务失败！", null);
			}

			@Override
			public RestMessage<PrinterConfigInfoDTO> queryPrinterInfo(PrinterConfigInfoVO var1) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-maindata-service|获取打印机和模版信息|queryPrinterInfo】请求服务失败！", null);
			}

			@Override
			public RestMessage<PrinterBatchConfigInfoDTO> queryBatchPrinterInfo(PrinterBatchConfigInfoVO var1) {
				return RestMessage.newInstance(false, "【upcloud-rdc-tms-maindata-service|批量获取打印机和模版信息|queryBatchPrinterInfo】请求服务失败！", null);
			}

		};
	}
}