import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Post,
  Query,
} from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ExcludePrivilege, Public } from 'src/core/guards';
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import { CreateReportExportDto } from '../shared/dto/report-export.create.dto';
import {
  GetReportExportDto,
  GetReportExportFileNameDto,
  GetReportExportProcessingDto,
} from '../shared/dto/report-export.get.dto';
import { ReportExportService } from './report-export.service';

@ApiTags(`${MODULE_NAME.REPORT_EXPORT.split('-').join(' ')}`)
@Controller(`v1/${MODULE_NAME.REPORT_EXPORT}`)
@Public(false)
@ApiBearerAuth('JWT')
export class ReportExportController {
  constructor(private service: ReportExportService) {}

  @Post()
  @ExcludePrivilege()
  async create(@Body() body: CreateReportExportDto) {
    await this.service.create(body);
    return { message: 'Processing request export data.' };
  }

  @Get()
  @ExcludePrivilege()
  async getAll(@Query() query: GetReportExportDto) {
    return await this.service.getAll(query);
  }

  @Delete(':id')
  @ExcludePrivilege()
  async delete(@Param('id') id: string) {
    return await this.service.delete(id);
  }

  @Get('processing')
  @ExcludePrivilege()
  async getAllProcessing(@Query() query: GetReportExportProcessingDto) {
    return await this.service.getAllProcessing(query);
  }

  @Get('filename-history')
  @ExcludePrivilege()
  async getListHistoryFileName(@Query() query: GetReportExportFileNameDto) {
    return await this.service.getListHistoryFileName(query);
  }
}
