Files
backend/src/videos/videos.controller.ts
T
Alireza HassaniandCursor d5e502cf77 Add Mellat e-payment, videos/instructions CMS, and legacy domain lookup.
Store gateway credentials per business, initiate/verify Mellat at checkout, and resolve old CMS ids from domains in the migrate modal.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 09:51:17 +03:30

121 lines
3.2 KiB
TypeScript

import {
Body,
Controller,
Delete,
Get,
Param,
Patch,
Post,
Query,
UseGuards,
} from '@nestjs/common';
import { AuthUser } from '../auth/auth.types';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { RequireBusinessPermission } from '../auth/decorators/require-business-permission.decorator';
import { BusinessPermissionGuard } from '../auth/guards/business-permission.guard';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { VideosService } from './videos.service';
import {
CreateVideoCommentDto,
CreateVideoDto,
ListPublicVideosDto,
ListVideosDto,
UpdateVideoDto,
} from './dto/video.dto';
@Controller('businesses/:businessId/videos')
@UseGuards(JwtAuthGuard, BusinessPermissionGuard)
export class VideosController {
constructor(private readonly service: VideosService) {}
@Get()
@RequireBusinessPermission('videos.read')
list(
@Param('businessId') businessId: string,
@Query() query: ListVideosDto,
@CurrentUser() user: AuthUser,
) {
return this.service.list(businessId, query, user);
}
@Get(':videoId')
@RequireBusinessPermission('videos.read')
getOne(
@Param('businessId') businessId: string,
@Param('videoId') videoId: string,
@CurrentUser() user: AuthUser,
) {
return this.service.getOne(businessId, videoId, user);
}
@Post()
@RequireBusinessPermission('videos.create')
create(
@Param('businessId') businessId: string,
@Body() dto: CreateVideoDto,
@CurrentUser() user: AuthUser,
) {
return this.service.create(businessId, dto, user);
}
@Patch(':videoId')
@RequireBusinessPermission('videos.update')
update(
@Param('businessId') businessId: string,
@Param('videoId') videoId: string,
@Body() dto: UpdateVideoDto,
@CurrentUser() user: AuthUser,
) {
return this.service.update(businessId, videoId, dto, user);
}
@Delete(':videoId')
@RequireBusinessPermission('videos.delete')
remove(
@Param('businessId') businessId: string,
@Param('videoId') videoId: string,
@CurrentUser() user: AuthUser,
) {
return this.service.remove(businessId, videoId, user);
}
@Get(':videoId/comments')
@RequireBusinessPermission('comments.read')
listComments(
@Param('businessId') businessId: string,
@Param('videoId') videoId: string,
@CurrentUser() user: AuthUser,
) {
return this.service.listCommentsAdmin(businessId, videoId, user);
}
}
@Controller('tenants/:host/videos')
export class PublicVideosController {
constructor(private readonly service: VideosService) {}
@Get()
list(@Param('host') host: string, @Query() query: ListPublicVideosDto) {
return this.service.listPublic(host, query);
}
@Get(':videoId/comments')
listComments(@Param('host') host: string, @Param('videoId') videoId: string) {
return this.service.listCommentsPublic(host, videoId);
}
@Post(':videoId/comments')
createComment(
@Param('host') host: string,
@Param('videoId') videoId: string,
@Body() dto: CreateVideoCommentDto,
) {
return this.service.createCommentPublic(host, videoId, dto);
}
@Get(':slug')
getBySlug(@Param('host') host: string, @Param('slug') slug: string) {
return this.service.getPublicBySlug(host, slug);
}
}