55 lines
2.6 KiB
TypeScript
55 lines
2.6 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { TrpcService } from '@server/trpc/trpc.service';
|
|
import { Prisma, UpdateOrderSchema } from '@nice/common';
|
|
import { EnrollmentService } from './enrollment.service';
|
|
import { z, ZodType } from 'zod';
|
|
import { EnrollSchema, UnenrollSchema } from './enroll.schema';
|
|
const EnrollmentCreateArgsSchema: ZodType<Prisma.EnrollmentCreateArgs> = z.any()
|
|
const EnrollmentCreateManyInputSchema: ZodType<Prisma.EnrollmentCreateManyInput> = z.any()
|
|
const EnrollmentDeleteManyArgsSchema: ZodType<Prisma.EnrollmentDeleteManyArgs> = z.any()
|
|
const EnrollmentFindManyArgsSchema: ZodType<Prisma.EnrollmentFindManyArgs> = z.any()
|
|
const EnrollmentFindFirstArgsSchema: ZodType<Prisma.EnrollmentFindFirstArgs> = z.any()
|
|
const EnrollmentWhereInputSchema: ZodType<Prisma.EnrollmentWhereInput> = z.any()
|
|
const EnrollmentSelectSchema: ZodType<Prisma.EnrollmentSelect> = z.any()
|
|
|
|
@Injectable()
|
|
export class EnrollmentRouter {
|
|
constructor(
|
|
private readonly trpc: TrpcService,
|
|
private readonly enrollmentService: EnrollmentService,
|
|
) { }
|
|
router = this.trpc.router({
|
|
findFirst: this.trpc.procedure
|
|
.input(EnrollmentFindFirstArgsSchema) // Assuming StaffMethodSchema.findMany is the Zod schema for finding staffs by keyword
|
|
.query(async ({ input }) => {
|
|
return await this.enrollmentService.findFirst(input);
|
|
}),
|
|
findMany: this.trpc.procedure
|
|
.input(EnrollmentFindManyArgsSchema) // Assuming StaffMethodSchema.findMany is the Zod schema for finding staffs by keyword
|
|
.query(async ({ input }) => {
|
|
return await this.enrollmentService.findMany(input);
|
|
}),
|
|
findManyWithCursor: this.trpc.protectProcedure
|
|
.input(z.object({
|
|
cursor: z.any().nullish(),
|
|
take: z.number().nullish(),
|
|
where: EnrollmentWhereInputSchema.nullish(),
|
|
select: EnrollmentSelectSchema.nullish()
|
|
}))
|
|
.query(async ({ ctx, input }) => {
|
|
const { staff } = ctx;
|
|
return await this.enrollmentService.findManyWithCursor(input);
|
|
}),
|
|
enroll: this.trpc.protectProcedure
|
|
.input(EnrollSchema)
|
|
.mutation(async ({ input }) => {
|
|
return await this.enrollmentService.enroll(input);
|
|
}),
|
|
unenroll: this.trpc.protectProcedure
|
|
.input(UnenrollSchema)
|
|
.mutation(async ({ input }) => {
|
|
return await this.enrollmentService.unenroll(input);
|
|
}),
|
|
});
|
|
}
|