import { Injectable } from '@nestjs/common'; import { TrpcService } from '@server/trpc/trpc.service'; import { Prisma, UpdateOrderSchema } from '@nice/common'; import { LectureService } from './lecture.service'; import { z, ZodType } from 'zod'; const LectureCreateArgsSchema: ZodType = z.any() const LectureCreateManyInputSchema: ZodType = z.any() const LectureDeleteManyArgsSchema: ZodType = z.any() const LectureFindManyArgsSchema: ZodType = z.any() const LectureFindFirstArgsSchema: ZodType = z.any() const LectureWhereInputSchema: ZodType = z.any() const LectureSelectSchema: ZodType = z.any() @Injectable() export class LectureRouter { constructor( private readonly trpc: TrpcService, private readonly lectureService: LectureService, ) { } router = this.trpc.router({ create: this.trpc.protectProcedure .input(LectureCreateArgsSchema) .mutation(async ({ ctx, input }) => { const { staff } = ctx; return await this.lectureService.create(input, {staff}); }), createMany: this.trpc.protectProcedure.input(z.array(LectureCreateManyInputSchema)) .mutation(async ({ ctx, input }) => { const { staff } = ctx; return await this.lectureService.createMany({ data: input }, staff); }), deleteMany: this.trpc.procedure .input(LectureDeleteManyArgsSchema) .mutation(async ({ input }) => { return await this.lectureService.deleteMany(input); }), findFirst: this.trpc.procedure .input(LectureFindFirstArgsSchema) // Assuming StaffMethodSchema.findMany is the Zod schema for finding staffs by keyword .query(async ({ input }) => { return await this.lectureService.findFirst(input); }), softDeleteByIds: this.trpc.protectProcedure .input(z.object({ ids: z.array(z.string()) })) // expect input according to the schema .mutation(async ({ input }) => { return this.lectureService.softDeleteByIds(input.ids); }), updateOrder: this.trpc.protectProcedure .input(UpdateOrderSchema) .mutation(async ({ input }) => { return this.lectureService.updateOrder(input); }), findMany: this.trpc.procedure .input(LectureFindManyArgsSchema) // Assuming StaffMethodSchema.findMany is the Zod schema for finding staffs by keyword .query(async ({ input }) => { return await this.lectureService.findMany(input); }), findManyWithCursor: this.trpc.protectProcedure .input(z.object({ cursor: z.any().nullish(), take: z.number().nullish(), where: LectureWhereInputSchema.nullish(), select: LectureSelectSchema.nullish() })) .query(async ({ ctx, input }) => { const { staff } = ctx; return await this.lectureService.findManyWithCursor(input); }), }); }