49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
|
|
import http from "./http";
|
||
|
|
import { SysDictType, SysDictItem } from "../types";
|
||
|
|
|
||
|
|
// Dictionary Type APIs
|
||
|
|
export async function fetchDictTypes() {
|
||
|
|
const resp = await http.get("/api/dict-types");
|
||
|
|
return resp.data.data as SysDictType[];
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function createDictType(data: Partial<SysDictType>) {
|
||
|
|
const resp = await http.post("/api/dict-types", data);
|
||
|
|
return resp.data.data as boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function updateDictType(id: number, data: Partial<SysDictType>) {
|
||
|
|
const resp = await http.put(`/api/dict-types/${id}`, data);
|
||
|
|
return resp.data.data as boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function deleteDictType(id: number) {
|
||
|
|
const resp = await http.delete(`/api/dict-types/${id}`);
|
||
|
|
return resp.data.data as boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Dictionary Item APIs
|
||
|
|
export async function fetchDictItems(typeCode?: string) {
|
||
|
|
const resp = await http.get("/api/dict-items", { params: { typeCode } });
|
||
|
|
return resp.data.data as SysDictItem[];
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function createDictItem(data: Partial<SysDictItem>) {
|
||
|
|
const resp = await http.post("/api/dict-items", data);
|
||
|
|
return resp.data.data as boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function updateDictItem(id: number, data: Partial<SysDictItem>) {
|
||
|
|
const resp = await http.put(`/api/dict-items/${id}`, data);
|
||
|
|
return resp.data.data as boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function deleteDictItem(id: number) {
|
||
|
|
const resp = await http.delete(`/api/dict-items/${id}`);
|
||
|
|
return resp.data.data as boolean;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function fetchDictItemsByTypeCode(typeCode: string) {
|
||
|
|
const resp = await http.get(`/api/dict-items/type/${typeCode}`);
|
||
|
|
return resp.data.data as SysDictItem[];
|
||
|
|
}
|