# 停車場管理車輛API
## 篩選車輛資料
紀錄排序為最新往最舊的排
善用`skip`和`limit`可以控制回應筆數
example:
`http://192.168.6.6:8080/vehicles/?skip=0&limit=10`
`count`可回應總筆數
example:
`http://192.168.6.6:8080/vehicles/count`
### 根據車牌篩選
`license_plate_number`query欄位填入車牌號碼,篩選此車牌號碼的車輛資料
HTTP request GET example:
`http://192.168.6.6:8080/vehicles/?skip=0&limit=10&license_plate_number=ABC123`
### 根據用戶篩選
`account_id`query欄位填入用戶id,篩選此用戶id的車輛資料
HTTP request GET example:
`http://192.168.6.6:8080/vehicles/?skip=0&limit=10&account_id=1`
### 根據E-TAG號碼篩選
`etag_number`query欄位填入E-TAG號碼,篩選此E-TAG號碼的車輛資料
HTTP request GET example:
`http://192.168.6.6:8080/vehicles/?skip=0&limit=10&etag_number=111111111111111111111111`
### 篩選特定車輛
`id`query欄位填入id,篩選此id的車輛資料
HTTP request GET example:
`http://192.168.6.6:8080/vehicles/?skip=0&limit=10&id=1`
### 篩選車輛類別
`vtype`query欄位填入車輛類別,篩選類別的車輛資料,`car`、`motorcycle`分別為車子與機車類別
HTTP request GET example:
`http://192.168.6.6:8080/vehicles/?skip=0&limit=10&vtype=car`
### 欄位說明
#### <ins>**Example**</ins>
```
{
"license_plate_number": "ABC123",
"account_id": 13,
"vtype": "car",
"etag_number": "111111111111111111111111",
"id": 1,
"occupied_space_id": null,
"account_name": "TEST",
"space_number": 7
}
```
| 欄位 | 格式 | 說明 |
| -------------------- | ---- | --- |
| **license_plate_number** | `string` | 車牌號碼 |
| **account_id** | `integer` | 用戶id,若無則為null |
| **vtype** | `string` | 車輛類別,`car`、`motorcycle`分別為車子與機車類別 |
| **etag_number** | `string` | E-Tag號碼,若無則為null |
| **id** | `integer` | 車輛id |
| **occupied_space_id** | `integer` | 所停放之車位id,若無則為null |
| **account_name** | `integer` | 用戶名稱,若無則為null |
| **space_number** | `integer` | 車位數量,若無則為0 |
## 新增車輛資料
HTTP request POST Content-Type:
`application/json`
HTTP request POST URL example:
`http://192.168.6.6:8080/vehicles/`
### 欄位說明
HTTP request POST Body example:
```
{
"license_plate_number": "9833EP",
"vtype": "car",
"account_id": 1,
"etag_number": "E280689420005008CA83817B"
}
```
| 欄位 | 格式 | 說明 |
| -------------------- | ---- | --- |
| **license_plate_number** | `string` | 車牌號碼,此欄位必須填入 |
| **account_id** | `integer` | 要填的用戶id |
| **vtype** | `string` | 車輛類別,`car`、`motorcycle`分別為車子與機車類別 |
| **etag_number** | `string` | E-Tag號碼 |
## 更新車輛資料
HTTP request PUT Content type:
`application/json`
### 參數說明
HTTP request PUT URL example:
`http://192.168.6.6:8080/vehicles/{vehicle_id}`
| 參數 | 格式 | 說明 |
| -------------------- | ---- | --- |
| **vehicle_id** | `integer` | 要更新的車輛id |
### 欄位說明
HTTP request PUT body example:
```
{
"license_plate_number": "9833EP",
"vtype": "car",
"account_id": 1,
"etag_number": "E280689420005008CA83817B"
}
```
| 欄位 | 格式 | 說明 |
| -------------------- | ---- | --- |
| **license_plate_number** | `string` | 車牌號碼 |
| **account_id** | `integer` | 要填的用戶id |
| **vtype** | `string` | 車輛類別,`car`、`motorcycle`分別為車子與機車類別 |
| **etag_number** | `string` | E-Tag號碼 |
## 刪除車輛
### 刪除特定車輛
`id`query欄位填入車輛id,刪除id篩選後的車輛資料
HTTP request DELETE example:
`http://192.168.6.6:8080/vehicles/?id=1`
### 根據車牌刪除
`license_plate_number`query欄位填入車牌號碼,刪除此車牌號碼的車輛資料
HTTP request DELETE example:
`http://192.168.6.6:8080/vehicles/?license_plate_number=ABC123`
### 根據用戶刪除
`account_id`query欄位填入用戶id,刪除此用戶id的車輛資料
HTTP request DELETE example:
`http://192.168.6.6:8080/vehicles/?account_id=1`
### 根據車輛類別刪除
`vtype`query欄位填入車輛類別,刪除此車輛類別的車輛資料,`car`、`motorcycle`分別為車子與機車類別
HTTP request DELETE example:
`http://192.168.6.6:8080/vehicles/?vtype=car`
### 根據E-TAG號碼刪除
`etag_number`query欄位填入E-TAG號碼,刪除此E-TAG號碼的車輛資料
HTTP request DELETE example:
`http://192.168.6.6:8080/vehicles/?etag_number=111111111111111111111111`
## 查詢車輛下的時間限制
### 參數說明
HTTP request GET example:
`http://192.168.5.88:8080/vehicles/{vehicle_id}/time_restricts?skip=0&limit=10`
| 參數 | 格式 | 說明 |
| -------------------- | ---- | --- |
| **vehicle_id** | `integer` | 要查詢的車輛id |
### 欄位說明
#### <ins>**Example**</ins>
```
{
"name": "時間限制",
"logical": "OR",
"id": 8
}
```
| 欄位 | 格式 | 說明 |
| -------------------- | ---- | --- |
| **name** | `string` | 時間限制名稱 |
| **logical** | `string(RestrictLogic)` | periods與time_ranges的邏輯類別, `AND`、`OR`分別為交集和聯集關係 |
| **id** | `integer` | 時間限制id |
## 將車輛加入時間限制
### 參數說明
HTTP request PUT example:
`http://192.168.6.6:8080/vehicles/{vehicle_id}/time_restricts/{time_restrict_id}`
| 參數 | 格式 | 說明 |
| -------------------- | ---- | --- |
| **vehicle_id** | `integer` | 要新增時間限制的車輛id |
| **time_restrict_id** | `integer` | 要與車輛綁定的的時間限制id |