2025-02-08 11:52:25 +08:00
|
|
|
import { mainApi } from '../instances';
|
|
|
|
import { serverFetch } from '@/api/createServerInstance';
|
2025-03-11 04:39:18 +08:00
|
|
|
import type { GetMetricParams, ListMetricsParams, UpdateMetricParams } from './interfaces';
|
2025-03-11 03:58:50 +08:00
|
|
|
import type {
|
|
|
|
BusterMetric,
|
|
|
|
BusterMetricData,
|
|
|
|
BusterMetricListItem
|
|
|
|
} from '@/api/asset_interfaces/metric';
|
2025-02-08 11:52:25 +08:00
|
|
|
|
|
|
|
export const getMetric = async ({ id, password }: GetMetricParams) => {
|
|
|
|
return mainApi
|
|
|
|
.get<BusterMetric>(`/metrics/get`, {
|
|
|
|
params: { id, ...(password && { password }) }
|
|
|
|
})
|
|
|
|
.then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getMetric_server = async ({ id, password }: GetMetricParams) => {
|
|
|
|
return await serverFetch<BusterMetric>(`/metrics/get`, {
|
|
|
|
params: { id, ...(password && { password }) }
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const listMetrics = async (params: ListMetricsParams) => {
|
|
|
|
return mainApi.get<BusterMetricListItem[]>('/metrics/list', { params }).then((res) => res.data);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const listMetrics_server = async (params: ListMetricsParams) => {
|
|
|
|
return await serverFetch<BusterMetricListItem[]>('/metrics/list', { params });
|
|
|
|
};
|
2025-03-11 03:58:50 +08:00
|
|
|
|
2025-03-11 23:38:49 +08:00
|
|
|
export const getMetricData = async ({ id }: { id: string }) => {
|
2025-03-12 01:07:18 +08:00
|
|
|
return mainApi.get<BusterMetricData>(`/metrics/${id}/data`).then((res) => res.data);
|
2025-03-11 03:58:50 +08:00
|
|
|
};
|
2025-03-11 04:39:18 +08:00
|
|
|
|
|
|
|
export const updateMetric = async (params: UpdateMetricParams) => {
|
2025-03-11 23:38:49 +08:00
|
|
|
return mainApi
|
|
|
|
.put<BusterMetric>(`/metrics/update/${params.id}`, { params })
|
|
|
|
.then((res) => res.data);
|
2025-03-11 04:39:18 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const deleteMetrics = async (params: { ids: string[] }) => {
|
2025-03-11 23:38:49 +08:00
|
|
|
return mainApi.delete<null>(`/metrics/delete`, { params }).then((res) => res.data);
|
2025-03-11 04:39:18 +08:00
|
|
|
};
|
|
|
|
|
2025-03-11 23:38:49 +08:00
|
|
|
export const duplicateMetric = async (params: {
|
2025-03-11 04:39:18 +08:00
|
|
|
id: string;
|
|
|
|
message_id: string;
|
|
|
|
share_with_same_people: boolean;
|
|
|
|
}) => {
|
2025-03-11 23:38:49 +08:00
|
|
|
return mainApi.post<BusterMetric>(`/metrics/duplicate`, { params }).then((res) => res.data);
|
2025-03-11 04:39:18 +08:00
|
|
|
};
|