import request from '@/utils/request';
import type { Page } from '@/types/base/page';
import type { DepartmentResponse, DepartmentRequest, DepartmentQuery } from './types';
import {UserResponse} from "@/pages/System/User/types";

const BASE_URL = '/api/v1/department';

// 获取部门列表(分页)
export const getDepartments = (params?: DepartmentQuery) => 
    request.get<Page<DepartmentResponse>>(`${BASE_URL}/page`, { params });

// 获取部门树
export const getDepartmentTree = () => 
    request.get<DepartmentResponse[]>(`${BASE_URL}/tree`);

// 创建部门
export const createDepartment = (data: DepartmentRequest) => 
    request.post<DepartmentResponse>(BASE_URL, data);

// 更新部门
export const updateDepartment = (id: number, data: DepartmentRequest) => 
    request.put<DepartmentResponse>(`${BASE_URL}/${id}`, data);

// 删除部门
export const deleteDepartment = (id: number) => 
    request.delete(`${BASE_URL}/${id}`);

// 获取用户列表(不分页)
export const getUsers = () => request.get<UserResponse[]>('/api/v1/user/list');
 