增加团队管理页面

This commit is contained in:
dengqichen 2025-10-29 13:54:52 +08:00
parent 01e702dfa2
commit 714ced899f
3 changed files with 829 additions and 540 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,126 @@
import request from '@/utils/request';
import type { GitInstanceInfo } from './types';
import type {
RepositoryGroupResponse,
RepositoryGroupQuery,
RepositoryProjectResponse,
RepositoryProjectQuery,
RepositoryBranchResponse,
RepositoryBranchQuery,
GitStatistics,
} from './types';
import { getExternalSystems } from '@/pages/Deploy/External/service';
import { SystemType } from '@/pages/Deploy/External/types';
const BASE_URL = '/api/v1/repository-manager';
// API 基础路径
const GROUP_URL = '/api/v1/repository-group';
const PROJECT_URL = '/api/v1/repository-project';
const BRANCH_URL = '/api/v1/repository-branch';
// 获取 Git 实例列表
// ==================== Git 实例 ====================
/**
* Git
*/
export const getGitInstances = () =>
getExternalSystems({
type: SystemType.GIT,
enabled: true
}).then(response => response.content);
enabled: true,
}).then((response) => response.content);
// 获取 Git 实例信息
export const getGitInstanceInfo = (externalSystemId: number) =>
request.get<GitInstanceInfo>(`${BASE_URL}/${externalSystemId}/instance`);
// ==================== 仓库组 ====================
// 同步所有 Git 数据
/**
*
*/
export const getRepositoryGroups = (params?: RepositoryGroupQuery) =>
request.get<RepositoryGroupResponse[]>(`${GROUP_URL}/list`, { params });
/**
*
*/
export const getRepositoryGroupTree = (externalSystemId: number) =>
request.get<RepositoryGroupResponse[]>(`${GROUP_URL}/tree`, {
params: { externalSystemId },
});
/**
*
*/
export const syncRepositoryGroups = (externalSystemId: number) =>
request.post<void>(`${GROUP_URL}/sync`, null, {
params: { externalSystemId },
});
// ==================== 仓库项目 ====================
/**
*
*/
export const getRepositoryProjects = (params?: RepositoryProjectQuery) =>
request.get<RepositoryProjectResponse[]>(`${PROJECT_URL}/list`, { params });
/**
* ID获取项目列表
*/
export const getProjectsByGroupId = (repoGroupId: number) =>
request.get<RepositoryProjectResponse[]>(`${PROJECT_URL}/list`, {
params: { repoGroupId },
});
/**
*
*/
export const syncRepositoryProjects = (externalSystemId: number, repoGroupId?: number) =>
request.post<void>(`${PROJECT_URL}/sync`, null, {
params: { externalSystemId, repoGroupId },
});
// ==================== 仓库分支 ====================
/**
*
*/
export const getRepositoryBranches = (params?: RepositoryBranchQuery) =>
request.get<RepositoryBranchResponse[]>(`${BRANCH_URL}/list`, { params });
/**
* ID获取分支列表
*/
export const getBranchesByProjectId = (repoProjectId: number) =>
request.get<RepositoryBranchResponse[]>(`${BRANCH_URL}/list`, {
params: { repoProjectId },
});
/**
*
*/
export const syncRepositoryBranches = (
externalSystemId: number,
repoProjectId?: number,
repoGroupId?: number
) =>
request.post<void>(`${BRANCH_URL}/sync`, null, {
params: { externalSystemId, repoProjectId, repoGroupId },
});
// ==================== 统计信息 ====================
/**
* Git仓库统计信息
*/
export const getGitStatistics = (externalSystemId: number) =>
request.get<GitStatistics>(`${GROUP_URL}/statistics`, {
params: { externalSystemId },
});
// ==================== 批量操作 ====================
/**
*
*/
export const syncAllGitData = (externalSystemId: number) =>
request.post<void>(`${BASE_URL}/${externalSystemId}/sync-all`);
// 同步 Git 仓库组
export const syncGitGroups = (externalSystemId: number) =>
request.post<void>(`${BASE_URL}/${externalSystemId}/sync-groups`);
// 同步 Git 项目
export const syncGitProjects = (externalSystemId: number) =>
request.post<void>(`${BASE_URL}/${externalSystemId}/groups/sync-projects`);
// 同步 Git 分支
export const syncGitBranches = (externalSystemId: number) =>
request.post<void>(`${BASE_URL}/${externalSystemId}/projects/sync-branches`);
Promise.all([
syncRepositoryGroups(externalSystemId),
syncRepositoryProjects(externalSystemId),
syncRepositoryBranches(externalSystemId),
]);

View File

