change structure to make package build
This commit is contained in:
17
app/model/card.py
Normal file
17
app/model/card.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
class CardBase(BaseModel):
|
||||
id: int
|
||||
uuid: str
|
||||
user_id: str
|
||||
|
||||
class AccessAuthorizationBase(BaseModel):
|
||||
name: str
|
||||
is_active: bool
|
||||
|
||||
class AccessAuthorizationCreate(AccessAuthorizationBase):
|
||||
pass
|
||||
|
||||
class AccessAuthorization(AccessAuthorizationBase):
|
||||
class Config:
|
||||
from_attributes = True
|
||||
35
app/model/dbModels.py
Normal file
35
app/model/dbModels.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from __future__ import annotations
|
||||
from typing import List, Optional
|
||||
|
||||
from sqlalchemy import ForeignKey
|
||||
from sqlalchemy import Column, Integer, String, Boolean
|
||||
from sqlalchemy.orm import Mapped, mapped_column, DeclarativeBase, relationship
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
||||
name: Mapped[str]
|
||||
email: Mapped[Optional[str]]
|
||||
password: Mapped[str]
|
||||
is_admin: Mapped[bool]
|
||||
|
||||
class AccessAuthorization(Base): #parent
|
||||
__tablename__ = "access_authorizations"
|
||||
|
||||
name: Mapped[str] = mapped_column(primary_key=True, index=True)
|
||||
is_active: Mapped[bool]
|
||||
card_id: Mapped[List["Card"]] = relationship(back_populates="user")
|
||||
|
||||
class Card(Base): #child
|
||||
__tablename__ = "cards"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
||||
uuid: Mapped[str] = mapped_column(index=True)
|
||||
user_id = mapped_column(ForeignKey("access_authorizations.name"))
|
||||
user: Mapped["AccessAuthorization"] = relationship(back_populates="card_id")
|
||||
|
||||
|
||||
14
app/model/user.py
Normal file
14
app/model/user.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
class UserBase(BaseModel):
|
||||
name: str
|
||||
email: str | None
|
||||
is_admin: bool
|
||||
|
||||
class UserCreate(UserBase):
|
||||
password: str
|
||||
|
||||
class User(UserBase):
|
||||
id: int
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Reference in New Issue
Block a user