Files
gaoYuJournal/miniprogram/api/TravelApi.ts
2025-12-17 16:16:10 +08:00

62 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Network } from "../utils/Network";
import { Travel } from "../types/Travel";
import { QueryPage, QueryPageResult } from "../types/Model";
/**
* Travel 出行计划 API
*
* 按业务模块封装网络请求,使代码更清晰、可维护
*/
export class TravelApi {
/**
* 获取出行详情
*
* @param id - 出行 ID
*/
static getDetail(id: number | string): Promise<Travel> {
return Network.get<Travel>(`/journal/travel/${id}`);
}
/**
* 出行分页列表
*
* @param pageParams - 分页参数
*/
static getList(pageParams: QueryPage): Promise<QueryPageResult<Travel>> {
return Network.page<Travel>("/journal/travel/list", pageParams);
}
/**
* 创建出行
*
* @param data - 出行数据
*/
static create(data: Partial<Travel>): Promise<Travel> {
return Network.post<Travel>("/journal/travel/create", data, {
showLoading: true,
loadingText: "正在保存.."
});
}
/**
* 更新出行
*
* @param data - 出行数据(必须包含 id
*/
static update(data: Partial<Travel> & { id: number }): Promise<Travel> {
return Network.post<Travel>("/journal/travel/update", data, {
showLoading: true,
loadingText: "正在保存.."
});
}
/**
* 删除出行
*
* @param id - 出行 ID
*/
static delete(id: number): Promise<void> {
return Network.post<void>("/journal/travel/delete", { id });
}
}