feat/db-init #3

Open
Nitro wants to merge 41 commits from feat/db-init into dev
5 changed files with 56 additions and 2 deletions
Showing only changes of commit e80c5645f1 - Show all commits
+6
View File
@@ -0,0 +1,6 @@
from .robot import Robot
from .product import Product
from .inventory import InventoryRecord
from .user import User
__all__ = ['Robot', 'Product', 'InventoryRecord', 'User']
+14
View File
@@ -0,0 +1,14 @@
from dataclasses import dataclass
from datetime import datetime
@dataclass
class InventoryRecord:
id: int
robot_id: str
product_id: str
quantity: int
zone: str
row_number: int
shelf_number: int
status: str
scanned_at: datetime
created_at: datetime
+9
View File
@@ -0,0 +1,9 @@
from dataclasses import dataclass
@dataclass
class Product:
id: str
name: str
category: str
min_stock: int
optimal_stock: int
+13
View File
@@ -0,0 +1,13 @@
from dataclasses import dataclass
from datetime import datetime
from typing import Optional
@dataclass
class Robot:
id: str
status: str
battery_level: int
last_update: datetime
current_zone: Optional[str] = None
current_row: Optional[int] = None
current_shelf: Optional[int] = None
+14 -2
View File
@@ -1,13 +1,16 @@
from dataclasses import dataclass
import json
from datetime import datetime
from utils.token import generateKey
@dataclass
class User:
id: int
email: str
password_hash: str
name: str
role: str
token: str
created_at: datetime
def __init__(self, email: str, passwd: str):
#us = getUsModel() #возвращает словарь
3
@@ -18,3 +21,12 @@ class User:
def toJson(self):
return {"user": {"id": self.id, "name": self.name, "role": self.role}, "token": self.token}
def is_admin(self) -> bool:
return self.role == 'admin'
def is_operator(self) -> bool:
return self.role == 'operator'
def is_viewer(self) -> bool:
return self.role == 'viewer'