WIP - scaffold approvals
This commit is contained in:
56
backend/src/approval/approval-setup.controller.ts
Normal file
56
backend/src/approval/approval-setup.controller.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user