import request from '@/axios';

// ==================== 评分管理接口 ====================

/**
 * 评分分页查询
 * @param {Number} current - 当前页,默认1
 * @param {Number} size - 每页条数,默认10
 * @param {Object} params - 查询参数
 * @param {Number} params.competitionId - 赛事ID
 * @param {Number} params.projectId - 项目ID
 * @param {Number} params.venueId - 场地ID
 * @param {Number} params.athleteId - 选手ID
 */
export const getScoreList = (current, size, params) => {
  return request({
    url: '/api/martial/score/list',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

/**
 * 获取评分详情
 * @param {Number} id - 评分主键ID
 */
export const getScoreDetail = (id) => {
  return request({
    url: '/api/martial/score/detail',
    method: 'get',
    params: { id }
  })
}

/**
 * 获取选手的所有裁判评分
 * @param {Number} athleteId - 选手ID
 * @param {Number} projectId - 项目ID
 */
export const getAthleteScores = (athleteId, projectId) => {
  return request({
    url: '/api/martial/score/list',
    method: 'get',
    params: {
      athleteId,
      projectId,
      current: 1,
      size: 1000
    }
  })
}

/**
 * 提交评分
 * @param {Object} data - 评分数据
 */
export const submitScore = (data) => {
  return request({
    url: '/api/martial/score/submit',
    method: 'post',
    data
  })
}

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

/**
 * 获取异常评分列表
 * @param {Number} athleteId - 选手ID
 * @param {Number} projectId - 项目ID
 */
export const getAnomalies = (athleteId, projectId) => {
  return request({
    url: '/api/martial/score/anomalies',
    method: 'get',
    params: { athleteId, projectId }
  })
}

/**
 * 验证评分
 * @param {Number} athleteId - 选手ID
 * @param {Number} projectId - 项目ID
 */
export const validateScores = (athleteId, projectId) => {
  return request({
    url: '/api/martial/score/validate',
    method: 'post',
    params: { athleteId, projectId }
  })
}
