0a9588abb7
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
58 lines
1.1 KiB
TypeScript
58 lines
1.1 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
UseGuards,
|
|
Request,
|
|
} from '@nestjs/common';
|
|
import { NoteCategoryService } from './note-category.service';
|
|
import { CombinedAuthGuard } from '../auth/combined-auth.guard';
|
|
|
|
@Controller('v1/note-categories')
|
|
@UseGuards(CombinedAuthGuard)
|
|
export class NoteCategoryController {
|
|
constructor(private readonly categoryService: NoteCategoryService) {}
|
|
|
|
@Get()
|
|
async findAll(@Request() req: any) {
|
|
return this.categoryService.findAll(req.user.id);
|
|
}
|
|
|
|
@Post()
|
|
async create(
|
|
@Request() req: any,
|
|
@Body('name') name: string,
|
|
@Body('parentId') parentId?: string,
|
|
) {
|
|
return this.categoryService.create(
|
|
req.user.id,
|
|
name,
|
|
parentId,
|
|
);
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(
|
|
@Request() req: any,
|
|
@Param('id') id: string,
|
|
@Body('name') name?: string,
|
|
@Body('parentId') parentId?: string,
|
|
) {
|
|
return this.categoryService.update(
|
|
req.user.id,
|
|
id,
|
|
name,
|
|
parentId,
|
|
);
|
|
}
|
|
|
|
@Delete(':id')
|
|
async remove(@Request() req: any, @Param('id') id: string) {
|
|
return this.categoryService.remove(req.user.id, id);
|
|
}
|
|
}
|