feat: complete backend swagger annotations, admin pages pagination, and frontend application fixes
This commit is contained in:
1 parent
24137beb32
commit
2851ef8a25
41 files changed
+478
-128
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ApiErrorResponse {
|
||||
@ApiProperty({ description: 'موفقیتآمیز بودن درخواست', example: false })
|
||||
success: boolean;
|
||||
|
||||
@ApiProperty({ description: 'پیام خطا', example: 'اطلاعات وارد شده نامعتبر است. لطفاً فرم را بررسی کنید.' })
|
||||
message: string;
|
||||
|
||||
@ApiProperty({ description: 'کد خطا', example: 'BAD_REQUEST' })
|
||||
code: string;
|
||||
|
||||
@ApiProperty({ description: 'جزئیات خطا (در صورت وجود)', required: false, example: {} })
|
||||
details?: any;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class PaginationMeta {
|
||||
@ApiProperty({ description: 'تعداد کل آیتمها', example: 100 })
|
||||
total: number;
|
||||
|
||||
@ApiProperty({ description: 'شماره صفحه فعلی', example: 1 })
|
||||
page: number;
|
||||
|
||||
@ApiProperty({ description: 'تعداد کل صفحات', example: 10 })
|
||||
lastPage: number;
|
||||
|
||||
@ApiProperty({ description: 'تعداد آیتمها در هر صفحه', example: 10 })
|
||||
limit: number;
|
||||
}
|
||||
|
||||
export class PaginatedResponse<T> {
|
||||
@ApiProperty({ description: 'آرایه آیتمها' })
|
||||
data: T[];
|
||||
|
||||
@ApiProperty({ description: 'اطلاعات صفحهبندی' })
|
||||
meta: PaginationMeta;
|
||||
}
|
||||
|
||||
export function createPaginatedSchema(dtoModel: any) {
|
||||
return {
|
||||
schema: {
|
||||
allOf: [
|
||||
{
|
||||
properties: {
|
||||
data: {
|
||||
type: 'array',
|
||||
items: { $ref: `#/components/schemas/${dtoModel.name}` },
|
||||
},
|
||||
meta: {
|
||||
$ref: '#/components/schemas/PaginationMeta',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user