student-manage/apps/server/src/models/goods/goods.router.ts

31 lines
904 B
TypeScript
Raw Normal View History

2025-05-13 15:58:47 +08:00
import { Injectable } from '@nestjs/common';
import { TrpcService } from '@server/trpc/trpc.service';
import { GoodsService } from './goods.service';
import { Prisma } from '@nice/common';
import { z, ZodType } from 'zod';
const GoodsUncheckedCreateInputSchema: ZodType<Prisma.GoodsUncheckedCreateInput> =
z.any();
const GoodsWhereInputSchema: ZodType<Prisma.GoodsWhereInput> = z.any();
const GoodsSelectSchema: ZodType<Prisma.GoodsSelect> = z.any();
@Injectable()
export class GoodsRouter {
constructor(
private readonly trpc: TrpcService,
private readonly goodsService: GoodsService,
) {}
// trpc路由
router = this.trpc.router({
// 希望前端传什么参数
//最简单的trpc写法
hello: this.trpc.procedure
.input(
z.object({
name: z.string(),
}),
)
.query(({ input }) => {
return input.name;
}),
});
}