增加团队管理页面
This commit is contained in:
parent
01e702dfa2
commit
714ced899f
File diff suppressed because it is too large
Load Diff
@ -1,33 +1,126 @@
|
|||||||
import request from '@/utils/request';
|
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 { getExternalSystems } from '@/pages/Deploy/External/service';
|
||||||
import { SystemType } from '@/pages/Deploy/External/types';
|
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 实例 ====================
|
||||||
export const getGitInstances = () =>
|
|
||||||
|
/**
|
||||||
|
* 获取 Git 实例列表
|
||||||
|
*/
|
||||||
|
export const getGitInstances = () =>
|
||||||
getExternalSystems({
|
getExternalSystems({
|
||||||
type: SystemType.GIT,
|
type: SystemType.GIT,
|
||||||
enabled: true
|
enabled: true,
|
||||||
}).then(response => response.content);
|
}).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) =>
|
export const syncAllGitData = (externalSystemId: number) =>
|
||||||
request.post<void>(`${BASE_URL}/${externalSystemId}/sync-all`);
|
Promise.all([
|
||||||
|
syncRepositoryGroups(externalSystemId),
|
||||||
// 同步 Git 仓库组
|
syncRepositoryProjects(externalSystemId),
|
||||||
export const syncGitGroups = (externalSystemId: number) =>
|
syncRepositoryBranches(externalSystemId),
|
||||||
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`);
|
|
||||||
|
|||||||
@ -1,88 +1,151 @@
|
|||||||
import type { BaseResponse } from '@/types/base';
|
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;
|
name: string;
|
||||||
|
/** 仓库组描述 */
|
||||||
|
description?: string;
|
||||||
|
/** 父级仓库组ID */
|
||||||
|
parentId?: number;
|
||||||
|
/** 仓库组路径 */
|
||||||
path: string;
|
path: string;
|
||||||
description: string;
|
/** 头像URL */
|
||||||
|
avatarUrl?: string;
|
||||||
|
/** 完整名称(包含层级关系) */
|
||||||
|
fullName?: string;
|
||||||
|
/** 完整路径 */
|
||||||
|
fullPath?: string;
|
||||||
|
/** 网页URL */
|
||||||
|
webUrl?: string;
|
||||||
|
/** 可见性 */
|
||||||
visibility: string;
|
visibility: string;
|
||||||
parentId: number | null;
|
/** 排序号 */
|
||||||
webUrl: string;
|
sort?: number;
|
||||||
avatarUrl: string;
|
/** 外部系统中的组ID */
|
||||||
|
repoGroupId?: number;
|
||||||
|
/** 外部系统ID */
|
||||||
|
externalSystemId: number;
|
||||||
|
/** 子仓库组列表(用于树形结构) */
|
||||||
|
children?: RepositoryGroupResponse[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Git项目
|
/**
|
||||||
export interface RepositoryProject {
|
* 仓库项目响应类型
|
||||||
id: number;
|
*/
|
||||||
projectId: number;
|
export interface RepositoryProjectResponse extends BaseResponse {
|
||||||
|
/** 项目名称 */
|
||||||
name: string;
|
name: string;
|
||||||
|
/** 项目路径 */
|
||||||
path: string;
|
path: string;
|
||||||
description: string;
|
/** 项目描述 */
|
||||||
|
description?: string;
|
||||||
|
/** 可见性 */
|
||||||
visibility: string;
|
visibility: string;
|
||||||
groupId: number;
|
/** 默认分支名称 */
|
||||||
isDefaultBranch: string;
|
isDefaultBranch?: string;
|
||||||
webUrl: string;
|
/** 网页URL */
|
||||||
sshUrl: string;
|
webUrl?: string;
|
||||||
httpUrl: string;
|
/** SSH URL */
|
||||||
lastActivityAt: string;
|
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;
|
export interface RepositoryBranchResponse extends BaseResponse {
|
||||||
totalProjects: number;
|
/** 分支名称 */
|
||||||
lastSyncProjectsTime: string;
|
name: string;
|
||||||
totalBranches: number;
|
/** 是否为默认分支 */
|
||||||
lastSyncBranchesTime: string;
|
isDefaultBranch?: boolean;
|
||||||
repositoryGroupList: RepositoryGroup[];
|
/** 是否受保护 */
|
||||||
repositoryProjectList: RepositoryProject[];
|
isProtected?: boolean;
|
||||||
}
|
/** 是否可推送 */
|
||||||
|
canPush?: boolean;
|
||||||
// 使用外部系统响应作为 Git 实例
|
/** 开发者是否可推送 */
|
||||||
export type GitInstance = ExternalSystemResponse;
|
developersCanPush?: boolean;
|
||||||
|
/** 开发者是否可合并 */
|
||||||
// Git 仓库详情
|
developersCanMerge?: boolean;
|
||||||
export interface GitRepositoryDTO extends BaseResponse {
|
/** 最后提交ID */
|
||||||
repoName: string;
|
lastCommitId?: string;
|
||||||
repoUrl: string;
|
/** 最后提交信息 */
|
||||||
description: string;
|
|
||||||
defaultBranch: string;
|
|
||||||
visibility: 'public' | 'private';
|
|
||||||
lastCommitTime?: string;
|
|
||||||
lastCommitMessage?: string;
|
lastCommitMessage?: string;
|
||||||
lastCommitAuthor?: string;
|
/** 提交作者 */
|
||||||
totalBranches: number;
|
commitAuthor?: string;
|
||||||
totalTags: number;
|
/** 提交日期 */
|
||||||
totalCommits: number;
|
commitDate?: string;
|
||||||
|
/** 网页URL */
|
||||||
|
webUrl?: string;
|
||||||
|
/** 所属项目ID */
|
||||||
|
repoProjectId: number;
|
||||||
|
/** 外部系统ID */
|
||||||
externalSystemId: number;
|
externalSystemId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Git 分支信息
|
/**
|
||||||
export interface GitBranchDTO extends BaseResponse {
|
* 仓库组查询参数
|
||||||
branchName: string;
|
*/
|
||||||
isDefault: boolean;
|
export interface RepositoryGroupQuery {
|
||||||
isProtected: boolean;
|
/** 仓库组名称 */
|
||||||
lastCommitSha: string;
|
name?: string;
|
||||||
lastCommitMessage: string;
|
/** 父级ID */
|
||||||
lastCommitAuthor: string;
|
parentId?: number;
|
||||||
lastCommitTime: string;
|
/** 外部系统ID */
|
||||||
repositoryId: number;
|
externalSystemId?: number;
|
||||||
|
/** 可见性 */
|
||||||
|
visibility?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Git 标签信息
|
/**
|
||||||
export interface GitTagDTO extends BaseResponse {
|
* 仓库项目查询参数
|
||||||
tagName: string;
|
*/
|
||||||
tagMessage: string;
|
export interface RepositoryProjectQuery {
|
||||||
taggerName: string;
|
/** 项目名称 */
|
||||||
taggerEmail: string;
|
name?: string;
|
||||||
taggedTime: string;
|
/** 仓库组ID */
|
||||||
commitSha: string;
|
repoGroupId?: number;
|
||||||
repositoryId: 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;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user