import type * as T from './type'
import http from '@/utils/http'

export type * from './type'

const BASE_URL = '/dept'

/** @desc 新增部门信息 */
export function addDept(data: T.DeptAddReq) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 查询部门信息详情 */
export function getDeptDetail(deptId: string) {
  return http.get<T.DeptDetailResp>(`${BASE_URL}/detail/${deptId}`)
}

/** @desc 查询部门树 */
export function getDeptTree(query?: T.DeptQuery) {
  return http.get(`${BASE_URL}/tree`, query)
}

/** @desc 修改部门信息 */
export function updateDept(deptId: string, data: T.DeptUpdateReq) {
  return http.put(`${BASE_URL}/${deptId}`, data)
}

/** @desc 删除部门信息 */
export function deleteDept(deptId: string) {
  return http.del(`${BASE_URL}/${deptId}`)
}
