133 lines
3.8 KiB
TypeScript
133 lines
3.8 KiB
TypeScript
/**
|
|
* @description 部门相关API
|
|
* @author yslg
|
|
* @since 2025-10-06
|
|
*/
|
|
|
|
import { api } from '@/apis/index';
|
|
import type { SysDept, SysRole, DeptRoleVO, SysDeptRole, ResultDomain } from '@/types';
|
|
|
|
/**
|
|
* 部门API服务
|
|
*/
|
|
export const deptApi = {
|
|
/**
|
|
* @description 查询所有部门
|
|
* @returns Promise<ResultDomain<SysDept>> 部门列表
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async getAllDepts(): Promise<ResultDomain<SysDept>> {
|
|
const response = await api.post<SysDept>('/depts/all');
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 查询部门列表
|
|
* @param filter 过滤条件
|
|
* @returns Promise<ResultDomain<SysDept>> 部门列表
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async getDeptList(filter: SysDept): Promise<ResultDomain<SysDept>> {
|
|
const response = await api.post<SysDept>('/depts/list', filter);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 查询部门
|
|
* @param dept 部门信息
|
|
* @returns Promise<ResultDomain<SysDept>> 部门信息
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async getDeptById(dept: SysDept): Promise<ResultDomain<SysDept>> {
|
|
const response = await api.post<SysDept>('/depts/id', dept);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 创建部门
|
|
* @param dept 部门信息
|
|
* @returns Promise<ResultDomain<SysDept>> 部门信息
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async createDept(dept: SysDept): Promise<ResultDomain<SysDept>> {
|
|
const response = await api.post<SysDept>('/depts/dept', dept);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 更新部门
|
|
* @param dept 部门信息
|
|
* @returns Promise<ResultDomain<SysDept>> 部门信息
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async updateDept(dept: SysDept): Promise<ResultDomain<SysDept>> {
|
|
const response = await api.put<SysDept>('/depts/dept', dept);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 删除部门
|
|
* @param dept 部门信息
|
|
* @returns Promise<ResultDomain<SysDept>> 部门信息
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async deleteDept(dept: SysDept): Promise<ResultDomain<SysDept>> {
|
|
const response = await api.delete<SysDept>('/depts/dept', dept);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 查询部门绑定角色
|
|
* @param dept 部门信息
|
|
* @returns Promise<ResultDomain<SysRole>> 角色列表
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async getDeptByRole(dept: SysDept): Promise<ResultDomain<SysRole>> {
|
|
const response = await api.post<SysRole>('/depts/role', dept);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 查询部门角色列表
|
|
* @param deptRole 部门角色信息
|
|
* @returns Promise<ResultDomain<SysDeptRole>> 部门角色列表
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async getDeptRoleList(deptRole: SysDeptRole): Promise<ResultDomain<SysDeptRole>> {
|
|
const response = await api.post<SysDeptRole>('/depts/role/list', deptRole);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 绑定部门角色
|
|
* @param deptRole 部门角色VO
|
|
* @returns Promise<ResultDomain<SysDeptRole>> 部门角色信息
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async bindDeptRole(deptRole: DeptRoleVO): Promise<ResultDomain<SysDeptRole>> {
|
|
const response = await api.post<SysDeptRole>('/depts/bind/role', deptRole);
|
|
return response.data;
|
|
},
|
|
|
|
/**
|
|
* @description 解绑部门角色
|
|
* @param deptRole 部门角色VO
|
|
* @returns Promise<ResultDomain<SysDeptRole>> 部门角色信息
|
|
* @author yslg
|
|
* @ since 2025-10-06
|
|
*/
|
|
async unbindDeptRole(deptRole: DeptRoleVO): Promise<ResultDomain<SysDeptRole>> {
|
|
const response = await api.post<SysDeptRole>('/depts/unbind/role', deptRole);
|
|
return response.data;
|
|
}
|
|
};
|