28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { apiJson } from '@/lib/api/client';
|
|
import { API_V1 } from '@/lib/api/paths';
|
|
import type { SystemParam } from '@/lib/api/types/system-param';
|
|
|
|
const B = `${API_V1}/system/param`;
|
|
|
|
type ListEnvelope<T> = { items: T[]; total: number };
|
|
|
|
export const systemParam = {
|
|
create: (body: Partial<SystemParam>) =>
|
|
apiJson<SystemParam>(`${B}/create`, { method: 'POST', body: JSON.stringify(body) }),
|
|
update: (id: string, body: Partial<SystemParam>) =>
|
|
apiJson<SystemParam>(`${B}/update/${encodeURIComponent(id)}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(body),
|
|
}),
|
|
deleteBatch: (ids: string[]) =>
|
|
apiJson<void>(`${B}/delete-batch`, { method: 'DELETE', body: JSON.stringify(ids) }),
|
|
get: (query: Record<string, string>) => {
|
|
const q = new URLSearchParams(query).toString();
|
|
return apiJson<SystemParam>(`${B}/get?${q}`);
|
|
},
|
|
list: (query?: Record<string, string>) => {
|
|
const q = query ? new URLSearchParams(query).toString() : '';
|
|
return apiJson<ListEnvelope<SystemParam>>(q ? `${B}/list?${q}` : `${B}/list`);
|
|
},
|
|
};
|