import http from '@/utils/http'
import type * as T from '@/types/training.d'

const BASE_URL = '/training'

/** @desc 分页查询培训计划列表 */
export function pageTrainingPlan(query: T.TrainingPlanPageQuery) {
  return http.get<T.TrainingPlanResp[]>(`${BASE_URL}/plan/page`, query)
}

/** @desc 查询培训计划列表 */
export function listTrainingPlan(query?: T.TrainingPlanPageQuery) {
  return http.get<T.TrainingPlanResp[]>(`${BASE_URL}/plan/list`, query)
}

/** @desc 查询培训计划详情 */
export function getTrainingPlanDetail(planId: string) {
  return http.get<T.TrainingPlanResp>(`${BASE_URL}/plan/detail/${planId}`)
}

/** @desc 新增培训计划 */
export function createTrainingPlan(data: T.TrainingPlanReq) {
  return http.post(`${BASE_URL}/plan`, data)
}

/** @desc 更新培训计划 */
export function updateTrainingPlan(planId: string, data: T.TrainingPlanReq) {
  return http.put(`${BASE_URL}/plan/${planId}`, data)
}

/** @desc 删除培训计划 */
export function deleteTrainingPlan(planId: string) {
  return http.del(`${BASE_URL}/plan/${planId}`)
}

/** @desc 发布培训计划 */
export function publishTrainingPlan(planId: string) {
  return http.put(`${BASE_URL}/plan/${planId}/publish`)
}

/** @desc 取消培训计划 */
export function cancelTrainingPlan(planId: string) {
  return http.put(`${BASE_URL}/plan/${planId}/cancel`)
}
