forked from b2894lxlx/tuanwei-admin
89 lines
2.4 KiB
TypeScript
89 lines
2.4 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { FileRecord } from '@/api/system/file/model';
|
|
import type {
|
|
TzbcyMaterial,
|
|
TzbcyMaterialAuditParam,
|
|
TzbcyMaterialParam
|
|
} from './model';
|
|
|
|
export async function pageTzbcyMaterial(params: TzbcyMaterialParam) {
|
|
const res = await request.get<ApiResult<PageResult<TzbcyMaterial>>>(
|
|
'/gxmu/tzbcy-material/page',
|
|
{
|
|
params: { ...params, backendAccess: true }
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
export async function listTzbcyMaterial(params?: TzbcyMaterialParam) {
|
|
const res = await request.get<ApiResult<TzbcyMaterial[]>>(
|
|
'/gxmu/tzbcy-material',
|
|
{
|
|
params: { ...params, backendAccess: true }
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
export async function addTzbcyMaterial(data: TzbcyMaterial) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
'/gxmu/tzbcy-material',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
export async function updateTzbcyMaterial(data: TzbcyMaterial) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/gxmu/tzbcy-material',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
export async function auditTzbcyMaterial(data: TzbcyMaterialAuditParam) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/gxmu/tzbcy-material/audit',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
export async function removeTzbcyMaterial(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/gxmu/tzbcy-material/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
export async function exportTzbcyMaterial(params?: TzbcyMaterialParam) {
|
|
const res = await request.post<ApiResult<FileRecord>>(
|
|
'/gxmu/tzbcy-material/export',
|
|
{ ...params, backendAccess: true }
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|