31 lines
921 B
Python
31 lines
921 B
Python
# -*- coding:utf-8 -*-
|
|
"""
|
|
@Author : xuxingchen
|
|
@Created :
|
|
@Updated :
|
|
@Contact : xuxingchen@sinochem.com
|
|
@Desc : 设备管理界面控制逻辑
|
|
"""
|
|
from fastapi import APIRouter, Request, Header
|
|
|
|
from models.devices import DevicesTable
|
|
from routers.login import authenticate_token
|
|
from utils import logger
|
|
from utils.logger import TOKEN_ERROR
|
|
from utils.database import get_table_handler
|
|
from utils.misc import InvalidException
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/getAllDevicesInfo", summary="获取全量的设备信息")
|
|
async def get_all_devices_info(request: Request, token: str = Header(...)):
|
|
"""获取全量的设备信息列表"""
|
|
if not authenticate_token(token):
|
|
raise InvalidException(TOKEN_ERROR)
|
|
th = get_table_handler()
|
|
devices_info = DevicesTable.get_devices_info(th)
|
|
resp = {"devices": devices_info}
|
|
logger.Logger.debug(f"{request.url.path} {resp}")
|
|
return resp
|