Files
ndm-web-platform/src/apis/request/system/def-parameter.ts
yangsy 495dc001a1 refactor: 优化请求封装
- 优化Result接口定义
- 新增响应数据解析逻辑
- 优化错误解析逻辑
2025-12-17 15:38:08 +08:00

24 lines
1.3 KiB
TypeScript

import { ndmClient, userClient, type DefParameterPageQuery, type DefParameterResultVO, type DefParameterUpdateVO, type PageParams, type PageResult, type Station } from '@/apis';
import type { Result } from '@/types';
import { unwrapResponse } from '@/utils';
export const pageDefParameterApi = async (pageQuery: PageParams<DefParameterPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/system/defParameter/page`;
const resp = await client.post<PageResult<DefParameterResultVO>>(endpoint, pageQuery, { signal });
const data = unwrapResponse(resp);
return data;
};
export const updateDefParameterApi = async (updateVO: DefParameterUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/system/defParameter`;
const resp = await client.put<Result<DefParameterResultVO>>(endpoint, updateVO, { signal });
const data = unwrapResponse(resp);
return data;
};