import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PackageForm, PackageQuery, PackageVO } from './types';

// 查询课包列表
export function listPackage(query: PackageQuery): AxiosPromise<PackageVO[]> {
  return request({
    url: '/edu/package/list',
    method: 'get',
    params: query
  });
}

// 查询课包详细(含价格策略)
export function getPackage(id: number | string): AxiosPromise<PackageVO> {
  return request({
    url: '/edu/package/' + id,
    method: 'get'
  });
}

// 新增课包
export function addPackage(data: PackageForm) {
  return request({
    url: '/edu/package',
    method: 'post',
    data: data
  });
}

// 修改课包
export function updatePackage(data: PackageForm) {
  return request({
    url: '/edu/package',
    method: 'put',
    data: data
  });
}

// 删除课包
export function delPackage(id: string | number | (string | number)[]) {
  return request({
    url: '/edu/package/' + id,
    method: 'delete'
  });
}

// 课包上架/下架
export function changePackageStatus(id: number | string, status: string) {
  return request({
    url: '/edu/package/changeStatus',
    method: 'put',
    data: { id, status }
  });
}
