fix(projects): 修复若干问题。
This commit is contained in:
parent
db6b699663
commit
c2c5340278
@ -1,5 +1,11 @@
|
|||||||
import { InputType } from '@nestjs/graphql';
|
import { InputType } from '@nestjs/graphql';
|
||||||
import { IsString, IsUrl, MaxLength, MinLength } from 'class-validator';
|
import {
|
||||||
|
IsOptional,
|
||||||
|
IsString,
|
||||||
|
IsUrl,
|
||||||
|
MaxLength,
|
||||||
|
MinLength,
|
||||||
|
} from 'class-validator';
|
||||||
|
|
||||||
@InputType({ isAbstract: true })
|
@InputType({ isAbstract: true })
|
||||||
export class CreateProjectInput {
|
export class CreateProjectInput {
|
||||||
@ -18,6 +24,7 @@ export class CreateProjectInput {
|
|||||||
sshUrl: string;
|
sshUrl: string;
|
||||||
|
|
||||||
@IsUrl()
|
@IsUrl()
|
||||||
|
@IsOptional()
|
||||||
@MaxLength(256)
|
@MaxLength(256)
|
||||||
webUrl?: string;
|
webUrl?: string;
|
||||||
|
|
||||||
|
@ -25,13 +25,15 @@ export class ProjectsResolver {
|
|||||||
return await this.service.create(dto);
|
return await this.service.create(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => Boolean)
|
@Mutation(() => Project)
|
||||||
async modifyProject(
|
async modifyProject(
|
||||||
@Args('id', { type: () => String }) id: string,
|
@Args('id', { type: () => String }) id: string,
|
||||||
@Args('project', { type: () => UpdateProjectInput })
|
@Args('project', { type: () => UpdateProjectInput })
|
||||||
dto: UpdateProjectInput,
|
dto: UpdateProjectInput,
|
||||||
) {
|
) {
|
||||||
return await this.service.update(id, dto);
|
const tmp = await this.service.update(id, dto);
|
||||||
|
console.log(tmp);
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => Number)
|
@Mutation(() => Number)
|
||||||
|
@ -26,7 +26,8 @@ export class ProjectsService extends BaseDbService<Project> {
|
|||||||
|
|
||||||
async update(id: string, dto: CreateProjectInput) {
|
async update(id: string, dto: CreateProjectInput) {
|
||||||
await this.isDuplicateEntityForUpdate(id, dto);
|
await this.isDuplicateEntityForUpdate(id, dto);
|
||||||
await this.repository.update({ id }, dto);
|
const old = await this.findOne(id);
|
||||||
|
return await this.repository.save(this.repository.merge(old, dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(id: string) {
|
async remove(id: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user