50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { TrpcService } from '@server/trpc/trpc.service';
|
|
import { sportProjectService } from './sportProject.service';
|
|
import { z, ZodType } from 'zod';
|
|
import { Prisma } from '@nice/common';
|
|
|
|
const SportProjectArgsSchema: ZodType<Prisma.SportProjectCreateArgs> = z.any();
|
|
const SportProjectUpdateArgsSchema: ZodType<Prisma.SportProjectUpdateArgs> =
|
|
z.any();
|
|
const SportProjectFindManyArgsSchema: ZodType<Prisma.SportProjectFindManyArgs> =
|
|
z.any();
|
|
const SportProjectFindFirstArgsSchema: ZodType<Prisma.SportProjectFindFirstArgs> =
|
|
z.any();
|
|
@Injectable()
|
|
export class SportProjectRouter {
|
|
constructor(
|
|
private readonly trpc: TrpcService,
|
|
private readonly sportProjectService: sportProjectService,
|
|
) {}
|
|
|
|
router = this.trpc.router({
|
|
create: this.trpc.procedure
|
|
.input(SportProjectArgsSchema)
|
|
.mutation(async ({ input }) => {
|
|
console.log(input);
|
|
return this.sportProjectService.create(input);
|
|
}),
|
|
update: this.trpc.procedure
|
|
.input(SportProjectUpdateArgsSchema)
|
|
.mutation(async ({ input }) => {
|
|
return this.sportProjectService.update(input);
|
|
}),
|
|
findMany: this.trpc.procedure
|
|
.input(SportProjectFindManyArgsSchema)
|
|
.query(async ({ input }) => {
|
|
return this.sportProjectService.findMany(input);
|
|
}),
|
|
softDeleteByIds: this.trpc.procedure
|
|
.input(z.object({ ids: z.array(z.string()) }))
|
|
.mutation(async ({ input }) => {
|
|
return this.sportProjectService.softDeleteByIds(input.ids);
|
|
}),
|
|
findFirst: this.trpc.procedure
|
|
.input(SportProjectFindFirstArgsSchema)
|
|
.query(async ({ input }) => {
|
|
return this.sportProjectService.findFirst(input);
|
|
}),
|
|
});
|
|
}
|