import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";

export interface BasicResponseModel<T = any> {
  code: number;
  msg: string;
  data: T;
}

/**
 * 获取部门列表
 * @param query
 */
export const getSystemDeptList = (query?: object) => {
  return http.request<BasicResponseModel>(
    "get",
    baseUrlApi("system/dept/list"),
    { params: query }
  );
};

/**
 * 添加部门
 * @param query
 */
export const addDept = (query?: object) => {
  return http.request<BasicResponseModel>("post", baseUrlApi("system/dept"), {
    data: query
  });
};

/**
 * 修改部门
 * @param query
 */
export const updateDept = (query?: object) => {
  return http.request<BasicResponseModel>("put", baseUrlApi("system/dept"), {
    data: query
  });
};

/**
 * 删除部门
 * @param id
 */
export const deleteDept = (id: number) => {
  return http.request<BasicResponseModel>(
    "delete",
    baseUrlApi(`system/dept/${id}`)
  );
};

/**
 * 根据ID获取部门详细信息
 * @param id
 */
export const getDept = (id: number) => {
  return http.request<BasicResponseModel>(
    "get",
    baseUrlApi(`system/dept/${id}`)
  );
};
