-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.json
More file actions
1851 lines (1850 loc) · 81.7 KB
/
swagger.json
File metadata and controls
1851 lines (1850 loc) · 81.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"openapi": "3.0.3",
"info": {
"title": "EVM Dealer Management API",
"version": "1.0.0",
"description": "EVDMS SYSTEMS"
},
"servers": [
{ "url": "http://localhost:5000", "description": "Development server" },
{ "url": "/", "description": "Current server" }
],
"security": [{ "bearerAuth": [] }],
"tags": [
{ "name": "Auth", "description": "Authentication endpoints - Role: Admin, DealerManager" },
{ "name": "VehicleModels", "description": "Vehicle model management - Role: EVMStaff, Admin" },
{ "name": "VehicleVariants", "description": "Vehicle variant management - Role: EVMStaff, Admin" },
{ "name": "VehicleColors", "description": "Vehicle color management - Role: EVMStaff, Admin" },
{ "name": "Inventory", "description": "Inventory management - Role: DealerStaff (read), DealerManager, EVMStaff, Admin" },
{ "name": "Promotions", "description": "Promotion management - Role: DealerStaff (read), EVMStaff, Admin" },
{ "name": "Customers", "description": "Customer management - Role: DealerStaff, DealerManager, Admin" },
{ "name": "TestDrives", "description": "Test drive booking - Role: DealerStaff, DealerManager, Admin" },
{ "name": "Quotes", "description": "Quote management - Role: DealerStaff, DealerManager, Admin" },
{ "name": "Orders", "description": "Order management - Role: DealerStaff, DealerManager, Admin" },
{ "name": "Contracts", "description": "Contract management - Role: DealerStaff, DealerManager, Admin" },
{ "name": "Payments", "description": "Payment management - Role: DealerStaff, DealerManager, Admin" },
{ "name": "Dealers", "description": "Dealer management - Role: DealerManager, EVMStaff, Admin" },
{ "name": "Reports", "description": "Reports and analytics - Role: DealerManager, EVMStaff, Admin" },
{ "name": "Deliveries", "description": "Quản lý giao xe - DealerStaff tạo, DealerManager cập nhật" },
{ "name": "Feedbacks", "description": "Phản hồi khách hàng - DealerStaff tạo, DealerManager xem/cập nhật" },
{ "name": "Dashboard", "description": "Tổng quan hệ thống" },
{ "name": "Users", "description": "Quản trị tài khoản" }
],
"paths": {
"/api/auth/login": {
"post": {
"tags": ["Auth"],
"summary": "Đăng nhập người dùng",
"description": "Đăng nhập bằng email và mật khẩu. Trả về access token và refresh token.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"email": { "type": "string", "example": "admin@evms.com" },
"password": { "type": "string", "example": "123456" }
},
"required": ["email", "password"]
}
}
}
},
"responses": {
"200": {
"description": "Login successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": { "type": "string", "example": "Login successful" },
"token": { "type": "string", "description": "JWT access token (valid for 1 day)" },
"refreshToken": { "type": "string", "description": "JWT refresh token (valid for 7 days)" },
"user": {
"type": "object",
"properties": {
"_id": { "type": "string" },
"email": { "type": "string" },
"role": { "type": "string" },
"profile": { "type": "object" },
"dealer": { "type": "string" }
}
}
}
}
}
}
},
"401": { "description": "Invalid credentials" },
"500": { "description": "Server error" }
},
"security": []
}
},
"/api/auth/refresh": {
"post": {
"tags": ["Auth"],
"summary": "Làm mới access token",
"description": "Tạo mới access token và refresh token từ refresh token hợp lệ",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"refreshToken": { "type": "string", "description": "Valid refresh token", "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }
},
"required": ["refreshToken"],
"example": {
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4ZjkwZWJlYmVhZWY3MmVjZjZlMDA1YSIsInJvbGUiOiJBZG1pbiIsInR5cGUiOiJyZWZyZXNoIiwiaWF0IjoxNzE2NTY3ODkzLCJleHAiOjE3MTcxNzI2OTN9..."
}
}
}
}
},
"responses": {
"200": {
"description": "Token refreshed successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": { "type": "string", "example": "Token refreshed successfully" },
"token": { "type": "string", "description": "New JWT access token" },
"refreshToken": { "type": "string", "description": "New JWT refresh token" },
"user": {
"type": "object",
"properties": {
"_id": { "type": "string" },
"email": { "type": "string" },
"role": { "type": "string" },
"profile": { "type": "object" },
"dealer": { "type": "string" }
}
}
}
}
}
}
},
"400": { "description": "Refresh token is required" },
"401": { "description": "Invalid or expired refresh token" },
"500": { "description": "Server error" }
},
"security": []
}
},
"/api/auth/register": {
"post": {
"tags": ["Auth"],
"summary": "Tạo tài khoản người dùng (Admin & DealerManager)",
"description": "Tạo tài khoản người dùng mới - Yêu cầu quyền: Admin hoặc DealerManager (DealerManager chỉ được tạo DealerStaff)",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"email": { "type": "string", "example": "newuser@evms.com" },
"password": { "type": "string", "example": "password123" },
"role": { "type": "string", "enum": ["Admin", "EVMStaff", "DealerManager", "DealerStaff"], "example": "DealerStaff" },
"dealer": { "type": "string", "description": "Dealer ID (required for DealerManager/DealerStaff)", "example": "68f90ebebeaef72ecf6e005a" },
"profile": {
"type": "object",
"properties": {
"name": { "type": "string", "example": "John Doe" },
"phone": { "type": "string", "example": "0901234567" }
}
}
},
"required": ["email", "password", "role"],
"example": {
"email": "staff@dealer.com",
"password": "password123",
"role": "DealerStaff",
"dealer": "68f90ebebeaef72ecf6e005a",
"profile": {
"name": "Nguyen Van A",
"phone": "0901234567"
}
}
}
}
}
},
"responses": {
"201": {
"description": "User created successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": { "type": "string", "example": "User registered successfully" },
"user": {
"type": "object",
"properties": {
"id": { "type": "string" },
"email": { "type": "string" },
"role": { "type": "string" },
"profile": { "type": "object" },
"dealer": { "type": "string" }
}
}
}
}
}
}
},
"400": { "description": "Bad request - User already exists or invalid data" },
"403": { "description": "Forbidden - Insufficient permissions" },
"500": { "description": "Server error" }
}
}
},
"/api/auth/me": {
"get": {
"tags": ["Auth"],
"summary": "Lấy thông tin người dùng hiện tại",
"description": "Trả về thông tin hồ sơ của người dùng đã xác thực",
"responses": {
"200": {
"description": "User profile",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"_id": { "type": "string" },
"email": { "type": "string" },
"role": { "type": "string", "enum": ["Admin", "EVMStaff", "DealerManager", "DealerStaff"] },
"profile": {
"type": "object",
"properties": {
"name": { "type": "string" },
"phone": { "type": "string" }
}
},
"dealer": { "type": "string" },
"status": { "type": "string", "enum": ["active", "locked"] },
"createdAt": { "type": "string", "format": "date-time" },
"updatedAt": { "type": "string", "format": "date-time" }
}
}
}
}
},
"401": { "description": "Unauthorized - No token or invalid token" }
}
}
},
"/api/auth/logout": {
"post": {
"tags": ["Auth"],
"summary": "Đăng xuất",
"description": "Đăng xuất người dùng đã đăng nhập. Client nên xóa token khỏi localStorage/cookie.",
"responses": {
"200": {
"description": "Logout successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": { "type": "boolean", "example": true },
"message": { "type": "string", "example": "Logout successful" }
}
}
}
}
},
"401": { "description": "Not authenticated" },
"500": { "description": "Server error" }
}
}
},
"/api/vehicles": {
"get": {
"tags": ["VehicleVariants"],
"summary": "Liệt kê tất cả phiên bản xe (variants)",
"responses": { "200": { "description": "List of vehicle variants" } }
},
"post": {
"tags": ["VehicleVariants"],
"summary": "Tạo phiên bản xe (variant) mới",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"model": { "type": "string", "description": "VehicleModel ID", "example": "68f90ebebeaef72ecf6e005e" },
"trim": { "type": "string", "example": "Premium" },
"battery": { "type": "string", "example": "100kWh" },
"range": { "type": "number", "example": 600 },
"motorPower": { "type": "number", "example": 300 },
"features": { "type": "array", "items": { "type": "string" }, "example": ["Electric", "Autopilot", "AI Assistant", "Fast Charging", "Premium Interior", "Panoramic Sunroof"] },
"msrp": { "type": "number", "example": 6500000000 },
"images": { "type": "array", "items": { "type": "string" }, "example": ["vf8_premium_front.jpg", "vf8_premium_interior.jpg", "vf8_premium_side.jpg"] },
"active": { "type": "boolean", "example": true }
},
"required": ["model", "trim", "msrp"],
"example": {
"model": "68f90ebebeaef72ecf6e005e",
"trim": "Premium",
"battery": "100kWh",
"range": 600,
"motorPower": 300,
"features": ["Electric", "Autopilot", "AI Assistant", "Fast Charging", "Premium Interior"],
"msrp": 6500000000,
"images": ["vf8_premium_1.jpg"],
"active": true
}
}
}
}
},
"responses": { "201": { "description": "Vehicle variant created" } }
}
},
"/api/vehicles/compare": {
"get": {
"tags": ["VehicleVariants"],
"summary": "So sánh nhiều phiên bản xe (GET)",
"description": "So sánh nhiều xe bằng query parameter. Tối thiểu 2 xe, không giới hạn tối đa. Truyền danh sách id biến thể qua query 'ids', phân tách dấu phẩy",
"parameters": [
{
"name": "ids",
"in": "query",
"required": true,
"schema": { "type": "string" },
"example": "68f90e...005c,68f90e...005e,68f90e...005f",
"description": "Danh sách ID của các xe cần so sánh, phân tách bởi dấu phẩy"
}
],
"responses": {
"200": {
"description": "So sánh thành công",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": { "type": "boolean", "example": true },
"message": { "type": "string", "example": "So sánh 3 xe thành công" },
"data": {
"type": "object",
"properties": {
"count": { "type": "number", "example": 3 },
"vehicles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"_id": { "type": "string" },
"model": {
"type": "object",
"properties": {
"_id": { "type": "string" },
"name": { "type": "string" },
"brand": { "type": "string" },
"segment": { "type": "string" },
"description": { "type": "string" }
}
},
"trim": { "type": "string" },
"battery": { "type": "string" },
"range": { "type": "number" },
"motorPower": { "type": "number" },
"features": { "type": "array", "items": { "type": "string" } },
"msrp": { "type": "number" },
"images": { "type": "array", "items": { "type": "string" } },
"active": { "type": "boolean" }
}
}
},
"comparison": {
"type": "object",
"properties": {
"models": { "type": "array", "items": { "type": "string" } },
"trims": { "type": "array", "items": { "type": "string" } },
"priceRange": {
"type": "object",
"properties": {
"min": { "type": "number" },
"max": { "type": "number" }
}
},
"rangeRange": {
"type": "object",
"properties": {
"min": { "type": "number" },
"max": { "type": "number" }
}
},
"motorPowerRange": {
"type": "object",
"properties": {
"min": { "type": "number" },
"max": { "type": "number" }
}
}
}
}
}
}
}
}
}
}
},
"400": { "description": "Thiếu hoặc sai tham số (cần ít nhất 2 xe)" },
"404": { "description": "Không tìm thấy một hoặc nhiều xe" }
}
},
"post": {
"tags": ["VehicleVariants"],
"summary": "So sánh nhiều phiên bản xe (POST - JSON)",
"description": "So sánh nhiều xe bằng JSON body. Tối thiểu 2 xe, không giới hạn tối đa. Gửi mảng IDs trong request body.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"ids": {
"type": "array",
"items": { "type": "string" },
"minItems": 2,
"description": "Danh sách ID của các xe cần so sánh"
}
},
"required": ["ids"],
"example": {
"ids": ["68f90e...005c", "68f90e...005e", "68f90e...005f"]
}
}
}
}
},
"responses": {
"200": {
"description": "So sánh thành công",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": { "type": "boolean", "example": true },
"message": { "type": "string", "example": "So sánh 3 xe thành công" },
"data": {
"type": "object",
"properties": {
"count": { "type": "number", "example": 3 },
"vehicles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"_id": { "type": "string" },
"model": {
"type": "object",
"properties": {
"_id": { "type": "string" },
"name": { "type": "string" },
"brand": { "type": "string" },
"segment": { "type": "string" },
"description": { "type": "string" }
}
},
"trim": { "type": "string" },
"battery": { "type": "string" },
"range": { "type": "number" },
"motorPower": { "type": "number" },
"features": { "type": "array", "items": { "type": "string" } },
"msrp": { "type": "number" },
"images": { "type": "array", "items": { "type": "string" } },
"active": { "type": "boolean" }
}
}
},
"comparison": {
"type": "object",
"properties": {
"models": { "type": "array", "items": { "type": "string" } },
"trims": { "type": "array", "items": { "type": "string" } },
"priceRange": {
"type": "object",
"properties": {
"min": { "type": "number" },
"max": { "type": "number" }
}
},
"rangeRange": {
"type": "object",
"properties": {
"min": { "type": "number" },
"max": { "type": "number" }
}
},
"motorPowerRange": {
"type": "object",
"properties": {
"min": { "type": "number" },
"max": { "type": "number" }
}
}
}
}
}
}
}
}
}
}
},
"400": { "description": "Thiếu hoặc sai tham số (cần ít nhất 2 xe)" },
"404": { "description": "Không tìm thấy một hoặc nhiều xe" }
}
}
},
"/api/vehicles/{id}": {
"get": {
"tags": ["VehicleVariants"],
"summary": "Lấy chi tiết phiên bản xe theo ID",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Vehicle variant details" } }
},
"put": {
"tags": ["VehicleVariants"],
"summary": "Cập nhật phiên bản xe",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"trim": { "type": "string" },
"battery": { "type": "string" },
"range": { "type": "number" },
"motorPower": { "type": "number" },
"features": { "type": "array", "items": { "type": "string" } },
"msrp": { "type": "number" },
"images": { "type": "array", "items": { "type": "string" } },
"active": { "type": "boolean" }
}
}
}
}
},
"responses": { "200": { "description": "Vehicle variant updated" } }
},
"delete": {
"tags": ["VehicleVariants"],
"summary": "Xóa phiên bản xe",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Vehicle variant deleted" } }
}
},
"/api/inventory": {
"get": {
"tags": ["Inventory"],
"summary": "Lấy tồn kho (theo đại lý hoặc tổng)",
"responses": { "200": { "description": "Inventory list" } }
},
"post": {
"tags": ["Inventory"],
"summary": "Tạo mục tồn kho",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"ownerType": { "type": "string", "enum": ["EVM", "Dealer"], "example": "Dealer" },
"owner": { "type": "string", "description": "Dealer ID", "example": "68f90ebebeaef72ecf6e005a" },
"variant": { "type": "string", "description": "VehicleVariant ID", "example": "68f90ebebeaef72ecf6e005c" },
"color": { "type": "string", "description": "VehicleColor ID", "example": "68f90ebebeaef72ecf6e005d" },
"quantity": { "type": "number", "example": 10 },
"reserved": { "type": "number", "example": 0 },
"vinList": { "type": "array", "items": { "type": "string" }, "example": ["VIN001234567890", "VIN001234567891"] },
"location": { "type": "string", "example": "Warehouse A - Hanoi" }
},
"required": ["ownerType", "owner", "variant", "quantity"],
"example": {
"ownerType": "Dealer",
"owner": "68f90ebebeaef72ecf6e005a",
"variant": "68f90ebebeaef72ecf6e005c",
"color": "68f90ebebeaef72ecf6e005d",
"quantity": 15,
"reserved": 2,
"vinList": ["VIN001234567890", "VIN001234567891", "VIN001234567892"],
"location": "Warehouse A - Hanoi"
}
}
}
}
},
"responses": { "201": { "description": "Inventory created" } }
}
},
"/api/inventory/dealer/{dealerId}": {
"get": {
"tags": ["Inventory"],
"summary": "Lấy tồn kho theo đại lý",
"parameters": [{ "name": "dealerId", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Danh sách tồn kho của đại lý" } }
}
},
"/api/inventory/transfer": {
"post": {
"tags": ["Inventory"],
"summary": "Điều phối xe giữa các đại lý",
"requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "variant": { "type": "string" }, "color": { "type": "string" }, "fromDealerId": { "type": "string" }, "toDealerId": { "type": "string" }, "quantity": { "type": "number" } }, "required": ["variant", "fromDealerId", "toDealerId", "quantity"], "example": { "variant": "68f9...005c", "color": "68f9...005d", "fromDealerId": "68f9...00aa", "toDealerId": "68f9...00bb", "quantity": 2 } } } } },
"responses": { "200": { "description": "Kết quả điều phối" } }
}
},
"/api/inventory/{id}": {
"put": {
"tags": ["Inventory"],
"summary": "Update inventory item",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"quantity": { "type": "number", "example": 15 },
"reserved": { "type": "number", "example": 2 },
"vinList": { "type": "array", "items": { "type": "string" } },
"location": { "type": "string" }
},
"example": {
"quantity": 20,
"reserved": 3,
"vinList": ["VIN001234567893", "VIN001234567894"],
"location": "Warehouse B - Ho Chi Minh City"
}
}
}
}
},
"responses": { "200": { "description": "Inventory updated" } }
},
"delete": {
"tags": ["Inventory"],
"summary": "Delete inventory item",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Inventory deleted" } }
}
},
"/api/promotions": {
"get": {
"tags": ["Promotions"],
"summary": "Liệt kê khuyến mãi",
"responses": { "200": { "description": "Promotion list" } }
},
"post": {
"tags": ["Promotions"],
"summary": "Tạo khuyến mãi",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": { "type": "string", "example": "Summer Sale 2024" },
"scope": { "type": "string", "enum": ["global", "byDealer", "byVariant"], "example": "byDealer" },
"dealers": { "type": "array", "items": { "type": "string" }, "description": "Array of Dealer IDs", "example": ["68f90ebebeaef72ecf6e005a", "68f90ebebeaef72ecf6e005b"] },
"variants": { "type": "array", "items": { "type": "string" }, "description": "Array of VehicleVariant IDs", "example": ["68f90ebebeaef72ecf6e005c", "68f90ebebeaef72ecf6e005d"] },
"type": { "type": "string", "enum": ["cashback", "accessory", "finance"], "example": "cashback" },
"value": { "type": "number", "example": 15, "description": "Percentage discount" },
"stackable": { "type": "boolean", "example": false },
"validFrom": { "type": "string", "format": "date", "example": "2024-06-01" },
"validTo": { "type": "string", "format": "date", "example": "2024-08-31" },
"status": { "type": "string", "enum": ["active", "inactive"], "example": "active" }
},
"required": ["name", "validFrom", "validTo"],
"example": {
"name": "Summer Sale 2024 - VF8 Special",
"scope": "byDealer",
"dealers": ["68f90ebebeaef72ecf6e005a"],
"variants": ["68f90ebebeaef72ecf6e005c"],
"type": "cashback",
"value": 15,
"stackable": false,
"validFrom": "2024-06-01",
"validTo": "2024-08-31",
"status": "active"
}
}
}
}
},
"responses": { "201": { "description": "Promotion created" } }
}
},
"/api/promotions/{id}": {
"put": {
"tags": ["Promotions"],
"summary": "Cập nhật khuyến mãi",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": { "type": "string" },
"scope": { "type": "string", "enum": ["global", "byDealer", "byVariant"] },
"dealers": { "type": "array", "items": { "type": "string" } },
"variants": { "type": "array", "items": { "type": "string" } },
"type": { "type": "string", "enum": ["cashback", "accessory", "finance"] },
"value": { "type": "number" },
"stackable": { "type": "boolean" },
"validFrom": { "type": "string", "format": "date" },
"validTo": { "type": "string", "format": "date" },
"status": { "type": "string", "enum": ["active", "inactive"] }
}
}
}
}
},
"responses": { "200": { "description": "Promotion updated" } }
},
"delete": {
"tags": ["Promotions"],
"summary": "Xóa khuyến mãi",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Promotion deleted" } }
}
},
"/api/customers": {
"get": {
"tags": ["Customers"],
"summary": "Liệt kê khách hàng",
"responses": { "200": { "description": "Customer list" } }
},
"post": {
"tags": ["Customers"],
"summary": "Tạo khách hàng",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"fullName": { "type": "string", "example": "Nguyen Van A" },
"email": { "type": "string", "example": "nguyenvana@gmail.com" },
"phone": { "type": "string", "example": "0901234567" },
"address": { "type": "string", "example": "123 Tran Hung Dao, Hoan Kiem, Hanoi" },
"notes": { "type": "string", "example": "Very interested in VF8 Premium. Budget around 6.5 billion VND" }
},
"required": ["fullName", "phone"],
"example": {
"fullName": "Nguyen Minh Khoa",
"email": "khoa.nguyen@gmail.com",
"phone": "0906789123",
"address": "456 Le Loi Street, District 1, Ho Chi Minh City",
"notes": "Interested in VF8 Premium, prefers white color, needs delivery within 2 months"
}
}
}
}
},
"responses": { "201": { "description": "Customer created" } }
}
},
"/api/customers/{id}": {
"get": {
"tags": ["Customers"],
"summary": "Lấy chi tiết khách hàng theo ID",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Customer details" } }
},
"patch": {
"tags": ["Customers"],
"summary": "Cập nhật khách hàng",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"fullName": { "type": "string" },
"email": { "type": "string" },
"phone": { "type": "string" },
"address": { "type": "string" },
"notes": { "type": "string" }
}
}
}
}
},
"responses": { "200": { "description": "Customer updated" } }
},
"delete": {
"tags": ["Customers"],
"summary": "Xóa khách hàng",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Customer deleted" } }
}
},
"/api/test-drives": {
"get": {
"tags": ["TestDrives"],
"summary": "Liệt kê lịch lái thử",
"responses": { "200": { "description": "Test drive list" } }
},
"post": {
"tags": ["TestDrives"],
"summary": "Tạo lịch lái thử",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"customer": { "type": "string", "description": "Customer ID", "example": "68f90ebebeaef72ecf6e005a" },
"dealer": { "type": "string", "description": "Dealer ID", "example": "68f90ebebeaef72ecf6e005b" },
"variant": { "type": "string", "description": "VehicleVariant ID", "example": "68f90ebebeaef72ecf6e005c" },
"preferredTime": { "type": "string", "format": "date-time", "example": "2024-12-25T14:00:00Z" },
"status": { "type": "string", "enum": ["pending", "confirmed", "done", "cancelled"], "example": "pending" },
"assignedStaff": { "type": "string", "description": "User ID of assigned staff", "example": "68f90ebebeaef72ecf6e005d" },
"result": {
"type": "object",
"properties": {
"feedback": { "type": "string", "example": "Customer very satisfied with performance" },
"interestRate": { "type": "number", "example": 90 }
}
}
},
"required": ["customer", "dealer", "variant", "preferredTime"],
"example": {
"customer": "68f90ebebeaef72ecf6e005a",
"dealer": "68f90ebebeaef72ecf6e005b",
"variant": "68f90ebebeaef72ecf6e005c",
"preferredTime": "2024-12-26T10:00:00Z",
"status": "confirmed",
"assignedStaff": "68f90ebebeaef72ecf6e005d"
}
}
}
}
},
"responses": { "201": { "description": "Test drive created" } }
}
},
"/api/test-drives/{id}": {
"get": {
"tags": ["TestDrives"],
"summary": "Lấy chi tiết lịch lái thử theo ID",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Test drive details" } }
},
"patch": {
"tags": ["TestDrives"],
"summary": "Cập nhật lịch lái thử",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"preferredTime": { "type": "string", "format": "date-time" },
"status": { "type": "string", "enum": ["pending", "confirmed", "done", "cancelled"] },
"assignedStaff": { "type": "string", "description": "User ID" },
"result": {
"type": "object",
"properties": {
"feedback": { "type": "string" },
"interestRate": { "type": "number" }
}
}
},
"example": {
"status": "done",
"result": {
"feedback": "Customer loved the autopilot feature and smooth acceleration",
"interestRate": 95
}
}
}
}
}
},
"responses": { "200": { "description": "Test drive updated" } }
},
"delete": {
"tags": ["TestDrives"],
"summary": "Xóa lịch lái thử",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Test drive deleted" } }
}
},
"/api/quotes": {
"get": {
"tags": ["Quotes"],
"summary": "Liệt kê báo giá",
"responses": { "200": { "description": "Quote list" } }
},
"post": {
"tags": ["Quotes"],
"summary": "Tạo báo giá",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"customer": { "type": "string", "description": "Customer ID", "example": "68f90ebebeaef72ecf6e005a" },
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"variant": { "type": "string", "description": "VehicleVariant ID" },
"color": { "type": "string", "description": "VehicleColor ID" },
"qty": { "type": "number", "example": 1 },
"unitPrice": { "type": "number", "example": 6500000000 }
}
}
},
"subtotal": { "type": "number", "example": 6500000000 },
"discount": { "type": "number", "example": 650000000 },
"total": { "type": "number", "example": 5850000000 },
"validUntil": { "type": "string", "format": "date", "example": "2024-12-31" },
"notes": { "type": "string", "example": "Special discount for VIP customer - 10% off" }
},
"required": ["customer", "items"],
"example": {
"customer": "68f90ebebeaef72ecf6e005a",
"items": [
{
"variant": "68f90ebebeaef72ecf6e005c",
"color": "68f90ebebeaef72ecf6e005d",
"qty": 1,
"unitPrice": 6500000000
}
],
"subtotal": 6500000000,
"discount": 650000000,
"total": 5850000000,
"validUntil": "2024-12-31",
"notes": "VF8 Premium in Pearl White - Summer promotion 10% discount applied"
}
}
}
}
},
"responses": { "201": { "description": "Quote created" } }
}
},
"/api/quotes/{id}": {
"get": {
"tags": ["Quotes"],
"summary": "Lấy chi tiết báo giá theo ID",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Quote details" } }
},
"patch": {
"tags": ["Quotes"],
"summary": "Cập nhật báo giá",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": { "type": "string", "enum": ["draft", "sent", "accepted", "rejected"] },
"subtotal": { "type": "number" },
"discount": { "type": "number" },
"total": { "type": "number" },
"validUntil": { "type": "string", "format": "date" },
"notes": { "type": "string" }
}
}
}
}
},
"responses": { "200": { "description": "Quote updated" } }
},
"delete": {
"tags": ["Quotes"],
"summary": "Xóa báo giá",
"parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }],
"responses": { "200": { "description": "Quote deleted" } }
}