70 lines
2.2 KiB
TypeScript
Executable File
70 lines
2.2 KiB
TypeScript
Executable File
import { Injectable } from '@nestjs/common';
|
|
import { TrpcService } from '@server/trpc/trpc.service';
|
|
import { DriverService } from './driver.service';
|
|
import { z, ZodType } from 'zod';
|
|
import { Prisma } from '@nice/common';
|
|
|
|
const CourseCreateArgsSchema: ZodType<Prisma.CarCreateArgs> = z.any();
|
|
const CourseUpdateArgsSchema: ZodType<Prisma.CarUpdateArgs> = z.any();
|
|
const CourseFindManyArgsSchema: ZodType<Prisma.CarFindManyArgs> = z.any();
|
|
const CourseWhereUniqueInputSchema: ZodType<Prisma.CarWhereUniqueInput> = z.any();
|
|
|
|
@Injectable()
|
|
export class DriverRouter {
|
|
constructor(
|
|
private readonly trpc: TrpcService,
|
|
private readonly driverService: DriverService,
|
|
) {}
|
|
|
|
router = this.trpc.router({
|
|
create: this.trpc.protectProcedure
|
|
.input(CourseCreateArgsSchema)
|
|
.mutation(async ({ input }) => {
|
|
return await this.driverService.create(input);
|
|
}),
|
|
|
|
// update: this.trpc.protectProcedure
|
|
// .input(CourseUpdateArgsSchema)
|
|
// .mutation(async ({ input }) => {
|
|
// return await this.driverService.update(input);
|
|
// }),
|
|
softDeleteByIds: this.trpc.protectProcedure
|
|
.input(
|
|
z.object({
|
|
ids: z.array(z.string()),
|
|
data: CourseUpdateArgsSchema.nullish(),
|
|
}),
|
|
)
|
|
.mutation(async ({ input }) => {
|
|
return await this.driverService.softDeleteByIds(input.ids);
|
|
}),
|
|
// delete: this.trpc.protectProcedure
|
|
// .input(CourseWhereUniqueInputSchema)
|
|
// .mutation(async ({ input }) => {
|
|
// return await this.driverService.delete({ where: input });
|
|
// }),
|
|
|
|
// findMany: this.trpc.procedure
|
|
// .input(CourseFindManyArgsSchema)
|
|
// .query(async ({ input }) => {
|
|
// return await this.driverService.findMany(input);
|
|
// }),
|
|
|
|
|
|
findWithScores: this.trpc.procedure
|
|
.input(z.number())
|
|
.query(async ({ input }) => {
|
|
return await this.driverService.findWithScores(input);
|
|
}),
|
|
|
|
search: this.trpc.procedure
|
|
.input(z.object({
|
|
name: z.string().optional(),
|
|
courseId: z.number().optional(),
|
|
limit: z.number().optional()
|
|
}))
|
|
.query(async ({ input }) => {
|
|
return await this.driverService.search(input);
|
|
}),
|
|
});
|
|
} |