import request from '@/utils/request'

// 查询羊舍管理列表
export function listSheepfold_management(query) {
  return request({
    url: '/sheepfold_management/sheepfold_management/list',
    method: 'get',
    params: query
  })
}

// 主表格：羊舍级别汇总查询
export function listSheepfoldSummary(query) {
  return request({
    url: '/sheepfold_management/sheepfold_management/summaryList',
    method: 'get',
    params: query
  })
}


// 查询羊舍管理详细
export function getSheepfold_management(id) {
  return request({
    url: '/sheepfold_management/sheepfold_management/' + id,
    method: 'get'
  })
}

// 新增羊舍管理
export function addSheepfold_management(data) {
  return request({
    url: '/sheepfold_management/sheepfold_management',
    method: 'post',
    data: data
  })
}

// 修改羊舍管理
export function updateSheepfold_management(data) {
  return request({
    url: '/sheepfold_management/sheepfold_management',
    method: 'put',
    data: data
  })
}

// 删除羊舍管理
export function delSheepfold_management(id) {
  return request({
    url: '/sheepfold_management/sheepfold_management/' + id,
    method: 'delete'
  })
}

// 检查羊舍编号是否已存在
export function checkSheepfoldNoExist(ranchId, sheepfoldTypeId, sheepfoldNo) {
  return request({
    url: '/sheepfold_management/sheepfold_management/checkSheepfoldNoExist',
    method: 'get',
    params: {
      ranchId: ranchId,
      sheepfoldTypeId: sheepfoldTypeId,
      sheepfoldNo: sheepfoldNo
    }
  })
}

// 获取树形座位图（牧场 → 类型 → 羊舍 → 排栏）
export function getSeatMap() {
  return request({
    url: '/sheepfold_management/sheepfold_management/seatMap',
    method: 'get'
  })
}


// 按组合条件删除（单条）：匹配Controller的/deleteByCondition
export function deleteSheepfoldByCondition(data) {
  return request({
    url: '/sheepfold_management/sheepfold_management/deleteByCondition',
    method: 'delete',
    data: data // 需包含ranchId/sheepfoldNo/sheepfoldTypeId/sheepfoldName（Controller校验了sheepfoldName）
  })
}

// 批量按组合条件删除：匹配Controller的/batchDeleteByCondition
export function batchDeleteSheepfoldByCondition(dataList) {
  return request({
    url: '/sheepfold_management/sheepfold_management/batchDeleteByCondition',
    method: 'delete',
    data: dataList
  })
}


// 导出羊舍管理汇总列表（主表格数据）- 新增
export function exportSheepfoldSummary(query) {
  return request({
    url: '/sheepfold_management/sheepfold_management/exportSummary',
    method: 'post',
    params: query,
    responseType: 'blob'
  })
}

// 导出羊舍管理明细列表（原有）- 保留
export function exportSheepfold(query) {
  return request({
    url: '/sheepfold_management/sheepfold_management/export',
    method: 'post',
    params: query,
    responseType: 'blob'
  })
}