@ -1,88 +1,151 @@
import type { BaseResponse } from '@/types/base';
import type { ExternalSystemResponse } from '@/pages/Deploy/External/types';
// Git仓库组
export interface RepositoryGroup {
id: number;
groupId: number;
/**
*
*/
export interface RepositoryGroupResponse extends BaseResponse {
/** 仓库组名 */
name: string;
/** 仓库组描述 */
description?: string;
/** 父级仓库组ID */
parentId?: number;
/** 仓库组路径 */
path: string;
description: string;
/** 头像URL */
avatarUrl?: string;
/** 完整名称(包含层级关系) */
fullName?: string;
/** 完整路径 */
fullPath?: string;
/** 网页URL */
webUrl?: string;
/** 可见性 */
visibility: string;
parentId: number | null;
webUrl: string;
avatarUrl: string;
/** 排序号 */
sort?: number;
/** 外部系统中的组ID */
repoGroupId?: number;
/** 外部系统ID */
externalSystemId: number;
/** 子仓库组列表(用于树形结构) */
children?: RepositoryGroupResponse[];
}
// Git项目
export interface RepositoryProject {
id: number;
projectId: number;
/**
*
*/
export interface RepositoryProjectResponse extends BaseResponse {
/** 项目名称 */
name: string;
/** 项目路径 */
path: string;
description: string;
/** 项目描述 */
description?: string;
/** 可见性 */
visibility: string;
groupId: number;
isDefaultBranch: string;
webUrl: string;
sshUrl: string;
httpUrl: string;
lastActivityAt: string;
/** 默认分支名称 */
isDefaultBranch?: string;
/** 网页URL */
webUrl?: string;
/** SSH URL */
sshUrl?: string;
/** HTTP URL */
httpUrl?: string;
/** 最后活动时间 */
lastActivityAt?: string;
/** 外部系统ID */
externalSystemId: number;
/** 所属仓库组ID */
repoGroupId?: number;
/** 外部系统中的项目ID */
repoProjectId?: number;
}
// Git实例信息
export interface GitInstanceInfo {
totalGroups: number;
lastSyncGroupsTime: string;
totalProjects: number;
lastSyncProjectsTime: string;
totalBranches: number;
lastSyncBranchesTime: string;
repositoryGroupList: RepositoryGroup[];
repositoryProjectList: RepositoryProject[];
}
// 使用外部系统响应作为 Git 实例
export type GitInstance = ExternalSystemResponse;
// Git 仓库详情
export interface GitRepositoryDTO extends BaseResponse {
repoName: string;
repoUrl: string;
description: string;
defaultBranch: string;
visibility: 'public' | 'private';
lastCommitTime?: string;
/**
*
*/
export interface RepositoryBranchResponse extends BaseResponse {
/** 分支名称 */
name: string;
/** 是否为默认分支 */
isDefaultBranch?: boolean;
/** 是否受保护 */
isProtected?: boolean;
/** 是否可推送 */
canPush?: boolean;
/** 开发者是否可推送 */
developersCanPush?: boolean;
/** 开发者是否可合并 */
developersCanMerge?: boolean;
/** 最后提交ID */
lastCommitId?: string;
/** 最后提交信息 */
lastCommitMessage?: string;
lastCommitAuthor?: string;
totalBranches: number;
totalTags: number;
totalCommits: number;
/** 提交作者 */
commitAuthor?: string;
/** 提交日期 */
commitDate?: string;
/** 网页URL */
webUrl?: string;
/** 所属项目ID */
repoProjectId: number;
/** 外部系统ID */
externalSystemId: number;
}
// Git 分支信息
export interface GitBranchDTO extends BaseResponse {
branchName: string;
isDefault: boolean;
isProtected: boolean;
lastCommitSha: string;
lastCommitMessage: string;
lastCommitAuthor: string;
lastCommitTime: string;
repositoryId: number;
/**
*
*/
export interface RepositoryGroupQuery {
/** 仓库组名称 */
name?: string;
/** 父级ID */
parentId?: number;
/** 外部系统ID */
externalSystemId?: number;
/** 可见性 */
visibility?: string;
}
// Git 标签信息
export interface GitTagDTO extends BaseResponse {
tagName: string;
tagMessage: string;
taggerName: string;
taggerEmail: string;
taggedTime: string;
commitSha: string;
repositoryId: number;
/**
*
*/
export interface RepositoryProjectQuery {
/** 项目名称 */
name?: string;
/** 仓库组ID */
repoGroupId?: number;
/** 外部系统ID */
externalSystemId?: number;
/** 可见性 */
visibility?: string;
}
// 同步类型
export type SyncType = 'repositories' | 'branches' | 'tags';
/**
*
*/
export interface RepositoryBranchQuery {
/** 分支名称 */
name?: string;
/** 项目ID */
repoProjectId?: number;
/** 外部系统ID */
externalSystemId?: number;
/** 是否为默认分支 */
isDefaultBranch?: boolean;
}
/**
*
*/
export interface GitStatistics {
/** 总仓库组数 */
totalGroups: number;
/** 总项目数 */
totalProjects: number;
/** 总分支数 */
totalBranches: number;
/** 最后同步时间 */
lastSyncTime?: string;
}