import request from '@/axios';

// ==================== 场地管理接口 ====================

/**
 * 场地列表查询
 * @param {Number} current - 当前页
 * @param {Number} size - 每页条数
 * @param {Object} params - 查询参数
 * @param {Number} params.competitionId - 赛事ID
 */
export const getVenueList = (current, size, params) => {
  return request({
    url: '/api/martial/venue/list',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

/**
 * 获取场地详情
 * @param {Number} id - 场地ID
 */
export const getVenueDetail = (id) => {
  return request({
    url: '/api/martial/venue/detail',
    method: 'get',
    params: { id }
  })
}

/**
 * 新增或修改场地
 * @param {Object} data - 场地数据
 * @param {Number} data.competitionId - 赛事ID
 * @param {String} data.venueName - 场地名称
 * @param {Number} data.capacity - 容纳人数
 * @param {String} data.location - 位置
 * @param {String} data.description - 描述
 */
export const submitVenue = (data) => {
  return request({
    url: '/api/martial/venue/submit',
    method: 'post',
    data
  })
}

/**
 * 删除场地
 * @param {String} ids - 场地ID,多个用逗号分隔
 */
export const removeVenue = (ids) => {
  return request({
    url: '/api/martial/venue/remove',
    method: 'post',
    params: { ids }
  })
}

/**
 * 获取赛事的场地列表（不分页）
 * @param {Number} competitionId - 赛事ID
 */
export const getVenuesByCompetition = (competitionId) => {
  return request({
    url: '/api/martial/venue/list',
    method: 'get',
    params: {
      competitionId,
      current: 1,
      size: 1000
    }
  })
}
