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

35 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';
2025-01-06 08:45:23 +08:00
import { TransformMethodSchema} from '@nice/common';
2024-12-30 08:26:40 +08:00
import { TrpcService } from '@server/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,
2024-12-30 08:26:40 +08:00
) { }
2024-09-10 10:31:24 +08:00
router = this.trpc.router({
2024-12-30 08:26:40 +08:00
2024-09-10 10:31:24 +08:00
importTerms: this.trpc.protectProcedure
2024-12-30 08:26:40 +08:00
.input(TransformMethodSchema.importTerms) // expect input according to the schema
2024-09-10 10:31:24 +08:00
.mutation(async ({ ctx, input }) => {
const { staff } = ctx;
return this.transformService.importTerms(staff, input);
}),
importDepts: this.trpc.protectProcedure
2024-12-30 08:26:40 +08:00
.input(TransformMethodSchema.importDepts) // expect input according to the schema
2024-09-10 10:31:24 +08:00
.mutation(async ({ ctx, input }) => {
const { staff } = ctx;
return this.transformService.importDepts(staff, input);
}),
importStaffs: this.trpc.protectProcedure
2024-12-30 08:26:40 +08:00
.input(TransformMethodSchema.importStaffs) // expect input according to the schema
2024-09-10 10:31:24 +08:00
.mutation(async ({ ctx, input }) => {
const { staff } = ctx;
return this.transformService.importStaffs(input);
}),
2024-12-30 08:26:40 +08:00
2024-09-10 10:31:24 +08:00
});
2024-09-03 20:29:51 +08:00
}