57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { Body, Controller, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
|
|
import { ApprovalService } from './approval.service';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { TenantId } from '../tenant/tenant.decorator';
|
|
|
|
@Controller('setup/approvals')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class ApprovalSetupController {
|
|
constructor(private approvalService: ApprovalService) {}
|
|
|
|
@Get()
|
|
async listDefinitions(@TenantId() tenantId: string) {
|
|
return this.approvalService.listDefinitions(tenantId);
|
|
}
|
|
|
|
@Post()
|
|
async createDefinition(
|
|
@TenantId() tenantId: string,
|
|
@Body()
|
|
body: {
|
|
name: string;
|
|
description?: string;
|
|
triggerType: string;
|
|
targetObjectType?: string;
|
|
entryCriteria?: Record<string, any>;
|
|
steps?: Array<Record<string, any>>;
|
|
votingPolicy?: Record<string, any>;
|
|
rejectionRule?: string;
|
|
materialChangePolicy?: string;
|
|
isActive?: boolean;
|
|
},
|
|
) {
|
|
return this.approvalService.createDefinition(tenantId, body);
|
|
}
|
|
|
|
@Patch(':definitionId')
|
|
async updateDefinition(
|
|
@TenantId() tenantId: string,
|
|
@Param('definitionId') definitionId: string,
|
|
@Body()
|
|
body: {
|
|
name?: string;
|
|
description?: string;
|
|
triggerType?: string;
|
|
targetObjectType?: string;
|
|
entryCriteria?: Record<string, any>;
|
|
steps?: Array<Record<string, any>>;
|
|
votingPolicy?: Record<string, any>;
|
|
rejectionRule?: string;
|
|
materialChangePolicy?: string;
|
|
isActive?: boolean;
|
|
},
|
|
) {
|
|
return this.approvalService.updateDefinition(tenantId, definitionId, body);
|
|
}
|
|
}
|