feat: Introduce DTOs for API validation and new deployment features, including a Git controller and UI components.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { type APIResponse, net } from '@shared';
|
||||
import type { Pipeline, Project, Step } from '../types';
|
||||
import type { Branch, Commit, Deployment, Pipeline, Project, Step } from '../types';
|
||||
|
||||
class DetailService {
|
||||
async getProject(id: string) {
|
||||
@@ -17,6 +17,14 @@ class DetailService {
|
||||
return data;
|
||||
}
|
||||
|
||||
// 获取项目的部署记录
|
||||
async getDeployments(projectId: number) {
|
||||
const { data } = await net.request<any>({
|
||||
url: `/api/deployments?projectId=${projectId}`,
|
||||
});
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// 创建流水线
|
||||
async createPipeline(
|
||||
pipeline: Omit<
|
||||
@@ -120,6 +128,39 @@ class DetailService {
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
// 获取项目的提交记录
|
||||
async getCommits(projectId: number, branch?: string) {
|
||||
const { data } = await net.request<APIResponse<Commit[]>>({
|
||||
url: `/api/git/commits?projectId=${projectId}${branch ? `&branch=${branch}` : ''}`,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
// 获取项目的分支列表
|
||||
async getBranches(projectId: number) {
|
||||
const { data } = await net.request<APIResponse<Branch[]>>({
|
||||
url: `/api/git/branches?projectId=${projectId}`,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
// 创建部署
|
||||
async createDeployment(deployment: {
|
||||
projectId: number;
|
||||
pipelineId: number;
|
||||
branch: string;
|
||||
commitHash: string;
|
||||
commitMessage: string;
|
||||
env?: string;
|
||||
}) {
|
||||
const { data } = await net.request<APIResponse<Deployment>>({
|
||||
url: '/api/deployments',
|
||||
method: 'POST',
|
||||
data: deployment,
|
||||
});
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export const detailService = new DetailService();
|
||||
|
||||
Reference in New Issue
Block a user