import { request } from '../request'

/** get user list */
export function fetchRankList(MainID: number, RoundType = 0) {
  return request<Api.Rank.CommonRecord>({
    url: `/Base/ActivityMain/GetTeamsTotal/list?MainID=${MainID}&RoundType=${RoundType}`,
    method: 'get',
  })
}

/** 获取队伍排名详情 */
export function fetchRankDetail(MainID: number, RoundType = 0) {
  return request<Api.Rank.CommonRecord>({
    url: `/Base/ActivityMain/GetTeamsTotal?MainID=${MainID}&RoundType=${RoundType}`,
    method: 'get',
  })
}

/** 根据队伍 id获取具体的题目分数 */
export function fetchTeamQuestionScore(TeamID: number) {
  return request<Api.Rank.CommonRecord>({
    url: `/Base/ActivityMain/GetTeamQuestionUseByTeamID?TeamID=${TeamID}`,
    method: 'get',
  })
}

/** 获取活动排行列表 */
export function fetchActivityRankList(PageIndex: number, PageSize: number = 10) {
  return request<App.Service.Response<Api.Rank.ActivityRankList>>({
    url: `/Base/ActivityMain/GetActivity_Main_TotalPager?PageIndex=${PageIndex}&PageSizes=${PageSize}`,
    method: 'get',
  })
}

/** 修改排名的队伍分数 */
export function updateTeamScore(data: Api.Rank.UpdateTeamScoreParams[], activityId: number) {
  return request<App.Service.Response>({
    url: `/Base/ActivityMain/UpdateTeamQuestionResultRecore/?ActivityID=${activityId}`,
    method: 'post',
    data,
  })
}

/** 发布排名,更新状态 */
export function publishRank(Id: number, Status = 1) {
  return request<App.Service.Response>({
    url: `/Base/ActivityMain/UpdateResultRecoreStatus`,
    method: 'post',
    data: {
      Id,
      Status,
    },
  })
}

/** 获取用户排名列表 */
export function fetchUserRankList(MainID: number, RoundType: number = 0) {
  return request<App.Service.Response<Api.Rank.ActivityRankResList>>({
    url: `/Base/ActivityMain/GetTeamsTotalList?MainID=${MainID}&RoundType=${RoundType}`,
    method: 'get',
  })
}
