2025-12-01 04:17:47 +00:00
|
|
|
import { Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
2025-11-25 09:26:00 +00:00
|
|
|
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)
|
2025-12-01 04:17:47 +00:00
|
|
|
async getValidationStatus(
|
|
|
|
|
@Query('take') take: number,
|
|
|
|
|
@Query('skip') skip: number,
|
|
|
|
|
@Query('page') page: number,
|
|
|
|
|
@Query('orderBy') orderBy: string,
|
2025-12-01 04:22:27 +00:00
|
|
|
@Query('search') search: string,
|
2025-12-01 04:17:47 +00:00
|
|
|
@Query('order') order: 'asc' | 'desc',
|
|
|
|
|
@Query('kelompok_data') kelompok_data: string,
|
|
|
|
|
@Query('aksi') aksi: string,
|
|
|
|
|
@Query('status') status: string,
|
|
|
|
|
) {
|
|
|
|
|
const queryParams = {
|
|
|
|
|
take,
|
|
|
|
|
skip,
|
|
|
|
|
page,
|
|
|
|
|
orderBy,
|
2025-12-01 04:22:27 +00:00
|
|
|
search,
|
2025-12-01 04:17:47 +00:00
|
|
|
order,
|
|
|
|
|
kelompok_data,
|
|
|
|
|
aksi,
|
|
|
|
|
status,
|
|
|
|
|
};
|
|
|
|
|
return this.validationService.getAllValidationsQueue(queryParams);
|
2025-11-25 09:26:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
// }
|
|
|
|
|
}
|