|
1
|
4 |
|
import { ApiProperty } from '@nestjs/swagger'; |
|
2
|
4 |
|
import { IsNumber, IsUUID, ValidateNested, IsArray } from 'class-validator'; |
|
3
|
4 |
|
import { Type } from 'class-transformer'; |
|
4
|
4 |
|
import { UpdateBicycleDto } from './update-bicycle.dto'; |
|
5
|
|
|
import { BicycleBatchResponse } from '../types/BicycleBatchResponse'; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
4 |
|
export class UpdateBicycleWithIdDto extends UpdateBicycleDto { |
|
8
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
9
|
|
|
description: 'Unique identifier of the bicycle', |
|
|
|
|
|
|
10
|
|
|
example: '123e4567-e89b-12d3-a456-426614174000', |
|
|
|
|
|
|
11
|
|
|
required: true, |
|
|
|
|
|
|
12
|
|
|
}) |
|
|
|
|
|
|
13
|
|
|
@IsUUID() |
|
|
|
|
|
|
14
|
4 |
|
id: string; |
|
|
|
|
|
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
4 |
|
export class BicyclePositionDto { |
|
18
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
19
|
|
|
description: 'Unique identifier of the bicycle', |
|
|
|
|
|
|
20
|
|
|
example: '123e4567-e89b-12d3-a456-426614174000', |
|
|
|
|
|
|
21
|
|
|
required: true, |
|
|
|
|
|
|
22
|
|
|
}) |
|
|
|
|
|
|
23
|
|
|
@IsUUID() |
|
|
|
|
|
|
24
|
4 |
|
id: string; |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
27
|
|
|
description: 'Latitude coordinate of the bicycle', |
|
|
|
|
|
|
28
|
|
|
example: 59.3293, |
|
|
|
|
|
|
29
|
|
|
type: Number, |
|
|
|
|
|
|
30
|
|
|
required: true, |
|
|
|
|
|
|
31
|
|
|
}) |
|
|
|
|
|
|
32
|
|
|
@IsNumber() |
|
|
|
|
|
|
33
|
4 |
|
latitude: number; |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
36
|
|
|
description: 'Longitude coordinate of the bicycle', |
|
|
|
|
|
|
37
|
|
|
example: 18.0686, |
|
|
|
|
|
|
38
|
|
|
type: Number, |
|
|
|
|
|
|
39
|
|
|
required: true, |
|
|
|
|
|
|
40
|
|
|
}) |
|
|
|
|
|
|
41
|
|
|
@IsNumber() |
|
|
|
|
|
|
42
|
4 |
|
longitude: number; |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
4 |
|
export class BatchUpdateBicyclePositionsDto { |
|
46
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
47
|
|
|
description: 'Array of bicycle position updates', |
|
|
|
|
|
|
48
|
|
|
type: [BicyclePositionDto], |
|
|
|
|
|
|
49
|
|
|
required: true, |
|
|
|
|
|
|
50
|
|
|
}) |
|
|
|
|
|
|
51
|
|
|
@IsArray() |
|
|
|
|
|
|
52
|
|
|
@ValidateNested({ each: true }) |
|
|
|
|
|
|
53
|
|
|
@Type(() => BicyclePositionDto) |
|
|
|
|
|
|
54
|
4 |
|
updates: BicyclePositionDto[]; |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
4 |
|
export class BicycleBatchResponseItem { |
|
58
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
59
|
|
|
description: 'Unique identifier of the bicycle', |
|
|
|
|
|
|
60
|
|
|
example: '123e4567-e89b-12d3-a456-426614174000', |
|
|
|
|
|
|
61
|
|
|
}) |
|
|
|
|
|
|
62
|
4 |
|
id: string; |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
65
|
|
|
description: 'Whether the update was successful', |
|
|
|
|
|
|
66
|
|
|
example: true, |
|
|
|
|
|
|
67
|
|
|
}) |
|
|
|
|
|
|
68
|
4 |
|
success: boolean; |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
71
|
|
|
description: 'Error message if the update failed', |
|
|
|
|
|
|
72
|
|
|
example: 'Bicycle not found', |
|
|
|
|
|
|
73
|
|
|
required: false, |
|
|
|
|
|
|
74
|
|
|
}) |
|
|
|
|
|
|
75
|
4 |
|
error?: string; |
|
|
|
|
|
|
76
|
|
|
} |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
4 |
|
export class BicycleBatchResponseDto { |
|
80
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
81
|
|
|
type: [BicycleBatchResponseItem], |
|
|
|
|
|
|
82
|
|
|
description: 'Array of update results', |
|
|
|
|
|
|
83
|
|
|
}) |
|
|
|
|
|
|
84
|
4 |
|
results: BicycleBatchResponseItem[]; |
|
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
87
|
|
|
description: 'Total number of updates attempted', |
|
|
|
|
|
|
88
|
|
|
example: 10, |
|
|
|
|
|
|
89
|
|
|
}) |
|
|
|
|
|
|
90
|
4 |
|
totalCount: number; |
|
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
93
|
|
|
description: 'Number of successful updates', |
|
|
|
|
|
|
94
|
|
|
example: 8, |
|
|
|
|
|
|
95
|
|
|
}) |
|
|
|
|
|
|
96
|
4 |
|
successCount: number; |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
@ApiProperty({ |
|
|
|
|
|
|
99
|
|
|
description: 'Number of failed updates', |
|
|
|
|
|
|
100
|
|
|
example: 2, |
|
|
|
|
|
|
101
|
|
|
}) |
|
|
|
|
|
|
102
|
|
|
failureCount: number; |
|
|
|
|
|
|
103
|
|
|
} |
|
|
|
|
|