import { http } from "@/utils/http";
import type {
    {{ class_name }}Info,
    Get{{ class_name }}ListParams,
    Add{{ class_name }}Params,
    Update{{ class_name }}Params,
} from "types/{{ name }}";
import { filterEmptyObject } from "./utils";

/** 添加{{ description }}数据 */
export const postAdd{{ class_name }}API = (data: Add{{ class_name }}Params) => {
    return http.request<null>("post", "/api{{ prefix }}/add", { data });
};

/** 删除{{ description }}数据 */
export const delete{{ class_name }}API = (id: string) => {
    return http.request<null>("delete", `/api{{ prefix }}/delete/${id}`);
};

/** 批量删除{{ description }}数据 */
export const delete{{ class_name }}ListAPI = (ids: string[]) => {
    return http.request<null>("delete", "/api{{ prefix }}/delete", {
        data: { ids },
    });
};

/** 修改{{ description }}数据 */
export const putUpdate{{ class_name }}API = (data: Update{{ class_name }}Params, id: string) => {
    return http.request<null>("put", `/api{{ prefix }}/update/${id}`, { data });
};

/** 获取{{ description }}信息 */
export const get{{ class_name }}InfoAPI = (id: string) => {
    return http.request<{{ class_name }}Info>("get", `/api{{ prefix }}/info/${id}`);
};

/** 获取{{ description }}列表 */
export const get{{ class_name }}ListAPI = (params: Get{{ class_name }}ListParams) => {
    return http.request<QueryListResult<{{ class_name }}Info>>("get", "/api{{ prefix }}/list", {
        params: filterEmptyObject(params),
    });
};