import httpRequest from '@/utils/axios'
import type { ExperimentCreateItem } from './types'

// 获取实验列表
export function getExperimentList(params?: { name?: string; page?: number; 'per-page'?: number }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/list', { params })
}

// 获取实验详情
export function getExperiment(params: { experiment_id: string; page?: number; 'per-page'?: number }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/view', { params })
}

// 创建实验
export function createExperiment(data: ExperimentCreateItem) {
  return httpRequest.post('/api/resource/v1/backend/experiment/create', data)
}

// 更新实验
export function updateExperiment(data: ExperimentCreateItem) {
  return httpRequest.post('/api/resource/v1/backend/experiment/update', data)
}

// 获取实验课程列表
export function getExperimentCourseList(params: { organ_id: string }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/courses', { params })
}
// 获取实验指导老师列表
export function getExperimentTeacherList(params: { organ_id: string }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/teachers', { params })
}
// 获取实验关联班级列表
export function getExperimentClassList(params: { experiment_id: string; page?: number; 'per-page'?: number }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/class-add', { params })
}
// 实验关联班级
export function experimentAddClass(data: { experiment_id: string; classes_id: string; type: 'add' | 'delete' }) {
  return httpRequest.post('/api/resource/v1/backend/experiment/class-add', data)
}

// 获取班级学生列表
export function getClassStudentList(params: { class_id: string; page?: number; 'per-page'?: number }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/class-students', { params })
}

// 获取班级小组列表
export function getExperimentClassGroupsList(params: { experiment_id: string; class_id: string }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/class-teams', { params })
}

// 获取实验小组
export function getExperimentGroup(params: { team_id: string; page?: number; 'per-page'?: number }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/team-view', { params })
}

// 新增实验小组
export function experimentAddClassGroup(data: { experiment_id: string; class_id: string; name: string }) {
  return httpRequest.post('/api/resource/v1/backend/experiment/team-add', data)
}

// 实验小组添加学生
export function experimentGroupAddStudent(data: { team_id: string; students_id: string; type: 'add' | 'delete' }) {
  return httpRequest.post('/api/resource/v1/backend/experiment/team-add-student', data)
}

// 获取实验关联班级列表
export function getExperimentGroupStudentList(params: { team_id: string; page?: number; 'per-page'?: number }) {
  return httpRequest.get('/api/resource/v1/backend/experiment/team-add-student', { params })
}
