origin/apps/server/src/models/comment/comment.router.ts

52 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-06-15 22:37:47 +08:00
import { Injectable } from '@nestjs/common';
import { TrpcService } from '@server/trpc/trpc.service';
import { CommentService } from './comment.service';
import { Prisma } from '@nice/common';
import { z, ZodType } from 'zod';
const CommentUncheckedCreateInputSchema: ZodType<Prisma.CommentUncheckedCreateInput> =
z.any();
const CommentWhereInputSchema: ZodType<Prisma.CommentWhereInput> = z.any();
const CommentSelectSchema: ZodType<Prisma.CommentSelect> = z.any();
const CommentUpdateArgsSchema: ZodType<Prisma.CommentUpdateArgs> = z.any();
const CommentFindFirstArgsSchema: ZodType<Prisma.CommentFindFirstArgs> =
z.any();
const CommentFindManyArgsSchema: ZodType<Prisma.CommentFindManyArgs> = z.any();
@Injectable()
export class CommentRouter {
constructor(
private readonly trpc: TrpcService,
private readonly commentService: CommentService,
) {}
router = this.trpc.router({
create: this.trpc.procedure
.input(CommentUncheckedCreateInputSchema)
.mutation(async ({ input }) => {
console.log(input);
return this.commentService.create({ data: input });
}),
update: this.trpc.procedure
.input(CommentUpdateArgsSchema)
.mutation(async ({ input }) => {
return this.commentService.update(input);
}),
findMany: this.trpc.procedure
.input(CommentFindManyArgsSchema)
.query(async ({ input }) => {
return this.commentService.findMany(input);
}),
softDeleteByIds: this.trpc.procedure
.input(z.object({ ids: z.array(z.string()) }))
.mutation(async ({ input }) => {
return this.commentService.softDeleteByIds(input.ids);
}),
findFirst: this.trpc.procedure
.input(CommentFindFirstArgsSchema)
.query(async ({ input }) => {
return this.commentService.findFirst(input);
}),
});
}