training_data/apps/server/src/models/term/term.controller.ts

29 lines
740 B
TypeScript
Raw Normal View History

2024-12-30 08:26:40 +08:00
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { TermService } from './term.service';
import { AuthGuard } from '@server/auth/auth.guard';
import { db } from '@nicestack/common';
@Controller('term')
export class TermController {
constructor(private readonly termService: TermService) {}
@UseGuards(AuthGuard)
@Get('get-tree-data')
async getTreeData(@Query('tax-id') taxId: string) {
try {
const result = await this.termService.getTreeData({ taxonomyId: taxId });
return {
data: result,
errmsg: 'success',
errno: 0,
};
} catch (e) {
return {
data: {},
errmsg: (e as any)?.message || 'error',
errno: 1,
};
}
}
}