Stage M1
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import type { Collection, Locale } from '@sport/types';
|
||||
|
||||
import { Public } from '@/common/decorators/public.decorator';
|
||||
import { RequestLocale } from '@/common/i18n';
|
||||
|
||||
import { CollectionsService } from './collections.service';
|
||||
|
||||
@ApiTags('catalog')
|
||||
@Controller('collections')
|
||||
export class CollectionsController {
|
||||
constructor(private readonly collectionsService: CollectionsService) {}
|
||||
|
||||
@Public()
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'List live collections' })
|
||||
@ApiQuery({ name: 'locale', required: false, enum: ['vi', 'en'] })
|
||||
list(@RequestLocale() locale: Locale): Promise<Collection[]> {
|
||||
return this.collectionsService.list(locale);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get(':slug')
|
||||
@ApiOperation({ summary: 'Get one collection by slug' })
|
||||
@ApiQuery({ name: 'locale', required: false, enum: ['vi', 'en'] })
|
||||
getBySlug(@Param('slug') slug: string, @RequestLocale() locale: Locale): Promise<Collection> {
|
||||
return this.collectionsService.getBySlug(slug, locale);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user