import { AddReq,EditReq, DelReq,UserPageQuery } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';

export const apiPrefix = '/api/system/articles/';
export function GetList(query: UserPageQuery) {
	return request({
		url: "/api/system/device-manuals/",
		method: 'get',
		params: query,
	});
}
// export function GetObj(id: InfoReq) {
// 	return request({
// 		url: apiPrefix + id,
// 		method: 'get',
// 	});
// }

export function AddObj(obj: AddReq) {
	return request({
		url: apiPrefix+"add-device-manual/",
		method: 'post',
		data: obj,
	});
}

export function UpdateObj(obj: EditReq) {
	return request({
		// url: apiPrefix+"device-manuals/"+ obj.article + '/',
		url: "/api/system/device-manuals/"+ obj.id + '/',
		method: 'put',
		data: obj,
	});
}

export function DeleteAttachment(id: number) {
	return request({
		url: '/api/system/device-manuals/' + id + '/delete_attachment/',
		method: 'delete',
		data: { id },
	});
}

export function DelObj(id: DelReq) {
	return request({
		url: '/api/system/device-manuals/' + id + '/',
		method: 'delete',
		data: { id },
	});
}

export function GetPermission() {
    return request({
        url: apiPrefix,
        method: 'get',
    });
}

// PDF文件上传功能
export function uploadPdfFile(formData: FormData) {
	return request({
		url: '/api/system/device/upload-image/',
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data',
		},
		timeout: 600000
	});
}