added data models
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
from .auth import LoginRequest, LoginResponse
|
||||||
|
|
||||||
|
__all__ = ["LoginRequest", "LoginResponse"]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
"""Authentication models for request and response validation."""
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class LoginRequest(BaseModel):
|
||||||
|
"""Request model for user login."""
|
||||||
|
|
||||||
|
username: str
|
||||||
|
password: str
|
||||||
|
|
||||||
|
|
||||||
|
class LoginResponse(BaseModel):
|
||||||
|
"""Response model for successful login."""
|
||||||
|
|
||||||
|
message: str
|
||||||
|
username: str
|
||||||
|
access_token: str
|
||||||
|
token_type: str = "bearer"
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
"""Database models package."""
|
||||||
|
|
||||||
|
from baby_monitor.models.db.user import User
|
||||||
|
|
||||||
|
__all__ = ["User"]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"""Database models."""
|
||||||
|
|
||||||
|
from sqlalchemy import Column, Integer, String, DateTime
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from baby_monitor.repositories.dependencies.get_database import Base
|
||||||
|
|
||||||
|
|
||||||
|
class User(Base):
|
||||||
|
"""User database model."""
|
||||||
|
|
||||||
|
__tablename__ = "users"
|
||||||
|
|
||||||
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
|
username = Column(String, unique=True, index=True, nullable=False)
|
||||||
|
hashed_password = Column(String, nullable=False)
|
||||||
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f"<User(id={self.id}, username='{self.username}')>"
|
||||||
Reference in New Issue
Block a user