src/testimonials/testimonials.controller.ts
testimonial
Methods |
deletePartNership | ||||||
deletePartNership(params: IsParameterWithIdOfTable)
|
||||||
Decorators :
@Delete(':id')
|
||||||
Parameters :
Returns :
any
|
getCategory |
getCategory()
|
Decorators :
@Get()
|
Returns :
any
|
Async getThreeRandomsPartnership |
getThreeRandomsPartnership()
|
Decorators :
@Public()
|
Returns :
Promise<any>
|
saveCategory | ||||||
saveCategory(modelCategory: TestimoialValidation)
|
||||||
Decorators :
@UseInterceptors(undefined)
|
||||||
Parameters :
Returns :
any
|
updateCategory | |||||||||
updateCategory(modelCategory: TestimoialValidation, params)
|
|||||||||
Decorators :
@UseInterceptors(undefined)
|
|||||||||
Parameters :
Returns :
any
|
import { Body, Controller, Get, Param, Post, Put, UseInterceptors, Delete } from '@nestjs/common';
import { TestimonialsService } from './testimonials.service';
import { FileInterceptor } from '@nestjs/platform-express';
import { TestimoialValidation } from 'src/database/validation/testimonial-validation';
import { IsParameterWithIdOfTable } from 'src/database/validation/parameter-validation';
import { generateRandomnumber } from 'src/utils/utils';
import { Public } from 'src/auth/auth.controller';
import { SkipThrottle } from '@nestjs/throttler';
@SkipThrottle()
@Controller('testimonial')
export class TestimonialsController {
constructor(private testimonialService:TestimonialsService){}
//Exponer punto para el listado de todas los testimonios
@Get()
getCategory():any{
return this.testimonialService.findAllTestimonials();
}
//Exponer punto para almacenamiento de un nuevo testimonio
@UseInterceptors(FileInterceptor(''))
@Post()
saveCategory(@Body() modelCategory:TestimoialValidation):any{
return this.testimonialService.saveTestimonial(modelCategory);
}
//Exponer punto para actualizar un testimonio mediante su id
@UseInterceptors(FileInterceptor(''))
@Put(':id')
updateCategory(@Body() modelCategory:TestimoialValidation, @Param() params):any{
return this.testimonialService.updateTestimonial(params.id, modelCategory);
}
//Exponer punto para remover un testimonio mediante su id
@Delete(':id')
deletePartNership(@Param() params:IsParameterWithIdOfTable){
return this.testimonialService.deleteTestimonial(params.id);
}
//Exponer punto para obtener 2 registros aleatorios
@Public()
@Get('random')
async getThreeRandomsPartnership():Promise<any>{
/*const totalRows = await this.testimonialService.getTotalRows();
const aleatoryRows = generateRandomnumber(totalRows,2)
return this.testimonialService.getTwoRandomRows(aleatoryRows)*/
return this.testimonialService.findAllTestimonials();
}
}