56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
|
|
import { del, get, post, put } from '../request'
|
|||
|
|
|
|||
|
|
export interface Project {
|
|||
|
|
id: string
|
|||
|
|
tenant_id: string
|
|||
|
|
name: string
|
|||
|
|
code: string
|
|||
|
|
description?: string
|
|||
|
|
status: string
|
|||
|
|
quota?: Record<string, unknown>
|
|||
|
|
member_count?: number
|
|||
|
|
task_count?: number
|
|||
|
|
create_time?: string
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export interface ProjectMember {
|
|||
|
|
user_id: string
|
|||
|
|
role: string
|
|||
|
|
joined_at?: string
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/** 项目列表(按租户过滤,默认 default) */
|
|||
|
|
export const getProjects = (tenantId = 'default') =>
|
|||
|
|
get<Project[]>('/projects', { tenant_id: tenantId })
|
|||
|
|
|
|||
|
|
/** 项目详情 */
|
|||
|
|
export const getProject = (id: string) => get<Project>(`/projects/${id}`)
|
|||
|
|
|
|||
|
|
/** 创建项目 */
|
|||
|
|
export const createProject = (payload: Partial<Project>) =>
|
|||
|
|
post<Project>('/projects', payload)
|
|||
|
|
|
|||
|
|
/** 更新项目 */
|
|||
|
|
export const updateProject = (id: string, payload: Partial<Project>) =>
|
|||
|
|
put<Project>(`/projects/${id}`, payload)
|
|||
|
|
|
|||
|
|
/** 归档项目 */
|
|||
|
|
export const archiveProject = (id: string) =>
|
|||
|
|
post<Project>(`/projects/${id}/archive`)
|
|||
|
|
|
|||
|
|
/** 项目成员列表 */
|
|||
|
|
export const getProjectMembers = (id: string) =>
|
|||
|
|
get<ProjectMember[]>(`/projects/${id}/members`)
|
|||
|
|
|
|||
|
|
/** 添加成员 */
|
|||
|
|
export const addProjectMember = (id: string, payload: { user_id: string; role: string }) =>
|
|||
|
|
post<ProjectMember>(`/projects/${id}/members`, payload)
|
|||
|
|
|
|||
|
|
/** 更新成员角色 */
|
|||
|
|
export const updateProjectMember = (id: string, userId: string, role: string) =>
|
|||
|
|
put<ProjectMember>(`/projects/${id}/members/${userId}`, { role })
|
|||
|
|
|
|||
|
|
/** 移除成员 */
|
|||
|
|
export const removeProjectMember = (id: string, userId: string) =>
|
|||
|
|
del(`/projects/${id}/members/${userId}`)
|