feat(repos): 添加checkout接口。
This commit is contained in:
parent
11cf2a6c12
commit
32102ffefd
16
src/repos/dtos/checkout.input.ts
Normal file
16
src/repos/dtos/checkout.input.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { InputType } from '@nestjs/graphql';
|
||||
import { IsOptional, IsString, IsUUID } from 'class-validator';
|
||||
|
||||
@InputType()
|
||||
export class CheckoutInput {
|
||||
@IsUUID()
|
||||
projectId: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
branch?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
commitNumber?: string;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { InputType, ObjectType } from '@nestjs/graphql';
|
||||
import { InputType } from '@nestjs/graphql';
|
||||
import { IsOptional, IsString, IsUUID } from 'class-validator';
|
||||
|
||||
@InputType()
|
||||
|
@ -4,9 +4,10 @@ import { Project } from '../projects/project.entity';
|
||||
import { ReposResolver } from './repos.resolver';
|
||||
import { ReposService } from './repos.service';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { ProjectsModule } from '../projects/projects.module';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Project]), ConfigModule],
|
||||
imports: [TypeOrmModule.forFeature([Project]), ConfigModule, ProjectsModule],
|
||||
providers: [ReposResolver, ReposService],
|
||||
})
|
||||
export class ReposModule {}
|
||||
|
@ -1,13 +1,18 @@
|
||||
import { Args, Query, Resolver } from '@nestjs/graphql';
|
||||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
||||
import { ListLogsArgs } from './dtos/list-logs.args';
|
||||
import { ReposService } from './repos.service';
|
||||
import { LogList } from './dtos/log-list.model';
|
||||
import { ListBranchesArgs } from './dtos/list-branches.args';
|
||||
import { BranchList } from './dtos/branch-list.model';
|
||||
import { CheckoutInput } from './dtos/checkout.input';
|
||||
import { ProjectsService } from '../projects/projects.service';
|
||||
|
||||
@Resolver()
|
||||
export class ReposResolver {
|
||||
constructor(private readonly service: ReposService) {}
|
||||
constructor(
|
||||
private readonly service: ReposService,
|
||||
private readonly projectService: ProjectsService,
|
||||
) {}
|
||||
@Query(() => LogList)
|
||||
async listLogs(@Args('listLogsArgs') dto: ListLogsArgs) {
|
||||
return await this.service.listLogs(dto);
|
||||
@ -23,4 +28,10 @@ export class ReposResolver {
|
||||
};
|
||||
});
|
||||
}
|
||||
@Mutation(() => Boolean)
|
||||
async checkout(@Args('checkoutInput') dto: CheckoutInput): Promise<true> {
|
||||
const project = await this.projectService.findOne(dto.projectId);
|
||||
await this.service.checkoutCommit(project, dto.commitNumber);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user