30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import { Controller, Get, Param, HttpStatus, Query } from '@nestjs/common';
|
|
import { BlogsService } from './blogs.service';
|
|
import { ApiTags, ApiOperation, ApiResponse, ApiOkResponse, ApiNotFoundResponse, ApiQuery } from '@nestjs/swagger';
|
|
import { PaginationDto } from '../common/dto/pagination.dto';
|
|
|
|
@ApiTags('Blogs - مجله سلامت')
|
|
@Controller('blogs')
|
|
@ApiResponse({
|
|
status: HttpStatus.INTERNAL_SERVER_ERROR,
|
|
description: 'خطای داخلی سرور'
|
|
})
|
|
export class BlogsController {
|
|
constructor(private readonly blogsService: BlogsService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'دریافت لیست مقالات مجله سلامت' })
|
|
@ApiOkResponse({ description: 'لیست مقالات منتشر شده (صفحهبندی شده)' })
|
|
findAll(@Query() query: PaginationDto) {
|
|
return this.blogsService.findAll(query);
|
|
}
|
|
|
|
@Get(':slug')
|
|
@ApiOperation({ summary: 'دریافت مقاله با اسلاگ (Slug)' })
|
|
@ApiOkResponse({ description: 'اطلاعات کامل مقاله' })
|
|
@ApiNotFoundResponse({ description: 'مقاله یافت نشد' })
|
|
findOne(@Param('slug') slug: string) {
|
|
return this.blogsService.findOneBySlug(slug);
|
|
}
|
|
}
|