File

src/module/excel/excel.controller.ts

Prefix

excel

Index

Methods

Methods

Async getCredentialsXLSX
getCredentialsXLSX(res: Response)
Decorators :
@Get('/credentials')
@HttpCode(HttpStatus.OK)
@UseGuards(HasRoleGuard)
Parameters :
Name Type Optional
res Response No
Returns : Promise<void>
Async getScheinStatusCSV
getScheinStatusCSV(res: Response)
Decorators :
@Get('/schein-information')
@HttpCode(HttpStatus.OK)
@UseGuards(HasRoleGuard)
Parameters :
Name Type Optional
res Response No
Returns : Promise<void>
Async getTutorialXLSX
getTutorialXLSX(id: string, res: Response)
Decorators :
@Get('/tutorial/:id')
@UseGuards(TutorialGuard)
@AllowCorrectors()
Parameters :
Name Type Optional
id string No
res Response No
Returns : Promise<void>
Async parseCSV
parseCSV(body: ParseCsvDTO)
Decorators :
@Post('/parseCSV')
@HttpCode(HttpStatus.OK)
@UseGuards(HasRoleGuard)
@Roles(Role.ADMIN, Role.EMPLOYEE, Role.TUTOR)
@UsePipes(ValidationPipe)
Parameters :
Name Type Optional
body ParseCsvDTO No
import {
    Body,
    Controller,
    Get,
    HttpCode,
    HttpStatus,
    Param,
    Post,
    Res,
    UseGuards,
    UsePipes,
    ValidationPipe,
} from '@nestjs/common';
import { Response } from 'express';
import { ParseCsvResult } from 'shared/model/CSV';
import { Role } from 'shared/model/Role';
import { AllowCorrectors } from '../../guards/decorators/allowCorrectors.decorator';
import { Roles } from '../../guards/decorators/roles.decorator';
import { HasRoleGuard } from '../../guards/has-role.guard';
import { TutorialGuard } from '../../guards/tutorial.guard';
import { ParseCsvDTO } from './excel.dto';
import { ExcelService } from './excel.service';

@Controller('excel')
export class ExcelController {
    constructor(private readonly excelService: ExcelService) {}

    @Get('/tutorial/:id')
    @UseGuards(TutorialGuard)
    @AllowCorrectors()
    async getTutorialXLSX(@Param('id') id: string, @Res() res: Response): Promise<void> {
        const buffer = await this.excelService.generateTutorialBackup(id);

        res.contentType('xlsx');
        res.send(buffer);
    }

    @Post('/parseCSV')
    @HttpCode(HttpStatus.OK)
    @UseGuards(HasRoleGuard)
    @Roles(Role.ADMIN, Role.EMPLOYEE, Role.TUTOR)
    @UsePipes(ValidationPipe)
    async parseCSV(@Body() body: ParseCsvDTO): Promise<ParseCsvResult<unknown>> {
        return await this.excelService.parseCSV(body);
    }

    @Get('/schein-information')
    @HttpCode(HttpStatus.OK)
    @UseGuards(HasRoleGuard)
    async getScheinStatusCSV(@Res() res: Response): Promise<void> {
        const buffer = await this.excelService.generateScheinstatusTable();

        res.contentType('xlsx');
        res.send(buffer);
    }

    @Get('/credentials')
    @HttpCode(HttpStatus.OK)
    @UseGuards(HasRoleGuard)
    async getCredentialsXLSX(@Res() res: Response): Promise<void> {
        const buffer = await this.excelService.generateCredentialsXLSX();

        res.contentType('xlsx');
        res.send(buffer);
    }
}

results matching ""

    No results matching ""