utaipei-sa / api.reserve.utsa Goto Github PK
View Code? Open in Web Editor NEWA platform to reserve the spaces and items managed by UTSA.
License: MIT License
A platform to reserve the spaces and items managed by UTSA.
License: MIT License
reservation_id
(path)/^[a-fA-F0-9]{24}$/
status: 200 OK
content: application/json
schema:
submit_datetime
: string, 用戶端表單送出時間server_datetime
: string, 伺服器端資料建立時間verified
: integer, 是否完成驗證,1:是 0:否name
: string, 登記人姓名department_grade
: string, 系級organization
: string, 借用單位(社團/單位等)email
: string, 聯絡用電子信箱/^[\w-.\+]+@([\w-]+\.)+[\w-]{2,4}$/
reason
: string, 借用原因/用途note
: string, 備註space_reservations
: array, 空間預約資料
space_id
: string, 場地 _id/^[a-fA-F0-9]{24}$/
start_datetime
: string, 預約時段開始時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
: string, 預約時段結束時間 format: /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
item_reservations
: array, 場地預約資料
item_id
: string, 物品 _id/^[a-fA-F0-9]{24}$/
item_code
: string, 物品編號start_datetime
: string, 預約時段開始時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
: string, 預約時段結束時間 format: /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
quantity
: integer, 預約物品數量example:
{
"submit_datetime": "2024-04-26T14:36:24.593+0800",
"server_datetime": "2024-04-26T14:36:25.286Z",
"name": "王小名",
"department_grade": "資科二",
"organization": "學生會",
"email": "[email protected]",
"reason": "舉辦迎新大會",
"note": "無",
"space_reservations": [
{
"space_id": "65253db7053c98f0bd1593db",
"start_datetime": "2024-01-23T18:00",
"end_datetime": "2024-01-25T22:00"
}
],
"item_reservations": [
{
"item_id": "652038af1b2271aa002c0a09",
"item_code": "ABC-123",
"start_datetime": "2024-01-23T18:00",
"end_datetime": "2024-01-25T22:00",
"quantity": 15
}
]
}
status: 404 Not found
content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Reservation ID not found"
}
增加 Dev container 相關設定檔
功能: 回傳場地 ID、場地列表
檔案:
資料庫 collection:
管理員登入權限管理:使用 Google 帳號登入
只有使用學生會 Google 帳號([email protected]),才能進入管理儀表板
Connect to the email service and send an email.
檔案:
資料庫 collection:
reservation (body)
新增預約紀錄
required
content: application/json
schema:
submit_datetime
: 用戶端表單送出時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d*)?\+08:?00$/
name
: 登記人姓名department_grade
: 系級organization
: 借用單位(社團/單位等)email
: 聯絡用電子信箱/^[\w-.\+]+@([\w-]+\.)+[\w-]{2,4}$/
reason
: 借用原因/用途note
: 備註space_reservations
: 空間預約資料Union(space_reservations, item_reservations)
)
space_id
: 場地 _id/^[a-fA-F0-9]{24}$/
start_datetime
: 預約時段開始時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
: 預約時段結束時間 string, required/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
item_reservations
: 場地預約資料Union(space_reservations, item_reservations)
)
item_id
: 物品 _id/^[a-fA-F0-9]{24}$/
item_code
: 物品編號start_datetime
: 預約時段開始時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
: 預約時段結束時間 string, required/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
quantity
: 預約物品數量example:
{
"submit_datetime": "2024-04-26T14:31:23.486+0800",
"name": "王小名",
"department_grade": "資科二",
"organization": "學生會",
"email": "[email protected]",
"reason": "舉辦迎新大會",
"space_reservations": [
{
"space_id": "65253db7053c98f0bd1593db",
"start_datetime": "2024-01-23T18:00",
"end_datetime": "2024-01-25T22:00"
}
],
"item_reservations": [
{
"item_id": "652038af1b2271aa002c0a09",
"item_code": "ABC-123",
"start_datetime": "2024-01-23T18:00",
"end_datetime": "2024-01-25T22:00",
"quantity": 15
}
],
"note": "無"
}
status: 200 OK
content: application/json
{
"code": "R_SUCCESS",
"message": "Success!"
}
status: 404 Not Found
content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Space ID not found"
}
reservation_id
(path)/^[a-fA-F0-9]{24}$/
status: 200 OK
content: application/json
If the server found the reservation data and delete it, the following content will be returned:
{
"code": "R_SUCCESS",
"message": "Delete success!"
}
If the reservation data not exist, the following content will be returned:
{
"code": "R_ID_NOT_FOUND",
"message": "Reservation ID not found"
}
修改 GET /reserve API 的文件,並將輸出格式調整為前端可用的格式(尤其是時間,消除時區資訊)
Is your feature request related to a problem? Please describe.
有點懶得維護文件😆
Describe the solution you'd like
使用 OpenAPI 及 Swagger 自動生成 API 文件(希望達到像是 FastAPI 一樣的效果)
Describe alternatives you've considered
不能自動生成的話也還可以接受
Additional context
參考資源:https://www.npmjs.com/package/swagger-ui-express
檔案: /server/routes/reserve/GET_reservation.js
資料庫:
POST /reserve
intervals
(query)item_id
(query)/^[a-fA-F0-9]{24}$/
start_datetime
(query)/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
(query) 查詢結束時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
status: 200 OK
content: application/json
if intervals is false
:
available_quantity
: integer, 可預約數量example:
{
"available_quantity": 5
}
if intervals is true
:
intervals
: Array, 各時段可否預約資料
start_datetime
: string, 時段開始時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
: string, 時段結束時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
available_quantity
: integer, 可預約數量example:
{
"intervals": [
{
"start_datetime": "2024-05-01T13:00",
"end_datetime": "2024-05-02T12:00",
"available_quantity": 20
},
{
"start_datetime": "2024-05-02T13:00",
"end_datetime": "2024-05-03T12:00",
"available_quantity": 5
},
]
}
status: 404 Not found content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Item ID not found"
}
合併 /routes/reserve/get_interval_item_availability.js(各時段物品能否預約)及 /routes/reserve/get_integral_item_availability.js(整體時段物品能否預約)
檔案:
資料庫 collection:
更改預約紀錄(reservation)的 verified 欄位值。
reservation_id
(path)/^[a-fA-F0-9]{24}$/
status: 200 OK
content: application/json
code
: string, 代碼message
: string, 提示訊息example:
{
"code": "R_SUCCESS",
"message": "success!"
}
status: 404 Not found
content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Reservation ID not found"
}
檢查所需的參數是否為 undefined,以免使用時因型別錯誤造成程式崩潰
解決存進資料庫的資料,未考量時區因素,直接當作 UTC 時間存入資料庫的錯誤
是否考慮在輸入時加入時區資料?
Add a check mechanism to ensure the item reservation's quantity is not over when the item reservation is on the same date and the total is more than the quantity that can be reserved.
Front-end can reject the user's answer when ze fills in the same date and the same item.
修改 Regular Expression 的規範,限制日期範圍不能過大,以免發生瘋狂切時段導致 CPU 佔用過高等問題
item_id
(query)/^[a-fA-F0-9]{24}$/
status: 200 OK
content: application/json
if item_id was given, it'll return an object. Otherwise, it'll return an array.
if item_id === undefined:
data
: Array
_id
: Object ID, 物品 _idname
: Object, 物品名稱
zh-tw
: string, 物品中文名稱en
: string, item English namequantity
: integer, 物品數量exception_time
: Array
if item_id !== undefined:
_id
: Object ID, 物品 _idname
: Object, 物品名稱
zh-tw
: string, 物品中文名稱en
: string, item English namequantity
: integer, 物品數量exception_time
: Array
example: item_id: undefined
{
"data": [
{
"_id": "65f48bbc6f21a65d302a6147",
"name": {
"zh-tw": "塑膠椅",
"en": "Plastic Chairs"
},
"quantity": 30,
"exception_time": []
},
{
"_id": "65f48bbc6f21a65d302a6148",
"name": {
"zh-tw": "長桌",
"en": "Tables"
},
"quantity": 2,
"exception_time": []
}
]
}
item_id: "65f48bbc6f21a65d302a6147"
{
{
"_id": "65f48bbc6f21a65d302a6147",
"name": {
"zh-tw": "塑膠椅",
"en": "Plastic Chairs"
},
"quantity": 30,
"exception_time": []
}
}
status: 404 Not found content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Item ID not found"
}
intervals
(query)space_id
(query)/^[a-fA-F0-9]{24}$/
start_datetime
(query) 查詢起始時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
(query)/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
status: 200 OK
content: application/json
if intervals is false
:
available
: integer, 是否可預約, 1:可 0:不可example:
{
"available": 0
}
if intervals is true
:
intervals
: Array, 各時段可否預約資料
start_datetime
: string, 時段開始時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
end_datetime
: string, 時段結束時間/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/
available
: integer, 是否可預約, 1:可 0:不可example:
{
"intervals": [
{
"start_datetime": "2024-05-02T13:00",
"end_datetime": "2024-05-02T17:00",
"available": 0
},
{
"start_datetime": "2024-05-02T18:00",
"end_datetime": "2024-05-02T22:00",
"available": 1
},
]
}
status: 404 Not found
content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Space ID not found"
}
合併 /routes/reserve/get_interval_space_availability.js(各時段場地能否預約)及 /routes/reserve/get_integral_space_availability.js(整體時段場地能否預約)
Make a basic reservation form (a form page, a confirmation page, and a result page).
space_id
(query)/^[a-fA-F0-9]{24}$/
status: 200 OK
content: application/json
if space_id was given, it'll return an object. Otherwise, it'll return an array.
if space_id === undefined:
data
: Array
_id
: string, 場地 _idname
: Object, 場地名稱
zh-tw
: string, 場地中文名稱en
: string, space English nameopen
: integer, 是否開放預約, 1: 可預約, 0: 不可預約exception_time
: Array
if space_id !== undefined:
_id
: string, 場地 _idname
: Object, 場地名稱
zh-tw
: string, 場地中文名稱en
: string, space English nameopen
: integer, 是否開放預約, 1: 可預約, 0: 不可預約exception_time
: Array
example: space_id: undefined
{
"data": [
{
"_id": "65f48bbc6f21a65d302a6149",
"name": {
"zh-tw": "學生活動中心",
"en": "Student Activity Center"
},
"open": 1,
"exception_time": []
},
{
"_id": "65f48bbc6f21a65d302a614a",
"name": {
"zh-tw": "勤樸樓B1小舞台",
"en": "Cin-Pu Building B1 Stage"
},
"open": 1,
"exception_time": []
}
]
}
space_id: "65f48bbc6f21a65d302a6149"
{
{
"_id": "65f48bbc6f21a65d302a6149",
"name": {
"zh-tw": "學生活動中心",
"en": "Student Activity Center"
},
"open": 1,
"exception_time": []
}
}
status: 404 Not found content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Space ID not found"
}
reservation_id
(path)/^[a-fA-F0-9]{24}$/
status: 200 OK
content: application/json
example:
{
"title": "UTSA reservation system",
"hello": "world"
}
status: 404 Not found content: application/json
error_code
: string, 錯誤代碼message
: string, 提示訊息example:
{
"error_code": "R_ID_NOT_FOUND",
"message": "Reservation ID not found"
}
Connect to the MongoDB Cluster and read/write successfully.
Plan the API structure between front-end and back-end
Make a page shows spaces/items availability in specific time slots.
Example:
Date | 08:00~12:00 | 13:00~17:00 | 18:00~22:00 |
---|---|---|---|
yyyy/mm/dd day | Available | Available | |
...... |
Additional task:
檔案:
資料庫 collection:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.