import request from '@/utils/request'

// 查询信贷客户家庭关系列表
export function listRelation(query) {
  return request({
    url: '/ccdi/custFmyRelation/list',
    method: 'get',
    params: query
  })
}

// 查询信贷客户家庭关系详细
export function getRelation(id) {
  return request({
    url: '/ccdi/custFmyRelation/' + id,
    method: 'get'
  })
}

// 新增信贷客户家庭关系
export function addRelation(data) {
  return request({
    url: '/ccdi/custFmyRelation',
    method: 'post',
    data: data
  })
}

// 修改信贷客户家庭关系
export function updateRelation(data) {
  return request({
    url: '/ccdi/custFmyRelation',
    method: 'put',
    data: data
  })
}

// 删除信贷客户家庭关系
export function delRelation(ids) {
  return request({
    url: '/ccdi/custFmyRelation/' + ids,
    method: 'delete'
  })
}

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

// 导入信贷客户家庭关系
export function importData(file, updateSupport) {
  const formData = new FormData()
  formData.append('file', file)
  formData.append('updateSupport', updateSupport)
  return request({
    url: '/ccdi/custFmyRelation/importData',
    method: 'post',
    data: formData
  })
}

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

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