lot_manager/api.py

29 lines
734 B
Python
Executable File

from db.models.base import BaseResponse
from db.models.lot_data_model import LOT_DATA
from db.repository import add_kb_to_db, delete_kb_detail_by_time, get_kb_detail
def add(data: LOT_DATA):
try:
add_kb_to_db(data)
return BaseResponse()
except Exception as e:
print(e)
return BaseResponse(code=500, msg=str(e))
def delete(start_time, end_time):
try:
delete_kb_detail_by_time(start_time, end_time)
return BaseResponse()
except Exception as e:
return BaseResponse(code=500, msg=str(e))
def get_data():
try:
data = get_kb_detail()
return BaseResponse(data=data)
except Exception as e:
return BaseResponse(code=404, msg=str(e))