import { http } from '../http'
import { get, post } from '../request'
// import { getCache } from '@/utils';

const config = {
  baseURL: '/api/main',
}

const homeWorkApi = {
  /**
   * @description: 查询作业的学科列表
   * @param {*} params：
   * @return {*}
   */
  getSubjectList: (params: object) =>
    http.request({
      url: '/sc/job/getSubjectList',
      params,
      ...config,
    }),

  /**
   * @description: 查询作业列表
   * @param {*} params：
   * @return {*}
   */
  getJobList: async (params: object) => await get<any>('/sc/job/list', params),

  // /**
  //  * @description: 客户端学生作业
  //  * @param {*} params：
  //  * @return {*}
  //  */
  // getJobTittle: async (params: object) =>
  //   (
  //     await http.request({
  //       url: '/sc/job/getJobTittle',
  //       params,
  //       ...config,
  //     })
  //   ).data,

  /**
   * @description: 客户端学生作业详情新
   * @param {*} data
   * @return {*}
   */
  getPaperRecordDetail: async (data: object) =>
    (
      await http.request({
        url: '/school/paper/getPaperRecordDetail',
        data,
        method: 'POST',
        ...config,
      })
    ).data,

  /**
   * @description: 提交当前题目id
   * @param {*} params
   * @return {*}
   */
  submitCurrentTitleId: (data: anyObj) =>
    http.request({
      url: `/sc/jobStu/submitCurrentTitleId?jobStuId=${data.jobStuId}&currentTitleId=${data.currentTitleId}&costTime=${data.costTime}`,
      method: 'POST',
      ...config,
    }),

  /**
   * @description: 提交作业答案-学生试题
   * @param {*} params：
   * @return {*}
   */
  submitAnswer: (data: anyObj) =>
    http.request({
      url: '/sc/jobStuTitle/submitAnswer',
      method: 'POST',
      data,
      ...config,
    }),

  /**
   * @description: 提交作业
   * @param {*} params：
   * @return {*}
   */
  submitPaper: async (data: anyObj) =>
    await http.request({
      url: '/sc/jobStu/submit',
      method: 'POST',
      data,
      ...config,
    }),

  /**
   * @description: 查询整体分析的学科列表
   * @param {*} params：
   * @return {*}
   */
  getAnalyseSubjectList: (params: object) =>
    http.request({
      url: '/sc/job/statisticalSubject',
      params,
      ...config,
    }),

  /**
   * @description: 获取作业的整体分析
   * @param {*} id：
   * @return {*}
   */
  getJobAnalyse: ({ id, stuId }: anyObj) =>
    http.request({
      url: `/sc/job/getJobAnalyse/${id}?stuId=${stuId}`,
      ...config,
    }),

  /**
   * @description: 新获取作业的整体分析
   * @param {*} id：
   * @return {*}
   */
  getJobAnalyseNew: (params: anyObj) =>
    http.request({
      url: `/sc/job/getJobAnalyse`,
      ...config,
      params,
    }),

  // /**
  //  * @description: 获取作业的知识点分析
  //  * @param {*} id：
  //  * @return {*}
  //  */
  // getKnowledgeAnalyse: ({ id, stuId }: anyObj) =>
  //   http.request({
  //     url: `/sc/jobStu/knowledgeAnalyse?jobId=${id}&stuId=${stuId}`,
  //     ...config,
  //   }),
  /**
   * @description: 新获取作业的知识点分析
   * @param {*} id：
   * @return {*}
   */
  getKnowledgeAnalyse: ({ recordId }: anyObj) =>
    http.request({
      url: `/sc/job/statisticalKnowledge?recordId=${recordId}`,
      ...config,
    }),

  /**
   * @description: 获取作业题目的知识点分析
   * @param {*} id：
   * @return {*}
   */
  getJobStatistics: (params: anyObj) =>
    http.request({
      url: '/sc/jobStu/title/statistics',
      ...config,
      params,
    }),

  /**
   * @description: 获取学科列表
   */
  getSubjectAll: () =>
    http.request({
      url: '/sc/subject/getList',
      ...config,
    }),

  /**
   * @description: 获取错题本
   */
  getWrongList: (params: anyObj) =>
    http.request({
      url: '/sc/userErrorEdition/list',
      params,
      ...config,
    }),

  /**
   * @description: 获取错题本数量
   */
  getWrongNum: (params: anyObj) =>
    http.request({
      url: '/sc/userErrorEdition/getNum',
      params,
      ...config,
    }),

  /**
   * @description: 举一反三
   */
  homeWorkInferences: (params: anyObj) =>
    http.request({
      url: '/sc/userDrawInferences/generated',
      params,
      ...config,
      timeout: 28000,
    }),

  /**
   * @description: 举一反三提交
   */
  submitHomeWorkInferences: async (data: anyObj) => {
    return await post('/sc/userDrawInferences/summit', data, { ...config, timeout: 28000 })
  },

  /**
   * @description: 主观题订正错题
   */
  errorEdition: (id: any) =>
    http.request({
      url: '/sc/userErrorEdition/correct/' + id,
      method: 'POST',
      ...config,
    }),

  /**
   * @description: 客观题订正错题
   */
  errorEditionObjective: (params: anyObj) =>
    http.request({
      url: '/sc/userErrorEdition/generated',
      params,
      ...config,
      timeout: 28000,
    }),

  /**
   * @description: 客观题订正错题提交
   */
  submitErrorEditionObjective: async (data: anyObj) => {
    return await post('/sc/userErrorEdition/summit', data, {
      ...config,
      timeout: 28000,
    })
  },

  /**
   * @description: 获取统计分析
   */
  getStatisticalAnalysis: (params: anyObj) =>
    http.request({
      url: '/sc/job/statisticalAnalysis',
      params,
      ...config,
    }),

  /**
   * @description: 获取各个学科统计分析
   */
  getStatisticalSubject: (params: anyObj) =>
    http.request({
      url: '/sc/job/scoringAbility',
      params,
      ...config,
    }),

  /**
   * @description: 获取各个学科知识点分析
   */
  getKnowledgeSubject: (params: anyObj) =>
    http.request({
      url: '/sc/job/statisticalKnowledge',
      params,
      ...config,
    }),

  /**
   * @description: 学生新增临时作业答案
   */
  uploadTemporaryJob: (data: anyObj) =>
    http.request({
      url: '/sc/temporaryJob',
      method: 'POST',
      data,
      ...config,
    }),

  /**
   * @description: 临时作业列表
   */
  temporaryJobList: (params: anyObj) =>
    http.request({
      url: '/sc/temporaryJob/list',
      params,
      ...config,
    }),

  /**
   * @description: 临时作业详情
   */
  temporaryJobDetail: (id: any) =>
    http.request({
      url: `/sc/temporaryJob/${id}`,
      ...config,
    }),

  /**
   * @description: 获取学科列表
   */
  getTemporarySubjectList: () =>
    http.request({
      url: '/sc/subject/list',
      ...config,
    }),

  /**
   * @description: AI智能批改
   * @param {*} id 题目id
   * @return {*}
   */
  gradeQuestionTitleByAI: (id: string) =>
    http.request({
      url: `/school/paper/userRecord/gradeQuestionTitleByAI/${id}`,
      method: 'POST',
      ...config,
    }),
}

export default homeWorkApi
