This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Yulei-cn/main
update
- Loading branch information
Showing
5 changed files
with
494 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,180 +1,155 @@ | ||
# Airline Reservation System API | ||
|
||
This project is a microservices-based airline reservation system. The system allows clients to view flights, make reservations, and manage their bookings. Staff members can manage flights, airports, planes, and view all bookings. The project is structured into three main services: `api_client`, `api_staff`, and `api_common`. | ||
|
||
## API Overview | ||
|
||
### API Client | ||
|
||
The `api_client` service handles all client-side operations, including user registration, login, viewing flights, and managing user-specific bookings. | ||
|
||
#### Endpoints | ||
|
||
- **Register**: `/api/client/register/` | ||
- Method: POST | ||
- Description: Registers a new user. | ||
|
||
- **Login**: `/api/client/login/` | ||
- Method: POST | ||
- Description: Authenticates a user and returns JWT tokens. | ||
|
||
- **User List**: `/api/client/users/` | ||
- Method: GET | ||
- Description: Retrieves a list of all users. (Admin only) | ||
|
||
- **Update User**: `/api/client/update-user/<int:pk>/` | ||
- Method: PUT | ||
- Description: Updates user details. | ||
|
||
- **Delete User**: `/api/client/delete-user/<int:pk>/` | ||
- Method: DELETE | ||
- Description: Deletes a user. | ||
|
||
- **Flight List**: `/api/client/flights/` | ||
- Method: GET | ||
- Description: Retrieves a list of all available flights. | ||
|
||
- **User Booking List**: `/api/client/bookings/` | ||
- Method: GET | ||
- Description: Retrieves a list of all bookings made by the authenticated user. | ||
|
||
- **User Booking Detail**: `/api/client/bookings/<int:pk>/` | ||
- Method: GET, PUT, DELETE | ||
- Description: Retrieves, updates, or deletes a specific booking made by the authenticated user. | ||
|
||
### API Staff | ||
|
||
The `api_staff` service handles all staff-side operations, including managing flights, airports, planes, and viewing all bookings. | ||
|
||
#### Endpoints | ||
|
||
- **Add Flight**: `/api/staff/add-flight/` | ||
- Method: POST | ||
- Description: Adds a new flight. | ||
|
||
- **Delete Flight**: `/api/staff/delete-flight/<int:pk>/` | ||
- Method: DELETE | ||
- Description: Deletes a flight. | ||
|
||
- **Update Flight**: `/api/staff/update-flight/<int:pk>/` | ||
- Method: PUT | ||
- Description: Updates a flight's details. | ||
|
||
- **Flight List**: `/api/staff/flights/` | ||
- Method: GET | ||
- Description: Retrieves a list of all flights. | ||
|
||
- **Staff Login**: `/api/staff/login/` | ||
- Method: POST | ||
- Description: Authenticates a staff member and returns JWT tokens. | ||
|
||
- **Airport List**: `/api/staff/airports/` | ||
- Method: GET | ||
- Description: Retrieves a list of all airports. | ||
|
||
- **Airport Detail**: `/api/staff/airports/<int:pk>/` | ||
- Method: GET, PUT, DELETE | ||
- Description: Retrieves, updates, or deletes a specific airport's details. | ||
|
||
- **Plane List**: `/api/staff/planes/` | ||
- Method: GET | ||
- Description: Retrieves a list of all planes. | ||
|
||
- **Plane Detail**: `/api/staff/planes/<int:pk>/` | ||
- Method: GET, PUT, DELETE | ||
- Description: Retrieves, updates, or deletes a specific plane's details. | ||
|
||
- **Booking List**: `/api/staff/bookings/` | ||
- Method: GET | ||
- Description: Retrieves a list of all bookings. | ||
|
||
|
||
# 航班预订系统 API | ||
|
||
本项目是一个基于微服务的航班预订系统。系统允许客户查看航班、进行预订和管理他们的预订。工作人员可以管理航班、机场、飞机,并查看所有的预订记录。项目主要分为三个服务:`api_client`、`api_staff`和`api_common`。 | ||
|
||
## API 概述 | ||
|
||
### API 客户端 | ||
|
||
`api_client`服务处理所有客户端操作,包括用户注册、登录、查看航班和管理用户特定的预订。 | ||
|
||
#### 端点 | ||
|
||
- **注册**: `/api/client/register/` | ||
- 方法: POST | ||
- 描述: 注册新用户。 | ||
|
||
- **登录**: `/api/client/login/` | ||
- 方法: POST | ||
- 描述: 认证用户并返回JWT令牌。 | ||
|
||
- **用户列表**: `/api/client/users/` | ||
- 方法: GET | ||
- 描述: 获取所有用户的列表。(仅管理员) | ||
|
||
- **更新用户**: `/api/client/update-user/<int:pk>/` | ||
- 方法: PUT | ||
- 描述: 更新用户详细信息。 | ||
|
||
- **删除用户**: `/api/client/delete-user/<int:pk>/` | ||
- 方法: DELETE | ||
- 描述: 删除用户。 | ||
|
||
- **航班列表**: `/api/client/flights/` | ||
- 方法: GET | ||
- 描述: 获取所有可用航班的列表。 | ||
|
||
- **用户预订列表**: `/api/client/bookings/` | ||
- 方法: GET | ||
- 描述: 获取当前认证用户的所有预订列表。 | ||
|
||
- **用户预订详情**: `/api/client/bookings/<int:pk>/` | ||
- 方法: GET, PUT, DELETE | ||
- 描述: 获取、更新或删除当前认证用户的特定预订。 | ||
|
||
### API 工作人员 | ||
|
||
`api_staff`服务处理所有工作人员操作,包括管理航班、机场、飞机和查看所有预订记录。 | ||
|
||
#### 端点 | ||
|
||
- **添加航班**: `/api/staff/add-flight/` | ||
- 方法: POST | ||
- 描述: 添加新航班。 | ||
|
||
- **删除航班**: `/api/staff/delete-flight/<int:pk>/` | ||
- 方法: DELETE | ||
- 描述: 删除航班。 | ||
|
||
- **更新航班**: `/api/staff/update-flight/<int:pk>/` | ||
- 方法: PUT | ||
- 描述: 更新航班详细信息。 | ||
|
||
- **航班列表**: `/api/staff/flights/` | ||
- 方法: GET | ||
- 描述: 获取所有航班的列表。 | ||
|
||
- **登录**: `/api/staff/login/` | ||
- 方法: POST | ||
- 描述: 认证工作人员并返回JWT令牌。 | ||
|
||
- **机场列表**: `/api/staff/airports/` | ||
- 方法: GET | ||
- 描述: 获取所有机场的列表。 | ||
|
||
- **机场详情**: `/api/staff/airports/<int:pk>/` | ||
- 方法: GET, PUT, DELETE | ||
- 描述: 获取、更新或删除特定机场的详细信息。 | ||
|
||
- **飞机列表**: `/api/staff/planes/` | ||
- 方法: GET | ||
- 描述: 获取所有飞机的列表。 | ||
|
||
- **飞机详情**: `/api/staff/planes/<int:pk>/` | ||
- 方法: GET, PUT, DELETE | ||
- 描述: 获取、更新或删除特定飞机的详细信息。 | ||
|
||
- **预订列表**: `/api/staff/bookings/` | ||
- 方法: GET | ||
- 描述: 获取所有预订的列表。 | ||
API 端点设计 | ||
用户管理 | ||
注册 | ||
端点: /api/register/ | ||
方法: POST | ||
描述: 注册新用户。 | ||
请求参数: | ||
username: string | ||
password: string | ||
email: string | ||
登录 | ||
端点: /api/login/ | ||
方法: POST | ||
描述: 认证用户并返回JWT令牌。 | ||
请求参数: | ||
username: string | ||
password: string | ||
获取用户列表(仅管理员) | ||
端点: /api/users/ | ||
方法: GET | ||
描述: 获取所有用户的列表。 | ||
更新用户 | ||
端点: /api/users/<int:pk>/ | ||
方法: PUT | ||
描述: 更新用户详细信息。 | ||
请求参数: | ||
email: string | ||
is_staff: boolean | ||
is_superuser: boolean | ||
删除用户 | ||
端点: /api/users/<int:pk>/ | ||
方法: DELETE | ||
描述: 删除用户。 | ||
航班管理 | ||
获取所有航班 | ||
端点: /api/flights/ | ||
方法: GET | ||
描述: 获取所有可用航班的列表。 | ||
添加新航班(仅工作人员) | ||
端点: /api/flights/ | ||
方法: POST | ||
描述: 添加新航班。 | ||
请求参数: | ||
flight_number: string | ||
departure: datetime | ||
arrival: datetime | ||
plane: int (plane ID) | ||
track_origin: int (track ID) | ||
track_destination: int (track ID) | ||
更新航班信息(仅工作人员) | ||
端点: /api/flights/<int:pk>/ | ||
方法: PUT | ||
描述: 更新航班详细信息。 | ||
请求参数: | ||
flight_number: string | ||
departure: datetime | ||
arrival: datetime | ||
plane: int (plane ID) | ||
track_origin: int (track ID) | ||
track_destination: int (track ID) | ||
删除航班(仅工作人员) | ||
端点: /api/flights/<int:pk>/ | ||
方法: DELETE | ||
描述: 删除航班。 | ||
预订管理 | ||
获取用户预订列表 | ||
端点: /api/bookings/ | ||
方法: GET | ||
描述: 获取当前认证用户的所有预订列表。 | ||
获取预订详情 | ||
端点: /api/bookings/<int:pk>/ | ||
方法: GET | ||
描述: 获取特定预订的详细信息。 | ||
创建预订 | ||
端点: /api/bookings/ | ||
方法: POST | ||
描述: 创建新预订。 | ||
请求参数: | ||
price: float | ||
booking_type: int (booking type ID) | ||
client: int (client ID) | ||
flight: int (flight ID) | ||
更新预订 | ||
端点: /api/bookings/<int:pk>/ | ||
方法: PUT | ||
描述: 更新预订详细信息。 | ||
请求参数: | ||
price: float | ||
booking_type: int (booking type ID) | ||
flight: int (flight ID) | ||
删除预订 | ||
端点: /api/bookings/<int:pk>/ | ||
方法: DELETE | ||
描述: 删除预订。 | ||
机场管理(仅工作人员) | ||
获取所有机场 | ||
端点: /api/airports/ | ||
方法: GET | ||
描述: 获取所有机场的列表。 | ||
获取机场详情 | ||
端点: /api/airports/<int:pk>/ | ||
方法: GET | ||
描述: 获取特定机场的详细信息。 | ||
添加机场 | ||
端点: /api/airports/ | ||
方法: POST | ||
描述: 添加新机场。 | ||
请求参数: | ||
name: string | ||
location: string | ||
更新机场信息 | ||
端点: /api/airports/<int:pk>/ | ||
方法: PUT | ||
描述: 更新机场详细信息。 | ||
请求参数: | ||
name: string | ||
location: string | ||
删除机场 | ||
端点: /api/airports/<int:pk>/ | ||
方法: DELETE | ||
描述: 删除机场。 | ||
飞机管理(仅工作人员) | ||
获取所有飞机 | ||
端点: /api/planes/ | ||
方法: GET | ||
描述: 获取所有飞机的列表。 | ||
获取飞机详情 | ||
端点: /api/planes/<int:pk>/ | ||
方法: GET | ||
描述: 获取特定飞机的详细信息。 | ||
添加飞机 | ||
端点: /api/planes/ | ||
方法: POST | ||
描述: 添加新飞机。 | ||
请求参数: | ||
model: string | ||
second_class_capacity: int | ||
first_class_capacity: int | ||
更新飞机信息 | ||
端点: /api/planes/<int:pk>/ | ||
方法: PUT | ||
描述: 更新飞机详细信息。 | ||
请求参数: | ||
model: string | ||
second_class_capacity: int | ||
first_class_capacity: int | ||
删除飞机 | ||
端点: /api/planes/<int:pk>/ | ||
方法: DELETE | ||
描述: 删除飞机。 | ||
所有预订记录(仅工作人员) | ||
获取所有预订记录 | ||
端点: /api/all-bookings/ | ||
方法: GET | ||
描述: 获取所有预订记录的列表。 |
Oops, something went wrong.