63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
|
|
import { Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
|
||
|
|
import { AuthGuard } from '../auth/guard/auth.guard';
|
||
|
|
import { ValidationService } from './validation.service';
|
||
|
|
import { CurrentUser } from '../auth/decorator/current-user.decorator';
|
||
|
|
import type { ActiveUserPayload } from '../auth/decorator/current-user.decorator';
|
||
|
|
|
||
|
|
@Controller('/validation')
|
||
|
|
export class ValidationController {
|
||
|
|
constructor(private readonly validationService: ValidationService) {}
|
||
|
|
|
||
|
|
@Get('/')
|
||
|
|
@UseGuards(AuthGuard)
|
||
|
|
async getValidationStatus() {
|
||
|
|
return this.validationService.getAllValidationsQueue();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Get('/:id')
|
||
|
|
@UseGuards(AuthGuard)
|
||
|
|
async getValidationById(@Param('id') id: number) {
|
||
|
|
return this.validationService.getValidationQueue(id);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Post('/:id/approve')
|
||
|
|
@UseGuards(AuthGuard)
|
||
|
|
async approveValidation(
|
||
|
|
@Param('id') id: number,
|
||
|
|
@CurrentUser() user: ActiveUserPayload,
|
||
|
|
) {
|
||
|
|
return this.validationService.approveValidation(id, user);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Post('/:id/reject')
|
||
|
|
@UseGuards(AuthGuard)
|
||
|
|
async rejectValidation(
|
||
|
|
@Param('id') id: number,
|
||
|
|
@CurrentUser() user: ActiveUserPayload,
|
||
|
|
) {
|
||
|
|
return this.validationService.rejectValidation(id, user);
|
||
|
|
}
|
||
|
|
|
||
|
|
// @Post('/')
|
||
|
|
// @UseGuards(AuthGuard)
|
||
|
|
// async storeValidationQueue(
|
||
|
|
// @Body() dataPayload: StoreValidationQueueDto,
|
||
|
|
// @CurrentUser() user: ActiveUserPayload,
|
||
|
|
// ) {
|
||
|
|
// return this.validationService.storeQueueValidation(dataPayload, user);
|
||
|
|
// }
|
||
|
|
|
||
|
|
// @Post('/process/:id')
|
||
|
|
// @UseGuards(AuthGuard)
|
||
|
|
// async processValidationQueue(
|
||
|
|
// // @Body('status') status: StoreValidationQueueDto['status'],
|
||
|
|
// // @CurrentUser() user: ActiveUserPayload,
|
||
|
|
// // @Body('id') id: string,
|
||
|
|
// @Body() data: StoreValidationQueueDto,
|
||
|
|
// @CurrentUser() user: ActiveUserPayload,
|
||
|
|
// ) {
|
||
|
|
// const { status, record_id: id } = data;
|
||
|
|
// return this.validationService.processValidationQueue(data, user);
|
||
|
|
// }
|
||
|
|
}
|