52 lines
1.7 KiB
Markdown
52 lines
1.7 KiB
Markdown
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
Param,
|
|
ParseIntPipe,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
|
|
|
import { RfaService } from './rfa.service';
|
|
import { CreateRfaDto } from './dto/create-rfa.dto';
|
|
import { WorkflowActionDto } from '../correspondence/dto/workflow-action.dto'; // Reuse DTO
|
|
import { User } from '../user/entities/user.entity';
|
|
|
|
import { JwtAuthGuard } from '../../common/auth/guards/jwt-auth.guard';
|
|
import { RbacGuard } from '../../common/auth/guards/rbac.guard';
|
|
import { RequirePermission } from '../../common/decorators/require-permission.decorator';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
|
|
@ApiTags('RFA (Request for Approval)')
|
|
@ApiBearerAuth()
|
|
@UseGuards(JwtAuthGuard, RbacGuard)
|
|
@Controller('rfas')
|
|
export class RfaController {
|
|
constructor(private readonly rfaService: RfaService) {}
|
|
|
|
// ... (Create, FindOne endpoints) ...
|
|
|
|
@Post(':id/submit')
|
|
@ApiOperation({ summary: 'Submit RFA to Workflow' })
|
|
@RequirePermission('rfa.create') // ผู้สร้างมีสิทธิ์ส่ง
|
|
submit(
|
|
@Param('id', ParseIntPipe) id: number,
|
|
@Body('templateId', ParseIntPipe) templateId: number, // รับ Template ID
|
|
@CurrentUser() user: User,
|
|
) {
|
|
return this.rfaService.submit(id, templateId, user);
|
|
}
|
|
|
|
@Post(':id/action')
|
|
@ApiOperation({ summary: 'Process Workflow Action (Approve/Reject)' })
|
|
@RequirePermission('workflow.action_review') // สิทธิ์ในการ Approve/Review
|
|
processAction(
|
|
@Param('id', ParseIntPipe) id: number,
|
|
@Body() actionDto: WorkflowActionDto,
|
|
@CurrentUser() user: User,
|
|
) {
|
|
return this.rfaService.processAction(id, actionDto, user);
|
|
}
|
|
} |