import httpClient from '@/utils/http';

import {
  ControllerResponse,
  ServiceScoreCalculateRequest,
  ServiceScoreCalculateResponse,
  ServiceScoreCancelRequest,
  ServiceScoreCancelResponse,
  ServiceScorePublishRequest,
  ServiceScorePublishResponse
} from './data-contracts';
export default {
  /**
   * @description 从答题明细中聚合分数并回写到答题卡信息，设置状态为registered，并将明细由completed改为registered
   */
  calculateCreate: (body: ServiceScoreCalculateRequest) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ServiceScoreCalculateResponse;
      }
    >(`/score-publish/calculate`, { params: body });
  },
  /**
   * @description 取消已完成的统分操作，清理统计数据并重置状态
   */
  cancelCalculateCreate: (body: ServiceScoreCancelRequest) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ServiceScoreCancelResponse;
      }
    >(`/score-publish/cancel-calculate`, { params: body });
  },
  /**
   * @description 将考试科目标记为已发布
   */
  publishCreate: (body: ServiceScorePublishRequest) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ServiceScorePublishResponse;
      }
    >(`/score-publish/publish`, { params: body });
  }
};
