完整API模块结构:
client/admin/api/ ├── auth.ts (认证API) ├── users.ts (用户API) ├── files.ts (文件API) ├── theme.ts (主题API) ├── charts.ts (图表API) ├── messages.ts (消息API) ├── sys.ts (系统API) ├── know_info.ts (知识库API) ├── maps.ts (地图API) └── index.ts (统一入口)
This commit is contained in:
64
client/admin/api/maps.ts
Normal file
64
client/admin/api/maps.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import axios from 'axios';
|
||||
import type {
|
||||
LoginLocation, LoginLocationDetail,
|
||||
} from '../../share/types.ts';
|
||||
|
||||
const API_BASE_URL = '/api';
|
||||
|
||||
|
||||
// 地图相关API的接口类型定义
|
||||
export interface LoginLocationResponse {
|
||||
message: string;
|
||||
data: LoginLocation[];
|
||||
}
|
||||
|
||||
export interface LoginLocationDetailResponse {
|
||||
message: string;
|
||||
data: LoginLocationDetail;
|
||||
}
|
||||
|
||||
export interface LoginLocationUpdateResponse {
|
||||
message: string;
|
||||
data: LoginLocationDetail;
|
||||
}
|
||||
|
||||
// 地图相关API
|
||||
export const MapAPI = {
|
||||
// 获取地图标记点数据
|
||||
getMarkers: async (params?: {
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
userId?: number
|
||||
}): Promise<LoginLocationResponse> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/map/markers`, { params });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// 获取登录位置详情
|
||||
getLocationDetail: async (locationId: number): Promise<LoginLocationDetailResponse> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/map/location/${locationId}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
// 更新登录位置信息
|
||||
updateLocation: async (locationId: number, data: {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
location_name?: string;
|
||||
}): Promise<LoginLocationUpdateResponse> => {
|
||||
try {
|
||||
const response = await axios.put(`${API_BASE_URL}/map/location/${locationId}`, data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user