from typing import Optional from uuid import UUID, uuid4 from sqlmodel import Session, select from app.database.models.shop_model import Shop, ShopStatus from app.database.models.user_model import User from app.schemas.shop_schemas import ShopCreate def get_shop_id_from_uuid(session: Session, shop_id: int) -> Optional[UUID]: stmt = select(Shop).where(Shop.id == shop_id) db_shop = session.exec(stmt).one_or_none() return db_shop def create_shop(session: Session, shop_data: ShopCreate, creator: User) -> None: shop_uuid = uuid4() new_shop = Shop( uuid=shop_uuid, owner_id=creator.id, name=shop_data.name, description=shop_data.description, status=ShopStatus.INACTIVE, contact_email=creator.email, phone_number=creator.phone_number, currency=shop_data.currency ) session.add(new_shop) session.commit()