-
Notifications
You must be signed in to change notification settings - Fork 3
Implementar Endpoint V2 de Relatórios com Paginação Contada e Baseada em Token #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: homol
Are you sure you want to change the base?
Changes from all commits
6c65899
7c80d23
c8dc071
57906f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,52 @@ | ||||||||||||||||
| import { ApiProperty } from '@nestjs/swagger'; | ||||||||||||||||
| import { FonteRelatorio, RelatorioVisibilidade, TipoRelatorio } from '@prisma/client'; | ||||||||||||||||
| import { Transform, TransformFnParams } from 'class-transformer'; | ||||||||||||||||
| import { IsDateString, IsEnum, IsInt, IsOptional, IsString, Max, Min } from 'class-validator'; | ||||||||||||||||
|
|
||||||||||||||||
| export class FilterRelatorioV2Dto { | ||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @ApiProperty({ description: 'ID do PDM para filtrar relatórios', required: false }) | ||||||||||||||||
| @IsInt() | ||||||||||||||||
| @Transform(({ value }: TransformFnParams) => (value === '' || value == null ? undefined : +value)) | ||||||||||||||||
| pdm_id?: number; | ||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @ApiProperty({ enum: FonteRelatorio, enumName: 'FonteRelatorio' }) | ||||||||||||||||
| @IsEnum(FonteRelatorio) | ||||||||||||||||
| fonte?: FonteRelatorio; | ||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @ApiProperty({ enum: TipoRelatorio, enumName: 'TipoRelatorio' }) | ||||||||||||||||
| @IsEnum(TipoRelatorio) | ||||||||||||||||
| tipo?: TipoRelatorio; | ||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @ApiProperty({ enum: RelatorioVisibilidade, enumName: 'RelatorioVisibilidade' }) | ||||||||||||||||
| @IsEnum(RelatorioVisibilidade) | ||||||||||||||||
| visibilidade?: RelatorioVisibilidade; | ||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @IsDateString() | ||||||||||||||||
| criado_em_de?: string; | ||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @IsDateString() | ||||||||||||||||
| criado_em_ate?: string; | ||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @IsString() | ||||||||||||||||
| token_paginacao?: string; | ||||||||||||||||
|
Comment on lines
+36
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add API documentation for pagination token. The pagination token field is missing Apply this diff to add API documentation: @IsOptional()
+@ApiProperty({ description: 'Token de paginação JWT para continuação', required: false })
@IsString()
token_paginacao?: string;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @IsInt() | ||||||||||||||||
| @Min(1) | ||||||||||||||||
| @Transform((a: TransformFnParams) => (a.value === '' ? 1 : +a.value)) | ||||||||||||||||
| pagina?: number = 1; | ||||||||||||||||
|
|
||||||||||||||||
| @IsOptional() | ||||||||||||||||
| @IsInt() | ||||||||||||||||
| @Max(500) | ||||||||||||||||
| @Min(1) | ||||||||||||||||
| @Transform((a: TransformFnParams) => (a.value === '' ? 25 : +a.value)) | ||||||||||||||||
| ipp?: number = 25; | ||||||||||||||||
|
Comment on lines
+40
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add API documentation and clarify default value handling. The pagination parameters need improvements:
Apply this diff to improve the implementation: @IsOptional()
+@ApiProperty({ description: 'Número da página', minimum: 1, default: 1, required: false })
@IsInt()
@Min(1)
@Transform((a: TransformFnParams) => (a.value === '' ? 1 : +a.value))
-pagina?: number = 1;
+pagina?: number;
@IsOptional()
+@ApiProperty({ description: 'Itens por página', minimum: 1, maximum: 500, default: 25, required: false })
@IsInt()
@Max(500)
@Min(1)
@Transform((a: TransformFnParams) => (a.value === '' ? 25 : +a.value))
-ipp?: number = 25;
+ipp?: number;
🤖 Prompt for AI Agents |
||||||||||||||||
| } | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add API documentation for date fields.
The date fields are missing
@ApiPropertydecorators for consistency with other fields and proper API documentation.Apply this diff to add API documentation:
Consider adding business logic validation to ensure
criado_em_de <= criado_em_atein the service layer.🤖 Prompt for AI Agents