import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common'; import { GalleryService } from './gallery.service'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; import { RolesGuard } from '../auth/roles.guard'; import { Roles } from '../auth/roles.decorator'; import { CurrentTenantContext } from '../auth/current-tenant.decorator'; import { TenantContext } from '../../common/tenant-context'; @Controller('admin/gallery') @UseGuards(JwtAuthGuard, RolesGuard) @Roles('OWNER', 'ADMIN') export class GalleryController { constructor(private readonly service: GalleryService) {} @Get('albums') listAlbums(@CurrentTenantContext() ctx: TenantContext) { return this.service.listAlbumsAdmin(ctx.tenantId); } @Post('albums') createAlbum( @CurrentTenantContext() ctx: TenantContext, @Body() body: { title: string; description?: string; coverUrl?: string; isPublished?: boolean }, ) { return this.service.createAlbum(ctx.tenantId, ctx.adminId!, body); } @Patch('albums/:id') updateAlbum( @CurrentTenantContext() ctx: TenantContext, @Param('id') id: string, @Body() body: { title?: string; description?: string; coverUrl?: string; isPublished?: boolean }, ) { return this.service.updateAlbum(ctx.tenantId, id, body); } @Delete('albums/:id') removeAlbum(@CurrentTenantContext() ctx: TenantContext, @Param('id') id: string) { return this.service.removeAlbum(ctx.tenantId, id); } @Post('albums/:id/items') addItem( @CurrentTenantContext() ctx: TenantContext, @Param('id') id: string, @Body() body: { mediaUrl: string; caption?: string; sortOrder?: number }, ) { return this.service.addItem(ctx.tenantId, id, body); } @Delete('items/:itemId') removeItem(@CurrentTenantContext() ctx: TenantContext, @Param('itemId') itemId: string) { return this.service.removeItem(ctx.tenantId, itemId); } }