import request from '@/utils/request'
import { AxiosPromise } from 'axios'

// apiUrl 部门管理
const api = {
	page: '/sys/department/list-tree',
	create: '/sys/department/create',
	update: '/sys/department/update',
	delete: '/sys/department/delete',
	listAll: '/sys/department/list-all'
}
/**
 * 部门管理 - 列表
 */
function departmentPageApi(data: any): AxiosPromise {
	return request({
		url: api.page,
		method: 'post',
		data
	})
}

/**
 * 部门管理 - 新增编辑保存
 */
function departmentAddOrEditSaveApi(data: any): AxiosPromise {
	return request({
		url: data.id ? api.update : api.create,
		method: 'post',
		data
	})
}

/**
 * 部门管理 - 删除
 */
function departmentDeleteApi(data: any): AxiosPromise {
	return request({
		url: api.delete,
		method: 'post',
		data
	})
}

function departmentListAllApi(): AxiosPromise {
	return request({ url: api.listAll, method: 'get' })
}

export default {
	departmentPageApi,
	departmentAddOrEditSaveApi,
	departmentDeleteApi,
	departmentListAllApi
}
