3e86e0ffc0
- GalleryAlbum + GalleryItem models + migration (publish gate, cover image, ordered items) - GalleryModule: admin CRUD for albums + items - Member endpoints: GET /my/memories (published albums w/ cover + count), GET /my/memories/:id (album + photos) - /my/memories page: album grid with cover thumbnails - /my/memories/[id] page: photo grid with captions - Memories nav item; register GalleryModule Completes Phase 2 (Intelligence) of the member portal — Sprints 9-11. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
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);
|
|
}
|
|
}
|