-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- added some models and schemas - still using sqlachemy
- Loading branch information
Showing
75 changed files
with
394 additions
and
1,500 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 |
---|---|---|
|
@@ -162,4 +162,4 @@ cython_debug/ | |
# Other folders | ||
data/db/*.db | ||
data/reports/* | ||
data/mindmaps/* | ||
data/mindmaps/* |
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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# app/api/endpoints/courses.py | ||
|
||
from fastapi import ( | ||
APIRouter, | ||
Depends, | ||
# HTTPException, | ||
) | ||
from sqlalchemy.orm import Session | ||
from app.database.session import get_db | ||
from app.schemas.course import ( | ||
CourseCreate, | ||
# CourseUpdate, | ||
CourseInDBBase, | ||
) | ||
from app.repositories.course_repository import ( | ||
create_course, | ||
) | ||
|
||
router = APIRouter() | ||
|
||
@router.post("/courses/", response_model=CourseInDBBase) | ||
def create_course_endpoint( | ||
course: CourseCreate, | ||
db: Session = Depends(get_db) | ||
) -> CourseInDBBase: | ||
return create_course(db, course) |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# app/api/endpoints/user.py | ||
|
||
from fastapi import ( | ||
APIRouter, | ||
Depends, | ||
HTTPException, | ||
) | ||
from sqlalchemy.orm import Session | ||
from app.database.session import get_db | ||
from app.schemas.user import ( | ||
UserCreate, | ||
UserUpdate, | ||
UserInDBBase, | ||
) | ||
from app.repositories.user_repository import ( | ||
create_user, | ||
get_user, | ||
get_users, | ||
update_user, | ||
delete_user, | ||
) | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.post("/users/", response_model=UserInDBBase) | ||
def create_user_endpoint( | ||
user: UserCreate, | ||
db: Session = Depends(get_db) | ||
) -> UserInDBBase: | ||
return create_user(db, user) | ||
|
||
|
||
@router.get("/users/{user_id}", response_model=UserInDBBase) | ||
def read_user(user_id: int, db: Session = Depends(get_db)) -> UserInDBBase: | ||
user = get_user(db, user_id) | ||
if user is None: | ||
raise HTTPException(status_code=404, detail="User not found") | ||
return user | ||
|
||
|
||
@router.get("/users/", response_model=list[UserInDBBase]) | ||
def read_users( | ||
skip: int = 0, | ||
limit: int = 10, | ||
db: Session = Depends(get_db) | ||
) -> list[UserInDBBase]: | ||
return get_users(db, skip, limit) | ||
|
||
|
||
@router.put("/users/{user_id}", response_model=UserInDBBase) | ||
def update_user_endpoint( | ||
user_id: int, | ||
user: UserUpdate, | ||
db: Session = Depends(get_db) | ||
) -> UserInDBBase: | ||
db_user = get_user(db, user_id) | ||
if db_user is None: | ||
raise HTTPException(status_code=404, detail="User not found") | ||
return update_user(db, user_id, user.model_dump()) | ||
|
||
|
||
@router.delete("/users/{user_id}", response_model=UserInDBBase) | ||
def delete_user_endpoint( | ||
user_id: int, | ||
db: Session = Depends(get_db) | ||
) -> UserInDBBase: | ||
user = delete_user(db, user_id) | ||
if user is None: | ||
raise HTTPException(status_code=404, detail="User not found") | ||
return user |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# app/api/v1/endpoints.py | ||
|
||
from fastapi import ( | ||
APIRouter, | ||
Depends, | ||
) | ||
from sqlalchemy.orm import Session | ||
from app.database.models import ( | ||
User, | ||
Course, | ||
Topic, | ||
) | ||
from app.database.session import get_db | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/users/", response_model=None) | ||
def read_users( | ||
skip: int = 0, | ||
limit: int = 10, | ||
db: Session = Depends(get_db) | ||
) -> list[User]: | ||
users = db.query(User).offset(skip).limit(limit).all() | ||
return users | ||
|
||
|
||
@router.get("/courses/", response_model=None) | ||
def read_courses( | ||
skip: int = 0, | ||
limit: int = 10, | ||
db: Session = Depends(get_db) | ||
) -> list[Course]: | ||
courses = db.query(Course).offset(skip).limit(limit).all() | ||
return courses | ||
|
||
|
||
@router.get("/topics/", response_model=None) | ||
def read_topics( | ||
skip: int = 0, | ||
limit: int = 10, | ||
db: Session = Depends(get_db) | ||
) -> list[Topic]: | ||
topics = db.query(Topic).offset(skip).limit(limit).all() | ||
return topics |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.