63 lines
1.2 KiB
TypeScript
63 lines
1.2 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
HttpStatus,
|
|
Param,
|
|
ParseIntPipe,
|
|
} from '@nestjs/common';
|
|
import { TestsService } from './providers/tests.service';
|
|
import { Public } from '../auth/decorators/public.decorator';
|
|
import { ApiAppResponse } from '@/common/decorators/api-app-response.decorator';
|
|
import { GetTestByIdDTO } from './dtos/responses/get-test-by-id.dto';
|
|
|
|
@Controller('tests')
|
|
export class TestsController {
|
|
constructor(
|
|
/**
|
|
* Inject Tests Service
|
|
*/
|
|
private readonly testsService: TestsService,
|
|
) {}
|
|
|
|
@Public()
|
|
@Get()
|
|
@ApiAppResponse([
|
|
{
|
|
status: HttpStatus.OK,
|
|
variants: [
|
|
{
|
|
isArray: true,
|
|
model: GetTestByIdDTO,
|
|
},
|
|
],
|
|
},
|
|
])
|
|
public async getAllTests() {
|
|
return await this.testsService.userGetAll();
|
|
}
|
|
|
|
@Public()
|
|
@Get(':id')
|
|
@ApiAppResponse([
|
|
{
|
|
status: HttpStatus.OK,
|
|
variants: [
|
|
{
|
|
model: GetTestByIdDTO,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
status: HttpStatus.NOT_FOUND,
|
|
variants: [
|
|
{
|
|
messageExample: 'تست مورد نظر یافت نشد.',
|
|
},
|
|
],
|
|
},
|
|
])
|
|
public async getTestById(@Param('id', ParseIntPipe) id: number) {
|
|
return await this.testsService.userGetOne(id);
|
|
}
|
|
}
|