Init repo
This commit is contained in:
54
src/videos/videos.controller.ts
Normal file
54
src/videos/videos.controller.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Delete,
|
||||
Body,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { videos, Prisma, EVideoSituation } from 'generated/prisma';
|
||||
|
||||
import { VideosService } from './videos.service';
|
||||
import { VideoResponseDto } from './dto/video-response.dto';
|
||||
import { PaginatedQueryDto, PaginatedResponse } from './dto/paginated.dto';
|
||||
|
||||
@Controller('videos')
|
||||
export class VideosController {
|
||||
constructor(private readonly videosService: VideosService) {}
|
||||
|
||||
@Get()
|
||||
async list(
|
||||
@Query() query: PaginatedQueryDto,
|
||||
@Query('situation') situation?: EVideoSituation,
|
||||
): Promise<PaginatedResponse<VideoResponseDto>> {
|
||||
return this.videosService.listPaginated(
|
||||
query.page,
|
||||
query.perPage,
|
||||
situation,
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async get(@Param('id') id: string): Promise<videos | null> {
|
||||
return this.videosService.get(Number(id));
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() body: Prisma.videosUpdateInput,
|
||||
): Promise<videos> {
|
||||
return this.videosService.update(Number(id), body);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') id: string): Promise<videos> {
|
||||
return this.videosService.delete(Number(id));
|
||||
}
|
||||
|
||||
@Get('situation/:s')
|
||||
async listBySituation(@Param('s') s: EVideoSituation): Promise<videos[]> {
|
||||
return this.videosService.listBySituation(s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user