import { request } from "@umijs/max";

export interface PostVO {
  id: number;
  name: string;
  code: string;
  sort: number;
  status: number;
  remark: string;
  createTime?: Date;
}

export interface PostReqVO extends PageParam {
  name?: string;
  status?: number;
  code?: string;
}

// 查询岗位列表
// export const getPostPage = async (params: PostReq) => {
//   return await request.get({ url: "/system/post/page", params });
// };

export const getPostPage = (params: PostReqVO) => {
  return request("/system/post/page", {
    method: "GET",
    params,
  });
};

// 获取岗位精简信息列表
// export const getSimplePostList = async (): Promise<Post[]> => {
//     return await request.get({ url: "/system/post/simple-list" });
//   };

export const getSimplePostList = () => {
  return request("/system/post/simple-list", {
    method: "GET",
  });
};

// 查询岗位详情
// export const getPost = async (id: number) => {
//     return await request.get({ url: "/system/post/get?id=" + id });
//   };

export const getPost = (id: number) => {
  return request("/system/post/get", {
    method: "GET",
    params: { id },
  });
};
// 新增岗位
//   export const createPost = async (data: Post) => {
//     return await request.post({ url: "/system/post/create", data });
//   };

export const createPost = async (data: PostVO) => {
  return await request("/system/post/create", {
    method: "POST",
    data,
  });
};

// 修改岗位
// export const updatePost = async (data: Post) => {
//   return await request.put({ url: "/system/post/update", data });
// };

export const updatePost = async (data: PostVO) => {
  return await request("/system/post/update", {
    method: "PUT",
    data,
  });
};

// 删除岗位
// export const deletePost = async (id: number) => {
//   return await request.delete({ url: "/system/post/delete?id=" + id });
// };

export const deletePost = async (id: number) => {
  return await request("/system/post/delete", {
    method: "DELETE",
    params: { id },
  });
};
