import { Body , Controller , Get , Post , UseGuards , Put , Query , ParseBoolPipe , } from '@nestjs/common' ; import { ApiBadRequestResponse , ApiCreatedResponse , ApiOperation , ApiOkResponse , ApiTags , ApiBearerAuth , } from '@nestjs/swagger' ; import { CreateArticleDto } from './dto/create-article.dto' ; import { ArticlesService } from './articles.service' ; import { Article } from './article.entity' ; import { JwtAuthGuard } from '../auth/jwt-auth.guard' ; import { GetAllArticlesQueryParams } from './dto/get-all-articles-query.dto' ; import { UnitsService } from './units.service' ; import { GetAllUnitsQueryParams } from './dto/get-all-units-query.dto' ; import { Unit } from './unit.entity' ; @ ApiBearerAuth ( ) @ Controller ( 'article' ) @ ApiTags ( 'Articles' ) @ UseGuards ( JwtAuthGuard ) @ ApiBadRequestResponse ( { description : 'Bad Request' } ) export class ArticlesController { constructor ( private readonly articlesService , private readonly unitsService ) { } @ Post ( '/articles' ) @ ApiOperation ( { summary : 'Create an article' } ) @ ApiCreatedResponse ( { description : 'Created' , type : Article } ) async insertOne ( @ Body ( ) createArticleDto ) { return this . articlesService . createArticle ( createArticleDto ) ; } @ Get ( '/articles' ) @ ApiOperation ( { summary : 'List articles' } ) @ ApiOkResponse ( { description : 'All existing articles' , type : [ Article ] , } ) findAll ( @ Query ( ) query ) { return this . articlesService . findAll ( query ) ; } @ Get ( '/units' ) @ ApiOperation ( { summary : 'Get a list of units' } ) async getUnits ( @ Query ( ) getUnitsDto ) { return this . unitsService . getUnits ( getUnitsDto ) ; } }