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

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

export default {
  /**
   * 获取选手列表
   */
  getAthleteList(params = {}) {
    return request.get('/martial/athlete/list', {
      current: params.current || 1,
      size: params.size || 100,
      ...params
    })
  },

  /**
   * 获取选手详情
   */
  getAthleteDetail(id) {
    return request.get('/martial/athlete/detail', { id })
  },

  /**
   * 新增或修改选手
   */
  submitAthlete(data) {
    return request.post('/martial/athlete/submit', data)
  },

  /**
   * 删除选手
   */
  removeAthlete(ids) {
    return request.post('/martial/athlete/remove', {
      ids: Array.isArray(ids) ? ids.join(',') : ids
    })
  },

  // ========== 集体/团队相关 API ==========

  getTeamList(params = {}) {
    return request.get('/martial/team/list', {
      current: params.current || 1,
      size: params.size || 100,
      ...params
    })
  },

  getTeamDetail(id) {
    return request.get('/martial/team/detail', { id })
  },

  saveTeam(data) {
    return request.post('/martial/team/submit', data)
  },

  removeTeam(id) {
    return request.post('/martial/team/remove?id=' + id, {})
  },

  // ========== 联系人相关 API ==========

  getContactList(params = {}) {
    return request.get('/martial/contact/list', {
      current: params.current || 1,
      size: params.size || 100,
      ...params
    })
  },

  getContactDetail(id) {
    return request.get('/martial/contact/detail', { id })
  },

  saveContact(data) {
    return request.post('/martial/contact/submit', data)
  },

  removeContact(id) {
    return request.post('/martial/contact/remove?ids=' + id, {})
  },

  /**
   * 获取已报名选手列表（用于检查重复报名）
   */
  getRegisteredAthletes(params = {}) {
    return request.get('/martial/athlete/registered', params)
  }
}
