158 lines
5.7 KiB
TypeScript
158 lines
5.7 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
HttpCode,
|
|
HttpStatus,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { SprintsService, SprintWithTasks } from './sprints.service';
|
|
import { ContentService } from './content.service';
|
|
import { ContentBatchesService } from './content-batches.service';
|
|
import { OutfitsService } from './outfits.service';
|
|
import { CreateSprintDto } from './dto/create-sprint.dto';
|
|
import { UpdateSprintDto } from './dto/update-sprint.dto';
|
|
import { QuerySprintDto } from './dto/query-sprint.dto';
|
|
import { CreateContentDto } from './dto/create-content.dto';
|
|
import { UpdateContentDto } from './dto/update-content.dto';
|
|
import { QueryContentDto } from './dto/query-content.dto';
|
|
import { CreateContentBatchDto } from './dto/create-content-batch.dto';
|
|
import { UpdateContentBatchDto } from './dto/update-content-batch.dto';
|
|
import { QueryContentBatchDto } from './dto/query-content-batch.dto';
|
|
import { CreateOutfitDto } from './dto/create-outfit.dto';
|
|
import { UpdateOutfitDto } from './dto/update-outfit.dto';
|
|
import { QueryOutfitDto } from './dto/query-outfit.dto';
|
|
import { Sprint } from './entities/sprint.entity';
|
|
import { ContentCalendarItem } from './entities/content-calendar-item.entity';
|
|
import { ContentBatch } from './entities/content-batch.entity';
|
|
import { Outfit } from './entities/outfit.entity';
|
|
import { PaginatedResponse } from '@common/pagination.dto';
|
|
|
|
@ApiTags('Projects')
|
|
@Controller('projects')
|
|
export class ProjectsController {
|
|
constructor(
|
|
private readonly sprintsService: SprintsService,
|
|
private readonly contentService: ContentService,
|
|
private readonly contentBatchesService: ContentBatchesService,
|
|
private readonly outfitsService: OutfitsService,
|
|
) {}
|
|
|
|
@Get('sprints')
|
|
@ApiOperation({ summary: 'List sprints with filters' })
|
|
findAllSprints(@Query() query: QuerySprintDto): Promise<PaginatedResponse<Sprint>> {
|
|
return this.sprintsService.findAll(query as QuerySprintDto & Record<string, unknown>);
|
|
}
|
|
|
|
@Get('sprints/:id')
|
|
@ApiOperation({ summary: 'Get sprint by ID with tasks' })
|
|
findOneSprint(@Param('id') id: string): Promise<SprintWithTasks> {
|
|
return this.sprintsService.findOneWithTasks(id);
|
|
}
|
|
|
|
@Post('sprints')
|
|
@ApiOperation({ summary: 'Create sprint' })
|
|
createSprint(@Body() dto: CreateSprintDto): Promise<Sprint> {
|
|
return this.sprintsService.createSprint(dto);
|
|
}
|
|
|
|
@Patch('sprints/:id')
|
|
@ApiOperation({ summary: 'Update sprint' })
|
|
updateSprint(@Param('id') id: string, @Body() dto: UpdateSprintDto): Promise<Sprint> {
|
|
return this.sprintsService.updateSprint(id, dto);
|
|
}
|
|
|
|
@Delete('sprints/:id')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Delete sprint' })
|
|
deleteSprint(@Param('id') id: string): Promise<void> {
|
|
return this.sprintsService.remove(id);
|
|
}
|
|
|
|
@Get('content')
|
|
@ApiOperation({ summary: 'List content calendar items with filters' })
|
|
findAllContent(@Query() query: QueryContentDto): Promise<PaginatedResponse<ContentCalendarItem>> {
|
|
return this.contentService.findAll(query as QueryContentDto & Record<string, unknown>);
|
|
}
|
|
|
|
@Post('content')
|
|
@ApiOperation({ summary: 'Create content calendar item' })
|
|
createContent(@Body() dto: CreateContentDto): Promise<ContentCalendarItem> {
|
|
return this.contentService.createContent(dto);
|
|
}
|
|
|
|
@Patch('content/:id')
|
|
@ApiOperation({ summary: 'Update content calendar item' })
|
|
updateContent(
|
|
@Param('id') id: string,
|
|
@Body() dto: UpdateContentDto,
|
|
): Promise<ContentCalendarItem> {
|
|
return this.contentService.updateContent(id, dto);
|
|
}
|
|
|
|
@Delete('content/:id')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Delete content calendar item' })
|
|
deleteContent(@Param('id') id: string): Promise<void> {
|
|
return this.contentService.remove(id);
|
|
}
|
|
|
|
// --- Content Batches ---
|
|
|
|
@Get('content-batches')
|
|
@ApiOperation({ summary: 'List content batches (shoot days)' })
|
|
findAllBatches(@Query() query: QueryContentBatchDto): Promise<PaginatedResponse<ContentBatch>> {
|
|
return this.contentBatchesService.findAll(query as QueryContentBatchDto & Record<string, unknown>);
|
|
}
|
|
|
|
@Post('content-batches')
|
|
@ApiOperation({ summary: 'Create content batch' })
|
|
createBatch(@Body() dto: CreateContentBatchDto): Promise<ContentBatch> {
|
|
return this.contentBatchesService.createBatch(dto);
|
|
}
|
|
|
|
@Patch('content-batches/:id')
|
|
@ApiOperation({ summary: 'Update content batch' })
|
|
updateBatch(@Param('id') id: string, @Body() dto: UpdateContentBatchDto): Promise<ContentBatch> {
|
|
return this.contentBatchesService.updateBatch(id, dto);
|
|
}
|
|
|
|
@Delete('content-batches/:id')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Delete content batch' })
|
|
deleteBatch(@Param('id') id: string): Promise<void> {
|
|
return this.contentBatchesService.remove(id);
|
|
}
|
|
|
|
// --- Outfits ---
|
|
|
|
@Get('outfits')
|
|
@ApiOperation({ summary: 'List outfits (wardrobe)' })
|
|
findAllOutfits(@Query() query: QueryOutfitDto): Promise<PaginatedResponse<Outfit>> {
|
|
return this.outfitsService.findAll(query as QueryOutfitDto & Record<string, unknown>);
|
|
}
|
|
|
|
@Post('outfits')
|
|
@ApiOperation({ summary: 'Create outfit' })
|
|
createOutfit(@Body() dto: CreateOutfitDto): Promise<Outfit> {
|
|
return this.outfitsService.createOutfit(dto);
|
|
}
|
|
|
|
@Patch('outfits/:id')
|
|
@ApiOperation({ summary: 'Update outfit' })
|
|
updateOutfit(@Param('id') id: string, @Body() dto: UpdateOutfitDto): Promise<Outfit> {
|
|
return this.outfitsService.updateOutfit(id, dto);
|
|
}
|
|
|
|
@Delete('outfits/:id')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@ApiOperation({ summary: 'Delete outfit' })
|
|
deleteOutfit(@Param('id') id: string): Promise<void> {
|
|
return this.outfitsService.remove(id);
|
|
}
|
|
}
|