107 lines
2.5 KiB
TypeScript
107 lines
2.5 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { Student, StudentParam } from './model';
|
|
import { MODULES_API_URL } from '@/config/setting';
|
|
|
|
/**
|
|
* 分页查询学生管理
|
|
*/
|
|
export async function pageStudent(params: StudentParam) {
|
|
const res = await request.get<ApiResult<PageResult<Student>>>(
|
|
MODULES_API_URL + '/booking/student/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询学生管理列表
|
|
*/
|
|
export async function listStudent(params?: StudentParam) {
|
|
const res = await request.get<ApiResult<Student[]>>(
|
|
MODULES_API_URL + '/booking/student',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加学生管理
|
|
*/
|
|
export async function addStudent(data: Student) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/booking/student',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改学生管理
|
|
*/
|
|
export async function updateStudent(data: Student) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/booking/student',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除学生管理
|
|
*/
|
|
export async function removeStudent(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/booking/student/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除学生管理
|
|
*/
|
|
export async function removeBatchStudent(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/booking/student/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据id查询学生管理
|
|
*/
|
|
export async function getStudent(id: number) {
|
|
const res = await request.get<ApiResult<Student>>(
|
|
MODULES_API_URL + '/booking/student/' + id
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|