Skip to content

Commit

Permalink
Merge pull request #15 from l7wei/main
Browse files Browse the repository at this point in the history
feat: 讓各 API 格式更加一致
  • Loading branch information
l7wei authored Nov 6, 2023
2 parents f582aa3 + f0d2921 commit 1362267
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 695 deletions.
1 change: 0 additions & 1 deletion src/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
app.include_router(courses.router, prefix="/courses", tags=["Courses"])
app.include_router(dining.router, prefix="/dining", tags=["Dining"])
app.include_router(energy.router, prefix="/energy", tags=["Energy"])
app.include_router(librarys.router, prefix="/lib", tags=["Library"])
app.include_router(librarys.router, prefix="/librarys", tags=["Library"])
app.include_router(locations.router, prefix="/locations", tags=["Locations"])
app.include_router(newsletters.router, prefix="/newsletters", tags=["Newsletters"])
Expand Down
1 change: 0 additions & 1 deletion src/api/models/resources/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion src/api/models/resources/events.py

This file was deleted.

Empty file.
135 changes: 7 additions & 128 deletions src/api/routers/buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,76 +37,23 @@ class BusNandaData(BaseModel):
buses = Buses()


@router.get(
"/nanda",
responses={
200: {
"content": {
"application/json": {
"example": {
"toward_south_campus_info": {},
"weekday_bus_schedule_toward_south_campus": {},
"weekend_bus_schedule_toward_south_campus": {},
"toward_main_campus_info": {},
"weekday_bus_schedule_toward_main_campus": {},
"weekend_bus_schedule_toward_main_campus": {},
}
},
},
},
},
response_model=BusNandaData,
)
@router.get("/nanda", response_model=BusNandaData)
async def get_nanda():
"""
南大校區區間車資訊。
"""
return buses.get_nanda_data()


@router.get(
"/nanda/information/toward_main_campus",
responses={
200: {
"content": {
"application/json": {
"example": {
"direction": "往校本部 (To Main Campus)",
"duration": "2023/10/16 ~ 2023/11/12",
"route": "南大校區校門口右側(食品路校牆邊) → 台積館(經寶山路) → 人社院/生科館 → 綜二館 → 北校門口",
"routeEN": "The right side of NandaCampus front gate(Shipin Road) → TSMC Building(Baoshan Rd.) → CHSS/CLS Builing → General Building II→School North Gate",
}
},
},
},
},
response_model=BusInfo,
)
@router.get("/nanda/information/toward_main_campus", response_model=BusInfo)
async def get_nanda_toward_main_campus_info() -> BusInfo:
"""
南大往本部區間車資訊。
"""
return buses.get_nanda_data()["toward_main_campus_info"]


@router.get(
"/nanda/information/toward_south_campus",
responses={
200: {
"content": {
"application/json": {
"example": {
"direction": "往南大校區 (To Nanda Campus)",
"duration": "2023/10/16 ~ 2023/11/12",
"route": "北校門口 → 綜二館 → 人社院/生科館 → 台積館(經寶山路) → 南大校區校門口右側(食品路校牆邊)",
"routeEN": "School North Gate → General Building II → CHSS/CLS Building → TSMC Building(Baoshan Rd.) → The right side of NandaCampus front gate(Shipin Road)",
}
},
},
},
},
response_model=BusInfo,
)
@router.get("/nanda/information/toward_south_campus", response_model=BusInfo)
async def get_nanda_toward_south_campus_info() -> BusInfo:
"""
本部往南大區間車資訊。
Expand All @@ -115,23 +62,7 @@ async def get_nanda_toward_south_campus_info() -> BusInfo:


@router.get(
"/nanda/schedules/weekday/toward_main_campus",
responses={
200: {
"content": {
"application/json": {
"example": [
{"time": "7:20", "description": ""},
{"time": "7:33", "description": "此為付費市區公車(83號公車直達兩校區)"},
{
"...",
},
]
},
},
},
},
response_model=list[BusSchedule],
"/nanda/schedules/weekday/toward_main_campus", response_model=list[BusSchedule]
)
async def get_nanda_weekday_bus_schedule_toward_main_campus() -> list[BusSchedule]:
"""
Expand All @@ -141,23 +72,7 @@ async def get_nanda_weekday_bus_schedule_toward_main_campus() -> list[BusSchedul


@router.get(
"/nanda/schedules/weekday/toward_south_campus",
responses={
200: {
"content": {
"application/json": {
"example": [
{"time": "7:30", "description": "此為付費市區公車(83號公車直達兩校區)"},
{"time": "7:40", "description": ""},
{
"...",
},
]
},
},
},
},
response_model=list[BusSchedule],
"/nanda/schedules/weekday/toward_south_campus", response_model=list[BusSchedule]
)
async def get_nanda_weekday_bus_schedule_toward_south_campus() -> list[BusSchedule]:
"""
Expand All @@ -167,25 +82,7 @@ async def get_nanda_weekday_bus_schedule_toward_south_campus() -> list[BusSchedu


@router.get(
"/nanda/schedules/weekend/toward_main_campus",
responses={
200: {
"content": {
"application/json": {
"example": [
{"time": "8:00", "description": ""},
{"time": "12:00", "description": ""},
{"time": "14:00", "description": ""},
{"time": "17:00", "description": ""},
{
"...",
},
]
},
},
},
},
response_model=list[BusSchedule],
"/nanda/schedules/weekend/toward_main_campus", response_model=list[BusSchedule]
)
async def get_nanda_weekend_bus_schedule_toward_main_campus() -> list[BusSchedule]:
"""
Expand All @@ -195,25 +92,7 @@ async def get_nanda_weekend_bus_schedule_toward_main_campus() -> list[BusSchedul


@router.get(
"/nanda/schedules/weekend/toward_south_campus",
responses={
200: {
"content": {
"application/json": {
"example": [
{"time": "8:30", "description": ""},
{"time": "12:30", "description": ""},
{"time": "14:30", "description": ""},
{"time": "17:30", "description": ""},
{
"...",
},
]
},
},
},
},
response_model=list[BusSchedule],
"/nanda/schedules/weekend/toward_south_campus", response_model=list[BusSchedule]
)
async def get_nanda_weekend_bus_schedule_toward_south_campus() -> list[BusSchedule]:
"""
Expand Down
Loading

0 comments on commit 1362267

Please sign in to comment.