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

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.organisation.UnifiedSupplierCostConfig;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dto.param.organisation.UnifiedSupplierQueryCriteria;
import cn.superdesk.uniorder.dubbo.facade.organisation.DubboUnifiedSupplierCostConfigService;
import cn.superdesk.uniorder.common.security.JwtUtil;
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 UnifiedSupplierCostConfigDubboConsumerService {

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

	public R<List<UnifiedSupplierCostConfig>> getDataByPage(String token, UnifiedSupplierQueryCriteria criteria, int pageNum, int pageSize) {
		return dubboUnifiedSupplierCostConfigService.getDataByPage(criteria, pageNum, pageSize);
	}

	public Map<String, Object> addObj(String token, UnifiedSupplierCostConfig param) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		return dubboUnifiedSupplierCostConfigService.addObj(param, loginSysUser);
	}

	public Map<String, Object> updateObj(String token, UnifiedSupplierCostConfig param) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		return dubboUnifiedSupplierCostConfigService.updateObj(param, loginSysUser);
	}

	public void delObj(Long id) {
		dubboUnifiedSupplierCostConfigService.delObj(id);
	}

	public UnifiedSupplierCostConfig findBySaleId(Long saleId) {
		return dubboUnifiedSupplierCostConfigService.findBySaleId(saleId);
	}
}
