model.py 1.24 KB
Newer Older
Ai-Sasit's avatar
Ai-Sasit committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
def User_helper(user) -> dict:
    return {
        "id": str(user["_id"]),
        "username": str(user["username"]),
        "email": str(user["email"]),
        "password": str(user["password"])
    }

def Shop_helper(shop) -> dict:
    return {
        "id": str(shop["_id"]),
        "name": str(shop["name"]),
        "email": str(shop["email"]),
        "tel": str(shop["tel"]),
        "owner": str(shop["owner"]),
        "secret": str(shop["secret"])
    }

def Category_helper(category) -> dict:
    return {
        'id': str(category["_id"]),
        'shop_id': str(category["shop_id"]),
        'name': str(category["name"]),
    }
    
def Table_helper(table) -> dict:
    return {
        'id': str(table['_id']),
        'shop_id': str(table["shop_id"]),
        'session_key': str(table['session_key']),
        'name': str(table['name']),
        'sit_number': str(table["sit_number"]),
        'status': bool(table['status'])
    }

def Menu_helper(menu) -> dict:
    return {
        'id': str(menu['_id']),
        'shop_id': str(menu['shop_id']),
        'status': bool(menu['status']),
        'name': str(menu['name']),
        'category': str(menu['category']),
        'price': str(menu['price']),
        'images': list(menu['images'])
    }