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

71 lines
1.8 KiB
TypeScript
Raw Permalink 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 { TravelLocation } from "../types/Travel";
import { QueryPage, QueryPageResult } from "../types/Model";
/**
* TravelLocation 出行地点 API
*
* 按业务模块封装网络请求,使代码更清晰、可维护
*/
export class TravelLocationApi {
/**
* 获取出行地点详情
*
* @param id - 地点 ID
*/
static getDetail(id: number | string): Promise<TravelLocation> {
return Network.get<TravelLocation>(`/journal/travel/location/${id}`);
}
/**
* 获取出行地点分页列表
*
* @param pageParams - 分页参数(通常包含 travelId 筛选)
*/
static getList(pageParams: QueryPage): Promise<QueryPageResult<TravelLocation>> {
return Network.page<TravelLocation>("/journal/travel/location/list", pageParams);
}
/**
* 创建出行地点
*
* @param data - 地点数据
*/
static create(data: Partial<TravelLocation>): Promise<TravelLocation> {
return Network.post<TravelLocation>("/journal/travel/location/create", data, {
showLoading: true,
loadingText: "正在保存.."
});
}
/**
* 更新出行地点
*
* @param data - 地点数据(必须包含 id
*/
static update(data: Partial<TravelLocation> & { id: number }): Promise<TravelLocation> {
return Network.post<TravelLocation>("/journal/travel/location/update", data, {
showLoading: true,
loadingText: "正在保存.."
});
}
/**
* 删除出行地点
*
* @param id - 地点 ID
*/
static delete(id: number): Promise<void> {
return Network.post<void>("/journal/travel/location/delete", { id });
}
/**
* 批量获取出行地点
*
* @param ids - 地点 ID 数组
*/
static getListByIds(ids: number[]): Promise<TravelLocation[]> {
return Network.post<TravelLocation[]>("/journal/travel/location/list/ids", ids);
}
}