Files
schoolNews/schoolNewsWeb/src/apis/system/dept.ts

133 lines
3.8 KiB
TypeScript
Raw Normal View History

2025-10-09 16:35:49 +08:00
/**
* @description API
* @author yslg
* @since 2025-10-06
*/
import { api } from '@/apis/index';
2025-10-16 10:31:32 +08:00
import type { SysDept, SysRole, DeptRoleVO, SysDeptRole, ResultDomain } from '@/types';
2025-10-09 16:35:49 +08:00
/**
* API服务
*/
export const deptApi = {
/**
* @description
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDept>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async getAllDepts(): Promise<ResultDomain<SysDept>> {
2025-10-09 16:35:49 +08:00
const response = await api.post<SysDept>('/depts/all');
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param filter
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDept>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async getDeptList(filter: SysDept): Promise<ResultDomain<SysDept>> {
2025-10-09 16:35:49 +08:00
const response = await api.post<SysDept>('/depts/list', filter);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param dept
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDept>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async getDeptById(dept: SysDept): Promise<ResultDomain<SysDept>> {
2025-10-09 16:35:49 +08:00
const response = await api.post<SysDept>('/depts/id', dept);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param dept
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDept>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async createDept(dept: SysDept): Promise<ResultDomain<SysDept>> {
2025-10-09 16:35:49 +08:00
const response = await api.post<SysDept>('/depts/dept', dept);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param dept
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDept>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async updateDept(dept: SysDept): Promise<ResultDomain<SysDept>> {
2025-10-09 16:35:49 +08:00
const response = await api.put<SysDept>('/depts/dept', dept);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param dept
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDept>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async deleteDept(dept: SysDept): Promise<ResultDomain<SysDept>> {
2025-10-09 16:35:49 +08:00
const response = await api.delete<SysDept>('/depts/dept', dept);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param dept
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysRole>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async getDeptByRole(dept: SysDept): Promise<ResultDomain<SysRole>> {
2025-10-09 16:35:49 +08:00
const response = await api.post<SysRole>('/depts/role', dept);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
2025-10-29 19:08:22 +08:00
* @param deptRole
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDeptRole>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-29 19:08:22 +08:00
async getDeptRoleList(deptRole: SysDeptRole): Promise<ResultDomain<SysDeptRole>> {
const response = await api.post<SysDeptRole>('/depts/role/list', deptRole);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param deptRole VO
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDeptRole>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async bindDeptRole(deptRole: DeptRoleVO): Promise<ResultDomain<SysDeptRole>> {
2025-10-09 16:35:49 +08:00
const response = await api.post<SysDeptRole>('/depts/bind/role', deptRole);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
},
/**
* @description
* @param deptRole VO
2025-10-16 10:31:32 +08:00
* @returns Promise<ResultDomain<SysDeptRole>>
2025-10-09 16:35:49 +08:00
* @author yslg
* @ since 2025-10-06
*/
2025-10-16 10:31:32 +08:00
async unbindDeptRole(deptRole: DeptRoleVO): Promise<ResultDomain<SysDeptRole>> {
2025-10-09 16:35:49 +08:00
const response = await api.post<SysDeptRole>('/depts/unbind/role', deptRole);
2025-10-16 10:31:32 +08:00
return response.data;
2025-10-09 16:35:49 +08:00
}
};