[haiz] haiz

This commit is contained in:
2024-06-27 04:35:56 +00:00
parent e6923277ed
commit 1c205c69ac
51 changed files with 958 additions and 279 deletions

View File

@ -1,6 +1,6 @@
from backend.core.config import get_app_settings
from backend.core.security.security import hash_password
from backend.db.models import User
from backend.db.models import Users
from backend.schemas import UserCreate, UserProfile
from sqlalchemy.orm import Session
from uuid import UUID
@ -11,7 +11,7 @@ settings = get_app_settings()
class RepositoryUsers:
def __init__(self):
self.user = User()
self.user = Users()
def get_all(self, skip: int = 0, limit: int = 100):
return self.user.query.offset(skip).limit(limit).all()
@ -25,7 +25,7 @@ class RepositoryUsers:
def create(self, db: Session, user: UserCreate | UserSeeds):
try:
password = getattr(user, "password")
db_user = User(**user.dict(exclude={"password"}), password=hash_password(password))
db_user = Users(**user.dict(exclude={"password"}), password=hash_password(password))
db.add(db_user)
db.commit()
except Exception:
@ -41,7 +41,7 @@ class RepositoryUsers:
return None
try:
user.update_password()
self.user.query.where(User.id == user_id).update(user.dict(exclude_unset=True, exclude_none=True))
self.user.query.where(Users.id == user_id).update(user.dict(exclude_unset=True, exclude_none=True))
db.commit()
except Exception:
db.rollback()