feat(pipelines): 添加流水线模块。
This commit is contained in:
37
src/pipelines/pipelines.service.ts
Normal file
37
src/pipelines/pipelines.service.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Pipeline } from './pipeline.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseDbService } from '../commons/services/base-db.service';
|
||||
import { CreatePipelineInput } from './dtos/create-pipeline.input';
|
||||
import { UpdatePipelineInput } from './dtos/update-pipeline.input';
|
||||
import { ListPipelineArgs } from './dtos/list-pipelines.args';
|
||||
|
||||
@Injectable()
|
||||
export class PipelinesService extends BaseDbService<Pipeline> {
|
||||
readonly uniqueFields: Array<keyof Pipeline> = ['branch', 'projectId'];
|
||||
constructor(
|
||||
@InjectRepository(Pipeline)
|
||||
readonly repository: Repository<Pipeline>,
|
||||
) {
|
||||
super(repository);
|
||||
}
|
||||
async list(dto: ListPipelineArgs) {
|
||||
return this.repository.find(dto);
|
||||
}
|
||||
|
||||
async create(dto: CreatePipelineInput) {
|
||||
await this.isDuplicateEntity(dto);
|
||||
return await this.repository.save(this.repository.create(dto));
|
||||
}
|
||||
|
||||
async update(id: string, dto: UpdatePipelineInput) {
|
||||
await this.isDuplicateEntityForUpdate(id, dto);
|
||||
const old = await this.findOne(id);
|
||||
return await this.repository.save(this.repository.merge(old, dto));
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
return (await this.repository.softDelete({ id })).affected;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user