feat: add pagination, sorting and filtering
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
import { Role } from '@/common/enums/roles.enum';
|
||||
import { Roles } from '@/modules/auth/decorators/roles.decorator';
|
||||
import { CreateTestDTO } from '@/modules/tests/dtos/create-test.dto';
|
||||
import { FindTestsDTO } from '@/modules/tests/dtos/find-tests.dto';
|
||||
import { UpdateTestDTO } from '@/modules/tests/dtos/update-test.dto';
|
||||
import { TestsService } from '@/modules/tests/providers/tests.service';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
|
||||
@Controller('admin/tests')
|
||||
@@ -29,8 +34,8 @@ export class AdminTestsController {
|
||||
}
|
||||
|
||||
@Get()
|
||||
public async getAllTests() {
|
||||
return await this.testsService.adminGetAll();
|
||||
public async getAllTests(@Query() query: FindTestsDTO) {
|
||||
return await this.testsService.adminGetAll(query);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@@ -45,4 +50,10 @@ export class AdminTestsController {
|
||||
) {
|
||||
return await this.testsService.updateOne(id, updateTestDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
public async deleteTestById(@Param('id', ParseIntPipe) id: number) {
|
||||
return await this.testsService.deleteOne(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user