File

src/services/services.controller.ts

Prefix

service

Index

Methods

Methods

deleteService
deleteService(params: IsParameterWithIdOfTable)
Decorators :
@Delete(':id')
Parameters :
Name Type Optional
params IsParameterWithIdOfTable No
Returns : any
getBlogByIdOrSlug
getBlogByIdOrSlug(params)
Decorators :
@Public()
@Get('search/:slug')
Parameters :
Name Optional
params No
Returns : any
getService
getService()
Decorators :
@Public()
@Get()
Returns : any
saveService
saveService(modelService: ServiceValidation)
Decorators :
@UseInterceptors(undefined)
@Post()
Parameters :
Name Type Optional
modelService ServiceValidation No
Returns : any
updateService
updateService(modelService: ServiceValidation, params)
Decorators :
@UseInterceptors(undefined)
@Put(':id')
Parameters :
Name Type Optional
modelService ServiceValidation No
params No
Returns : any
import { Body, Controller, Get, Param, Post, Put, UseInterceptors,Delete } from '@nestjs/common';
import { ServicesService } from './services.service';
import { FileInterceptor } from '@nestjs/platform-express';
import { ServiceValidation } from 'src/database/validation/service-validation';
import { IsParameterWithIdOfTable } from 'src/database/validation/parameter-validation';
import { Public } from 'src/auth/auth.controller';
import { ExceptionErrorMessage } from 'src/validation/exception-error';
import { SkipThrottle } from '@nestjs/throttler';

@SkipThrottle()
@Controller('service')
export class ServicesController {
    constructor(private serviceService:ServicesService){}
    
    //Exponer punto para el listado de todos los Servicios 
    @Public()
    @Get()
    getService():any{
        return this.serviceService.findAllServices();
    }

    //Exponer punto para almacenamiento de un nuevo servicio
    @UseInterceptors(FileInterceptor(''))
    @Post()
    saveService(@Body() modelService:ServiceValidation):any{
        try {
            const customer = modelService.customer;
            delete modelService.customer;
            return this.serviceService.saveService(modelService,customer);
        } catch (error) {
            ExceptionErrorMessage(error);            
        }       
    }

    //Exponer punto para actualizar un servicio mediante su id
    @UseInterceptors(FileInterceptor(''))
    @Put(':id')
    updateService(@Body() modelService:ServiceValidation, @Param() params):any{
        try {
            const customer = modelService.customer;
            delete modelService.customer;
            return this.serviceService.updateService(params.id, modelService, customer);
        } catch (error) {
            ExceptionErrorMessage(error);            
        }
    }

    //Exponer punto para remover un servicio mediante su id   
    @Delete(':id')
    deleteService(@Param() params:IsParameterWithIdOfTable){
        return this.serviceService.deleteService(params.id);
    }


    //Exponer punto para obtener un servicio mediante su slug
    @Public()
    @Get('search/:slug')
    getBlogByIdOrSlug(@Param() params):any{
      return this.serviceService.findlBySlug(params.slug);
    }
    

}

results matching ""

    No results matching ""