/**
 * 选手管理API接口
 */

import request from '@/utils/request.js'

export default {
  /**
   * 获取选手列表
   * @param {Object} params 查询参数 { current, size, competitionId, name }
   * @returns {Promise}
   */
  getAthleteList(params = {}) {
    return request.get('/martial/athlete/list', {
      current: params.current || 1,
      size: params.size || 100,
      ...params
    })
  },

  /**
   * 获取选手详情
   * @param {String|Number} id 选手ID
   * @returns {Promise}
   */
  getAthleteDetail(id) {
    return request.get('/martial/athlete/detail', { id })
  },

  /**
   * 新增或修改选手
   * @param {Object} data 选手数据
   * @returns {Promise}
   */
  submitAthlete(data) {
    return request.post('/martial/athlete/submit', data)
  },

  /**
   * 删除选手
   * @param {String|Array} ids 选手ID或ID数组
   * @returns {Promise}
   */
  removeAthlete(ids) {
    return request.post('/martial/athlete/remove', {
      ids: Array.isArray(ids) ? ids.join(',') : ids
    })
  }
}
