import request from '@/utils/request'

// 查询中介黑名单列表
export function listIntermediary(query) {
  return request({
    url: '/ccdi/intermediary/list',
    method: 'get',
    params: query
  })
}

// 查询个人中介详细
export function getPersonIntermediary(bizId) {
  return request({
    url: '/ccdi/intermediary/person/' + bizId,
    method: 'get'
  })
}

// 查询实体中介详细
export function getEntityIntermediary(socialCreditCode) {
  return request({
    url: '/ccdi/intermediary/entity/' + socialCreditCode,
    method: 'get'
  })
}

// 新增个人中介黑名单
export function addPersonIntermediary(data) {
  return request({
    url: '/ccdi/intermediary/person',
    method: 'post',
    data: data
  })
}

// 新增机构中介黑名单
export function addEntityIntermediary(data) {
  return request({
    url: '/ccdi/intermediary/entity',
    method: 'post',
    data: data
  })
}

// 修改个人中介黑名单
export function updatePersonIntermediary(data) {
  return request({
    url: '/ccdi/intermediary/person',
    method: 'put',
    data: data
  })
}

// 修改机构中介黑名单
export function updateEntityIntermediary(data) {
  return request({
    url: '/ccdi/intermediary/entity',
    method: 'put',
    data: data
  })
}

// 删除中介黑名单
export function delIntermediary(intermediaryIds) {
  return request({
    url: '/ccdi/intermediary/' + intermediaryIds,
    method: 'delete'
  })
}

// 查询中介亲属列表
export function listIntermediaryRelatives(bizId) {
  return request({
    url: '/ccdi/intermediary/' + bizId + '/relatives',
    method: 'get'
  })
}

// 查询中介亲属详情
export function getIntermediaryRelative(relativeBizId) {
  return request({
    url: '/ccdi/intermediary/relative/' + relativeBizId,
    method: 'get'
  })
}

// 新增中介亲属
export function addIntermediaryRelative(bizId, data) {
  return request({
    url: '/ccdi/intermediary/' + bizId + '/relative',
    method: 'post',
    data: data
  })
}

// 修改中介亲属
export function updateIntermediaryRelative(data) {
  return request({
    url: '/ccdi/intermediary/relative',
    method: 'put',
    data: data
  })
}

// 删除中介亲属
export function delIntermediaryRelative(relativeBizId) {
  return request({
    url: '/ccdi/intermediary/relative/' + relativeBizId,
    method: 'delete'
  })
}

// 查询中介关联机构列表
export function listIntermediaryEnterpriseRelations(bizId) {
  return request({
    url: '/ccdi/intermediary/' + bizId + '/enterprise-relations',
    method: 'get'
  })
}

// 查询中介关联机构详情
export function getIntermediaryEnterpriseRelation(id) {
  return request({
    url: '/ccdi/intermediary/enterprise-relation/' + id,
    method: 'get'
  })
}

// 新增中介关联机构
export function addIntermediaryEnterpriseRelation(bizId, data) {
  return request({
    url: '/ccdi/intermediary/' + bizId + '/enterprise-relation',
    method: 'post',
    data: data
  })
}

// 修改中介关联机构
export function updateIntermediaryEnterpriseRelation(data) {
  return request({
    url: '/ccdi/intermediary/enterprise-relation',
    method: 'put',
    data: data
  })
}

// 删除中介关联机构
export function delIntermediaryEnterpriseRelation(id) {
  return request({
    url: '/ccdi/intermediary/enterprise-relation/' + id,
    method: 'delete'
  })
}

// 下载导入模板（已废弃，保留以兼容旧代码）
export function importTemplate() {
  return request({
    url: '/ccdi/intermediary/importTemplate',
    method: 'post'
  })
}

// 导入中介黑名单
export function importData(data, updateSupport) {
  return request({
    url: '/ccdi/intermediary/importData?updateSupport=' + updateSupport,
    method: 'post',
    data: data
  })
}

// 下载个人中介导入模板
export function importPersonTemplate() {
  return request({
    url: '/ccdi/intermediary/importPersonTemplate',
    method: 'post'
  })
}

// 导入个人中介黑名单
export function importPersonData(data, updateSupport) {
  return request({
    url: '/ccdi/intermediary/importPersonData?updateSupport=' + updateSupport,
    method: 'post',
    data: data
  })
}

// 下载中介实体关联关系导入模板
export function importEnterpriseRelationTemplate() {
  return request({
    url: '/ccdi/intermediary/importEnterpriseRelationTemplate',
    method: 'post'
  })
}

// 查询个人中介导入状态
export function getPersonImportStatus(taskId) {
  return request({
    url: `/ccdi/intermediary/importPersonStatus/${taskId}`,
    method: 'get'
  })
}

// 查询个人中介导入失败记录
export function getPersonImportFailures(taskId, pageNum, pageSize) {
  return request({
    url: `/ccdi/intermediary/importPersonFailures/${taskId}`,
    method: 'get',
    params: { pageNum, pageSize }
  })
}

// 导入中介实体关联关系
export function importEnterpriseRelationData(data, updateSupport) {
  return request({
    url: '/ccdi/intermediary/importEnterpriseRelationData?updateSupport=' + updateSupport,
    method: 'post',
    data: data
  })
}

// 查询中介实体关联关系导入状态
export function getEnterpriseRelationImportStatus(taskId) {
  return request({
    url: `/ccdi/intermediary/importEnterpriseRelationStatus/${taskId}`,
    method: 'get'
  })
}

// 查询中介实体关联关系导入失败记录
export function getEnterpriseRelationImportFailures(taskId, pageNum, pageSize) {
  return request({
    url: `/ccdi/intermediary/importEnterpriseRelationFailures/${taskId}`,
    method: 'get',
    params: { pageNum, pageSize }
  })
}
