add category response dto

This commit is contained in:
Evert Prants 2023-07-22 18:37:42 +03:00
parent 878687e7ec
commit f92af930d7
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 22 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import { CreateContentRevisionDto } from './dtos/create-content-revision.dto';
import { ContentResponseDto } from './dtos/content-response.dto'; import { ContentResponseDto } from './dtos/content-response.dto';
import { ContentAssetType } from 'apps/catalog/src/enums/content-asset-type.enum'; import { ContentAssetType } from 'apps/catalog/src/enums/content-asset-type.enum';
import { lastValueFrom } from 'rxjs'; import { lastValueFrom } from 'rxjs';
import { CategoryResponseDto } from './dtos/category-response.dto';
@Controller({ @Controller({
version: '1', version: '1',
@ -40,6 +41,7 @@ export class CatalogController {
constructor(@Inject('catalog') private catalog: ClientProxy) {} constructor(@Inject('catalog') private catalog: ClientProxy) {}
@Get('categories') @Get('categories')
@ApiOkResponse({ type: CategoryResponseDto, isArray: true })
@ApiOperation({ summary: 'Get catalog categories' }) @ApiOperation({ summary: 'Get catalog categories' })
async getCatalogCategories() { async getCatalogCategories() {
return this.catalog.send('catalog.items.categories', {}); return this.catalog.send('catalog.items.categories', {});

View File

@ -0,0 +1,20 @@
import { ApiProperty } from '@nestjs/swagger';
export class CategoryContentTypeResponseDto {
@ApiProperty()
contentType: string;
}
export class CategoryResponseDto {
@ApiProperty()
id: number;
@ApiProperty()
category: string;
@ApiProperty({ type: CategoryResponseDto, isArray: true })
children: CategoryResponseDto[];
@ApiProperty({ type: CategoryContentTypeResponseDto, isArray: true })
contentTypes: CategoryContentTypeResponseDto[];
}