Fixed a variable
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from app.routers import info
|
from app.routers import info, delivery, customer
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
@@ -22,7 +22,8 @@ app.add_middleware(
|
|||||||
|
|
||||||
|
|
||||||
app.include_router(info.router)
|
app.include_router(info.router)
|
||||||
|
app.include_router(delivery.router)
|
||||||
|
app.include_router(customer.router)
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
def read_root():
|
def read_root():
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Customer_Customer(Base):
|
|||||||
customer_town = Column(VARCHAR(140))
|
customer_town = Column(VARCHAR(140))
|
||||||
customer_state = Column(Integer)
|
customer_state = Column(Integer)
|
||||||
customer_zip = Column(VARCHAR(25))
|
customer_zip = Column(VARCHAR(25))
|
||||||
customer_first_call = Column(TIMESTAMP(), default=datetime.utcnow())
|
customer_first_call = Column(TIMESTAMP(), default=datetime.datetime.utcnow())
|
||||||
customer_email = Column(VARCHAR(500))
|
customer_email = Column(VARCHAR(500))
|
||||||
customer_automatic = Column(Integer)
|
customer_automatic = Column(Integer)
|
||||||
customer_phone_number = Column(VARCHAR(25))
|
customer_phone_number = Column(VARCHAR(25))
|
||||||
|
|||||||
31
app/routers/customer.py
Normal file
31
app/routers/customer.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
from fastapi import APIRouter
|
||||||
|
from app.database import session
|
||||||
|
import os
|
||||||
|
|
||||||
|
from app.models.customer import Customer_Customer
|
||||||
|
|
||||||
|
|
||||||
|
router = APIRouter(
|
||||||
|
prefix="/customer",
|
||||||
|
tags=["customer"],
|
||||||
|
responses={404: {"description": "Not found"}},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/{user_id}")
|
||||||
|
async def get_customer(user_id):
|
||||||
|
|
||||||
|
get_the_customer = (session.query(Customer_Customer)
|
||||||
|
.filter(Customer_Customer.id == user_id)
|
||||||
|
.first())
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
"ok": True,
|
||||||
|
"customer_phone_number": get_the_customer.customer_phone_number,
|
||||||
|
"customer_first_name": get_the_customer.customer_first_name,
|
||||||
|
"customer_last_name": get_the_customer.customer_last_name,
|
||||||
|
"account_number": get_the_customer.account_number,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
50
app/routers/delivery.py
Normal file
50
app/routers/delivery.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
from fastapi import APIRouter
|
||||||
|
from app.database import session
|
||||||
|
import os
|
||||||
|
from app.schema.price import SchemaPricing
|
||||||
|
from app.models.delivery import Delivery
|
||||||
|
from app.models.pricing import Pricing_Oil_Oil
|
||||||
|
|
||||||
|
|
||||||
|
router = APIRouter(
|
||||||
|
prefix="/delivery",
|
||||||
|
tags=["delivery"],
|
||||||
|
responses={404: {"description": "Not found"}},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/{ticket_id}")
|
||||||
|
async def get_delivery(ticket_id):
|
||||||
|
|
||||||
|
get_the_delivery = (session.query(Delivery)
|
||||||
|
.filter(Delivery.id == int((ticket_id)))
|
||||||
|
.first())
|
||||||
|
|
||||||
|
return {
|
||||||
|
"ok": True,
|
||||||
|
"dispatcher_notes": get_the_delivery.dispatcher_notes,
|
||||||
|
"payment_type": get_the_delivery.payment_type,
|
||||||
|
"customer_address": get_the_delivery.customer_address,
|
||||||
|
"customer_town": get_the_delivery.customer_town,
|
||||||
|
"customer_state": get_the_delivery.customer_state,
|
||||||
|
"customer_zip": get_the_delivery.customer_zip,
|
||||||
|
"when_ordered": get_the_delivery.when_ordered,
|
||||||
|
"when_delivered": get_the_delivery.when_delivered,
|
||||||
|
"gallons_delivered": get_the_delivery.gallons_delivered,
|
||||||
|
"expected_delivery_date": get_the_delivery.expected_delivery_date,
|
||||||
|
"customer_price": get_the_delivery.customer_price,
|
||||||
|
"driver_employee_id": get_the_delivery.driver_employee_id,
|
||||||
|
"customer_id": get_the_delivery.customer_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/past/{user_id}")
|
||||||
|
async def get_delivery(user_id):
|
||||||
|
|
||||||
|
get_the_deliveries = (session.query(Delivery)
|
||||||
|
.filter(Delivery.customer_id == int(user_id))
|
||||||
|
.all())
|
||||||
|
|
||||||
|
return get_the_deliveries
|
||||||
|
|
||||||
Reference in New Issue
Block a user