feat/db-init #3
@@ -77,8 +77,11 @@ class AIPredictionsRepository:
|
||||
logger.error(f"Ошибка получения последних прогнозов по товарам: {e}")
|
||||
return []
|
||||
|
||||
def create_prediction(self, product_id: str, prediction_date: date,
|
||||
days_until_stockout: int, recommended_order: int,
|
||||
def create_prediction(self,
|
||||
product_id: str,
|
||||
prediction_date: date,
|
||||
days_until_stockout: int,
|
||||
recommended_order: int,
|
||||
confidence_score: float) -> Optional[int]:
|
||||
try:
|
||||
with get_connection() as conn:
|
||||
|
||||
@@ -48,8 +48,15 @@ class InventoryRepository:
|
||||
logger.error(f"Ошибка получения записи инвентаризации {record_id}: {e}")
|
||||
return None
|
||||
|
||||
def create_record(self, robot_id: str, product_id: str, quantity: int, zone: str,
|
||||
row_number: int, shelf_number: int, status: str, scanned_at: datetime) -> Optional[int]:
|
||||
def create_record(self,
|
||||
robot_id: str,
|
||||
product_id: str,
|
||||
quantity: int,
|
||||
zone: str,
|
||||
row_number: int,
|
||||
shelf_number: int,
|
||||
status: str,
|
||||
scanned_at: datetime) -> Optional[int]:
|
||||
try:
|
||||
with get_connection() as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# db/repositories/robot_repository.py
|
||||
from typing import List, Optional
|
||||
import logging
|
||||
from db.connection import get_connection
|
||||
@@ -44,8 +43,13 @@ class RobotRepository:
|
||||
logger.error(f"Ошибка получения робота {robot_id}: {e}")
|
||||
return None
|
||||
|
||||
def update_robot(self, robot_id: str, status: str = None, battery_level: int = None,
|
||||
current_zone: str = None, current_row: int = None, current_shelf: int = None) -> bool:
|
||||
def update_robot(self,
|
||||
robot_id: str,
|
||||
status: str = None,
|
||||
battery_level: int = None,
|
||||
current_zone: str = None,
|
||||
current_row: int = None,
|
||||
current_shelf: int = None) -> bool:
|
||||
try:
|
||||
with get_connection() as conn:
|
||||
with conn.cursor() as cur:
|
||||
@@ -127,7 +131,10 @@ class RobotRepository:
|
||||
logger.error(f"Ошибка получения роботов в зоне {zone}: {e}")
|
||||
return []
|
||||
|
||||
def create_robot(self, robot_id: str, status: str = 'active', battery_level: int = 100) -> bool:
|
||||
def create_robot(self,
|
||||
robot_id: str,
|
||||
status: str = 'active',
|
||||
battery_level: int = 100) -> bool:
|
||||
try:
|
||||
with get_connection() as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
@@ -57,7 +57,11 @@ class UserRepository:
|
||||
logger.error(f"Ошибка получения пользователя по email {email}: {e}")
|
||||
return None
|
||||
|
||||
def create_user(self, email: str, password_hash: str, name: str, role: str) -> Optional[User]:
|
||||
def create_user(self,
|
||||
email: str,
|
||||
password_hash: str,
|
||||
name: str,
|
||||
role: str) -> Optional[User]:
|
||||
try:
|
||||
with get_connection() as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
Reference in New Issue
Block a user