2023-06-09 13:31:25 +08:00
|
|
|
import { api } from 'src/boot/axios';
|
|
|
|
import { PageDto, PageQueryDto } from './ApiCommon';
|
|
|
|
|
|
|
|
const UriBase = '/api/lineInfo';
|
|
|
|
|
2023-06-09 16:36:49 +08:00
|
|
|
export interface createParams {
|
2023-06-09 13:31:25 +08:00
|
|
|
name: string;
|
|
|
|
lineId: number;
|
2023-06-09 16:36:49 +08:00
|
|
|
config?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Item extends createParams {
|
|
|
|
id: number;
|
2023-06-09 13:31:25 +08:00
|
|
|
createdAt: string;
|
|
|
|
updateAt: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class PagingQueryParams extends PageQueryDto {
|
|
|
|
name?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页查询
|
|
|
|
* @param params
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
export async function pageQuery(
|
|
|
|
params: PagingQueryParams
|
|
|
|
): Promise<PageDto<Item>> {
|
|
|
|
const response = await api.get(`${UriBase}/paging`, {
|
|
|
|
params: params,
|
|
|
|
});
|
|
|
|
return response.data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 创建线路
|
|
|
|
* @param params
|
|
|
|
* @returns
|
|
|
|
*/
|
2023-06-09 16:36:49 +08:00
|
|
|
export function createLine(data: createParams) {
|
2023-06-09 13:31:25 +08:00
|
|
|
return api.post(`${UriBase}`, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除线路
|
|
|
|
* @param id 线路id
|
|
|
|
*/
|
|
|
|
export function deleteLine(id: number) {
|
|
|
|
return api.delete(`${UriBase}/${id}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 保存线路数据
|
|
|
|
* @param id 草稿id
|
|
|
|
*/
|
2023-06-09 16:36:49 +08:00
|
|
|
export function saveLineData(id: number, data: createParams) {
|
2023-06-09 13:31:25 +08:00
|
|
|
return api.put(`${UriBase}/${id}`, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取线路数据详情
|
|
|
|
* @param params
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
export async function getLineInfo(id: number): Promise<Item> {
|
|
|
|
const response = await api.get(`${UriBase}/${id}`);
|
|
|
|
return response.data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取线路信息列表
|
|
|
|
* @param params
|
|
|
|
* @returns
|
|
|
|
*/
|
2023-06-09 15:15:27 +08:00
|
|
|
export async function getLineList(): Promise<Array<Item>> {
|
2023-06-09 13:31:25 +08:00
|
|
|
const response = await api.get(`${UriBase}/list`);
|
|
|
|
return response.data;
|
|
|
|
}
|