2026-04-23 15:48:43 +08:00
|
|
|
import type { PageParam, PageResult } from '@vben/request';
|
|
|
|
|
|
|
|
|
|
import type { SystemUserApi } from '#/api/system/user';
|
|
|
|
|
|
2026-04-23 14:51:09 +08:00
|
|
|
import { requestClient } from '#/api/request';
|
|
|
|
|
|
|
|
|
|
export namespace SystemUserProjectApi {
|
|
|
|
|
export interface AssignUserProjectsReq {
|
|
|
|
|
userId: number;
|
|
|
|
|
projectIds: number[];
|
|
|
|
|
}
|
|
|
|
|
export interface AssignProjectUsersReq {
|
|
|
|
|
projectId: number;
|
|
|
|
|
userIds: number[];
|
|
|
|
|
}
|
2026-04-23 15:48:43 +08:00
|
|
|
export interface AddProjectUsersReq {
|
|
|
|
|
projectId: number;
|
|
|
|
|
userIds: number[];
|
|
|
|
|
}
|
|
|
|
|
export interface ProjectUserPageReq extends PageParam {
|
|
|
|
|
projectId: number;
|
|
|
|
|
keyword?: string;
|
|
|
|
|
}
|
2026-04-23 14:51:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 给用户覆盖式分配项目 */
|
|
|
|
|
export function assignUserProjects(
|
|
|
|
|
data: SystemUserProjectApi.AssignUserProjectsReq,
|
|
|
|
|
) {
|
|
|
|
|
return requestClient.post<boolean>(
|
|
|
|
|
'/system/user-project/assign-user-projects',
|
|
|
|
|
data,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 给项目覆盖式分配成员 */
|
|
|
|
|
export function assignProjectUsers(
|
|
|
|
|
data: SystemUserProjectApi.AssignProjectUsersReq,
|
|
|
|
|
) {
|
|
|
|
|
return requestClient.post<boolean>(
|
|
|
|
|
'/system/user-project/assign-project-users',
|
|
|
|
|
data,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 查询某用户已绑定的项目编号集合 */
|
|
|
|
|
export function getProjectIdsByUserId(userId: number) {
|
|
|
|
|
return requestClient.get<number[]>(
|
|
|
|
|
`/system/user-project/list-project-ids-by-user?userId=${userId}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 查询某项目下绑定的用户编号集合 */
|
|
|
|
|
export function getUserIdsByProjectId(projectId: number) {
|
|
|
|
|
return requestClient.get<number[]>(
|
|
|
|
|
`/system/user-project/list-user-ids-by-project?projectId=${projectId}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-04-23 15:48:43 +08:00
|
|
|
|
|
|
|
|
/** 分页查询项目成员(已自动过滤超级管理员) */
|
|
|
|
|
export function getProjectUserPage(params: SystemUserProjectApi.ProjectUserPageReq) {
|
|
|
|
|
return requestClient.get<PageResult<SystemUserApi.User>>(
|
|
|
|
|
'/system/user-project/project-user-page',
|
|
|
|
|
{ params },
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 增量给项目添加成员 */
|
|
|
|
|
export function addProjectUsers(data: SystemUserProjectApi.AddProjectUsersReq) {
|
|
|
|
|
return requestClient.post<boolean>(
|
|
|
|
|
'/system/user-project/add-project-users',
|
|
|
|
|
data,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 从项目中移除单个成员 */
|
|
|
|
|
export function removeProjectUser(projectId: number, userId: number) {
|
|
|
|
|
return requestClient.delete<boolean>(
|
|
|
|
|
`/system/user-project/remove-project-user?projectId=${projectId}&userId=${userId}`,
|
|
|
|
|
);
|
|
|
|
|
}
|