31 lines
904 B
TypeScript
Executable File
31 lines
904 B
TypeScript
Executable File
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;
|
|
}),
|
|
});
|
|
}
|