2024-09-03 20:29:51 +08:00
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
import { TransformService } from './transform.service';
|
2025-02-06 16:32:52 +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,
|
2025-02-06 16:32:52 +08:00
|
|
|
) {}
|
2024-09-10 10:31:24 +08:00
|
|
|
router = this.trpc.router({
|
|
|
|
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-09-03 20:29:51 +08:00
|
|
|
}
|