import request from '@/utils/request'

// 查询信贷客户实体关联列表
export function listRelation(query) {
  return request({
    url: '/ccdi/custEnterpriseRelation/list',
    method: 'get',
    params: query
  })
}

// 查询信贷客户实体关联详情
export function getRelation(id) {
  return request({
    url: '/ccdi/custEnterpriseRelation/' + id,
    method: 'get'
  })
}

// 新增信贷客户实体关联
export function addRelation(data) {
  return request({
    url: '/ccdi/custEnterpriseRelation',
    method: 'post',
    data: data
  })
}

// 修改信贷客户实体关联
export function updateRelation(data) {
  return request({
    url: '/ccdi/custEnterpriseRelation',
    method: 'put',
    data: data
  })
}

// 删除信贷客户实体关联
export function delRelation(ids) {
  return request({
    url: '/ccdi/custEnterpriseRelation/' + ids,
    method: 'delete'
  })
}

// 下载导入模板
export function importTemplate() {
  return request({
    url: '/ccdi/custEnterpriseRelation/importTemplate',
    method: 'post'
  })
}

// 导入信贷客户实体关联
export function importData(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/ccdi/custEnterpriseRelation/importData',
    method: 'post',
    data: formData
  })
}

// 查询导入状态
export function getImportStatus(taskId) {
  return request({
    url: '/ccdi/custEnterpriseRelation/importStatus/' + taskId,
    method: 'get'
  })
}

// 查询导入失败记录
export function getImportFailures(taskId, pageNum, pageSize) {
  return request({
    url: '/ccdi/custEnterpriseRelation/importFailures/' + taskId,
    method: 'get',
    params: { pageNum, pageSize }
  })
}
