training_data/apps/server/src/transform/transform.router.ts

33 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-09-03 20:29:51 +08:00
import { Injectable } from '@nestjs/common';
import { TransformService } from './transform.service';
2024-09-10 10:31:24 +08:00
import { TransformSchema } from '@nicestack/common';
import { TrpcService } from '../trpc/trpc.service';
2024-09-03 20:29:51 +08:00
@Injectable()
export class TransformRouter {
2024-09-10 10:31:24 +08:00
constructor(
private readonly trpc: TrpcService,
private readonly transformService: TransformService,
) {}
router = this.trpc.router({
importTerms: this.trpc.protectProcedure
.input(TransformSchema.importTerms) // expect input according to the schema
.mutation(async ({ ctx, input }) => {
const { staff } = ctx;
return this.transformService.importTerms(staff, input);
}),
importDepts: this.trpc.protectProcedure
.input(TransformSchema.importDepts) // expect input according to the schema
.mutation(async ({ ctx, input }) => {
const { staff } = ctx;
return this.transformService.importDepts(staff, input);
}),
importStaffs: this.trpc.protectProcedure
.input(TransformSchema.importStaffs) // expect input according to the schema
.mutation(async ({ ctx, input }) => {
const { staff } = ctx;
return this.transformService.importStaffs(input);
}),
});
2024-09-03 20:29:51 +08:00
}