package cn.superdesk.uniorder.dubbo.consumer.unified;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.common.InvoiceTaxRate;
import cn.superdesk.uniorder.dao.entity.invoice.common.InvoiceType;
import cn.superdesk.uniorder.dao.entity.organisation.SysEnterprise;
import cn.superdesk.uniorder.dao.entity.unified.UnifiedCustomer;
import cn.superdesk.uniorder.dto.vo.unified.UnifiedCustomerAdd;
import cn.superdesk.uniorder.dto.vo.unified.UnifiedCustomerDetail;
import cn.superdesk.uniorder.dto.vo.unified.UnifiedCustomerVo;
import cn.superdesk.uniorder.dubbo.facade.unified.DubboUnifiedCustomerService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;


@Slf4j
@Component
public class UnifiedCustomerDubboConsumerService {

	@Reference(version = "1.0.0", timeout = 30000, retries = -1)
	private DubboUnifiedCustomerService dubboUnifiedCustomerService;

	public UnifiedCustomer addObjTran(SysEnterprise virt, UnifiedCustomerAdd model, String token) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		return dubboUnifiedCustomerService.addObjTran(virt, model, loginSysUser);
	}

	public UnifiedCustomer updateObj(UnifiedCustomerAdd model, String token) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		return dubboUnifiedCustomerService.updateObjTran(model, loginSysUser);
	}

	public UnifiedCustomerDetail getDetail(Long virtId) {

		return dubboUnifiedCustomerService.getDetail(virtId);
	}

	public R<List<UnifiedCustomerVo>> getDataByPage(String token, Map<String, Object> params, int pageNum, int pageSize) {

		return dubboUnifiedCustomerService.getDataByPage(params, pageNum, pageSize);
	}

	public List<InvoiceTaxRate> getInvoiceTaxDataList(Map<String, Object> params) {

		return dubboUnifiedCustomerService.getInvoiceTaxDataList(params);
	}

	public List<InvoiceType> getInvoiceTypeList(Map<String, Object> params) {

		return dubboUnifiedCustomerService.getInvoiceTypeList(params);
	}

	public UnifiedCustomer findById(Long virtId) {

		return dubboUnifiedCustomerService.findById(virtId);
	}


}
