feat: add swagger docs

This commit is contained in:
Ahmed Bouhuolia
2025-06-16 15:53:00 +02:00
parent c4668d7d22
commit e057b4e2f0
22 changed files with 3532 additions and 13 deletions

View File

@@ -1,4 +1,9 @@
import { ApiOperation } from '@nestjs/swagger';
import {
ApiOperation,
ApiResponse,
ApiExtraModels,
getSchemaPath,
} from '@nestjs/swagger';
import { ApiTags } from '@nestjs/swagger';
import { Controller, Put, Get, Body, Param } from '@nestjs/common';
import { TransactionsLockingService } from './commands/CommandTransactionsLockingService';
@@ -9,9 +14,11 @@ import {
CancelTransactionsLockingDto,
TransactionsLockingDto,
} from './dtos/TransactionsLocking.dto';
import { TransactionLockingResponseDto } from './dtos/TransactionLockingResponse.dto';
@Controller('transactions-locking')
@ApiTags('Transactions Locking')
@ApiExtraModels(TransactionLockingResponseDto)
export class TransactionsLockingController {
constructor(
private readonly transactionsLockingService: TransactionsLockingService,
@@ -22,6 +29,13 @@ export class TransactionsLockingController {
@ApiOperation({
summary: 'Lock all transactions for a module or all modules',
})
@ApiResponse({
status: 200,
description: 'The transactions have been successfully locked.',
schema: {
$ref: getSchemaPath(TransactionLockingResponseDto),
},
})
async commandTransactionsLocking(
@Body('module') module: TransactionsLockingGroup,
@Body() transactionLockingDTO: TransactionsLockingDto,
@@ -41,6 +55,13 @@ export class TransactionsLockingController {
@ApiOperation({
summary: 'Cancel all transactions locking for a module or all modules',
})
@ApiResponse({
status: 200,
description: 'The transactions locking has been successfully canceled.',
schema: {
$ref: getSchemaPath(TransactionLockingResponseDto),
},
})
async cancelTransactionLocking(
@Body('module') module: TransactionsLockingGroup,
@Body() cancelLockingDTO: CancelTransactionsLockingDto,
@@ -60,6 +81,13 @@ export class TransactionsLockingController {
summary:
'Partial unlock all transactions locking for a module or all modules',
})
@ApiResponse({
status: 200,
description: 'The transactions have been successfully partially unlocked.',
schema: {
$ref: getSchemaPath(TransactionLockingResponseDto),
},
})
async unlockTransactionsLockingBetweenPeriod(
@Body('module') module: TransactionsLockingGroup,
@Body() unlockDTO: ITransactionLockingPartiallyDTO,
@@ -80,6 +108,14 @@ export class TransactionsLockingController {
summary:
'Cancel partial unlocking all transactions locking for a module or all modules',
})
@ApiResponse({
status: 200,
description:
'The partial transaction unlocking has been successfully canceled.',
schema: {
$ref: getSchemaPath(TransactionLockingResponseDto),
},
})
async cancelPartialUnlocking(
@Body('module') module: TransactionsLockingGroup,
) {
@@ -95,12 +131,28 @@ export class TransactionsLockingController {
@Get('/')
@ApiOperation({ summary: 'Get all transactions locking meta' })
@ApiResponse({
status: 200,
description:
'The transactions locking meta has been successfully retrieved.',
schema: {
$ref: getSchemaPath(TransactionLockingResponseDto),
},
})
async getTransactionLockingMetaList() {
return await this.queryTransactionsLocking.getTransactionsLockingList();
}
@Get(':module')
@ApiOperation({ summary: 'Get transactions locking meta for a module' })
@ApiResponse({
status: 200,
description:
'The module transactions locking meta has been successfully retrieved.',
schema: {
$ref: getSchemaPath(TransactionLockingResponseDto),
},
})
async getTransactionLockingMeta(@Param('module') module: string) {
return await this.queryTransactionsLocking.getTransactionsLockingModuleMeta(
module as TransactionsLockingGroup,

View File

@@ -0,0 +1,51 @@
import { ApiProperty } from '@nestjs/swagger';
export class TransactionLockingResponseDto {
@ApiProperty({
description: 'Indicates whether transaction locking is enabled',
example: true,
})
isEnabled: boolean;
@ApiProperty({
description: 'Indicates whether partial unlock is enabled',
example: false,
})
isPartialUnlock: boolean;
@ApiProperty({
description: 'The date until which transactions are locked',
example: '2024-12-31',
})
lockToDate: Date;
@ApiProperty({
description: 'The start date of the unlock period',
example: '2025-01-01',
})
unlockFromDate: string;
@ApiProperty({
description: 'The end date of the unlock period',
example: '2025-01-31',
})
unlockToDate: string;
@ApiProperty({
description: 'The reason for locking transactions',
example: 'Year-end closing',
})
lockReason: string;
@ApiProperty({
description: 'The reason for unlocking transactions',
example: 'New fiscal year',
})
unlockReason: string;
@ApiProperty({
description: 'The reason for partial unlock of transactions',
example: 'Special adjustment period',
})
partialUnlockReason: string;
}