2024-09-10 10:31:24 +08:00
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
import { TrpcService } from '@server/trpc/trpc.service';
|
|
|
|
import { TaxonomyService } from './taxonomy.service';
|
2025-01-06 08:45:23 +08:00
|
|
|
import { TaxonomyMethodSchema } from '@nice/common';
|
2024-09-10 10:31:24 +08:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class TaxonomyRouter {
|
2024-12-30 08:26:40 +08:00
|
|
|
constructor(
|
|
|
|
private readonly trpc: TrpcService,
|
|
|
|
private readonly taxonomyService: TaxonomyService,
|
|
|
|
) { }
|
|
|
|
|
|
|
|
router = this.trpc.router({
|
|
|
|
create: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.create)
|
|
|
|
.mutation(async ({ input }) => {
|
|
|
|
return this.taxonomyService.create(input);
|
|
|
|
}),
|
|
|
|
findById: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.findById)
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
return this.taxonomyService.findById(input);
|
|
|
|
}),
|
|
|
|
findBySlug: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.findBySlug)
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
return this.taxonomyService.findBySlug(input);
|
|
|
|
}),
|
|
|
|
update: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.update)
|
|
|
|
.mutation(async ({ input }) => {
|
|
|
|
return this.taxonomyService.update(input);
|
|
|
|
}),
|
|
|
|
delete: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.delete)
|
|
|
|
.mutation(async ({ input }) => {
|
|
|
|
return this.taxonomyService.delete(input);
|
|
|
|
}),
|
|
|
|
deleteMany: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.deleteMany)
|
|
|
|
.mutation(async ({ input }) => {
|
|
|
|
return this.taxonomyService.deleteMany(input);
|
|
|
|
}),
|
|
|
|
paginate: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.paginate!)
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
return this.taxonomyService.paginate(input);
|
|
|
|
}),
|
|
|
|
getAll: this.trpc.procedure
|
|
|
|
.input(TaxonomyMethodSchema.getAll)
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
return this.taxonomyService.getAll(input);
|
|
|
|
}),
|
|
|
|
});
|
2024-09-10 10:31:24 +08:00
|
|
|
}
|