import { Injectable } from '@nestjs/common';
import { TrpcService } from '@server/trpc/trpc.service';
import { Prisma, UpdateOrderSchema } from '@nice/common';
import { RoleService } from './role.service';
import { z, ZodType } from 'zod';
const RoleCreateArgsSchema: ZodType<Prisma.RoleCreateArgs> = z.any()
const RoleUpdateArgsSchema: ZodType<Prisma.RoleUpdateArgs> = z.any()
const RoleCreateManyInputSchema: ZodType<Prisma.RoleCreateManyInput> = z.any()
const RoleDeleteManyArgsSchema: ZodType<Prisma.RoleDeleteManyArgs> = z.any()
const RoleFindManyArgsSchema: ZodType<Prisma.RoleFindManyArgs> = z.any()
const RoleFindFirstArgsSchema: ZodType<Prisma.RoleFindFirstArgs> = z.any()
const RoleWhereInputSchema: ZodType<Prisma.RoleWhereInput> = z.any()
const RoleSelectSchema: ZodType<Prisma.RoleSelect> = z.any()
const RoleUpdateInputSchema: ZodType<Prisma.RoleUpdateInput> = z.any();
@Injectable()
export class RoleRouter {
    constructor(
        private readonly trpc: TrpcService,
        private readonly roleService: RoleService,
    ) { }
    router = this.trpc.router({
        create: this.trpc.protectProcedure
            .input(RoleCreateArgsSchema)
            .mutation(async ({ ctx, input }) => {
                const { staff } = ctx;
                return await this.roleService.create(input, staff);
            }),
        update: this.trpc.protectProcedure
            .input(RoleUpdateArgsSchema)
            .mutation(async ({ ctx, input }) => {
                const { staff } = ctx;
                return await this.roleService.update(input, staff);
            }),
        createMany: this.trpc.protectProcedure.input(z.array(RoleCreateManyInputSchema))
            .mutation(async ({ ctx, input }) => {
                const { staff } = ctx;

                return await this.roleService.createMany({ data: input }, staff);
            }),
        softDeleteByIds: this.trpc.protectProcedure
            .input(
                z.object({
                    ids: z.array(z.string()),
                    data: RoleUpdateInputSchema.optional()
                }),
            )
            .mutation(async ({ input }) => {
                return await this.roleService.softDeleteByIds(input.ids, input.data);
            }),
        findFirst: this.trpc.procedure
            .input(RoleFindFirstArgsSchema) // Assuming StaffMethodSchema.findMany is the Zod schema for finding staffs by keyword
            .query(async ({ input }) => {
                return await this.roleService.findFirst(input);
            }),

        updateOrder: this.trpc.protectProcedure
            .input(UpdateOrderSchema)
            .mutation(async ({ input }) => {
                return this.roleService.updateOrder(input);
            }),
        findMany: this.trpc.procedure
            .input(RoleFindManyArgsSchema) // Assuming StaffMethodSchema.findMany is the Zod schema for finding staffs by keyword
            .query(async ({ input }) => {
                return await this.roleService.findMany(input);
            }),
        findManyWithCursor: this.trpc.protectProcedure
            .input(z.object({
                cursor: z.any().nullish(),
                take: z.number().optional(),
                where: RoleWhereInputSchema.optional(),
                select: RoleSelectSchema.optional()
            }))
            .query(async ({ ctx, input }) => {
                const { staff } = ctx;
                return await this.roleService.findManyWithCursor(input);
            }),
        findManyWithPagination: this.trpc.procedure
            .input(z.object({
                page: z.number(),
                pageSize: z.number().optional(),
                where: RoleWhereInputSchema.optional(),
                select: RoleSelectSchema.optional()
            })) // Assuming StaffMethodSchema.findMany is the Zod schema for finding staffs by keyword
            .query(async ({ input }) => {
                return await this.roleService.findManyWithPagination(input);
            }),
    });
}
