71 lines
1.9 KiB
TypeScript
71 lines
1.9 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Put,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
Query,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { VideosService } from './videos.service';
|
|
import { CreateVideoDto } from './dto/create-video.dto';
|
|
import { GetVideosQueryDto } from './dto/get-videos-query.dto';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import {
|
|
ApiTags,
|
|
ApiOperation,
|
|
ApiQuery,
|
|
ApiBearerAuth,
|
|
} from '@nestjs/swagger';
|
|
|
|
@ApiTags('Videos - مشاوره ویدئویی و آکادمی')
|
|
@Controller('videos')
|
|
export class VideosController {
|
|
constructor(private readonly videosService: VideosService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'دریافت لیست ویدئوها (عمومی)' })
|
|
@ApiQuery({ name: 'page', required: false })
|
|
@ApiQuery({ name: 'limit', required: false })
|
|
@ApiQuery({ name: 'search', required: false })
|
|
@ApiQuery({ name: 'featured', required: false })
|
|
findAll(@Query() query: GetVideosQueryDto) {
|
|
return this.videosService.findAll(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'دریافت جزئیات یک ویدئو' })
|
|
findOne(@Param('id') id: string) {
|
|
return this.videosService.findOne(id);
|
|
}
|
|
|
|
@Post()
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@ApiOperation({ summary: 'افزودن ویدئوی جدید (ادمین)' })
|
|
create(@Body() createVideoDto: CreateVideoDto) {
|
|
return this.videosService.create(createVideoDto);
|
|
}
|
|
|
|
@Put(':id')
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@ApiOperation({ summary: 'ویرایش ویدئو (ادمین)' })
|
|
update(
|
|
@Param('id') id: string,
|
|
@Body() updateVideoDto: Partial<CreateVideoDto>,
|
|
) {
|
|
return this.videosService.update(id, updateVideoDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@UseGuards(JwtAuthGuard)
|
|
@ApiBearerAuth()
|
|
@ApiOperation({ summary: 'حذف ویدئو (ادمین)' })
|
|
remove(@Param('id') id: string) {
|
|
return this.videosService.remove(id);
|
|
}
|
|
}
|