132 lines
7.2 KiB
Python
132 lines
7.2 KiB
Python
from datetime import datetime
|
|
from fastapi import APIRouter, Depends, Form, Request
|
|
from pydantic_validation_decorator import ValidateFields
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from config.enums import BusinessType
|
|
from config.get_db import get_db
|
|
from module_admin.annotation.log_annotation import Log
|
|
from module_admin.aspect.interface_auth import CheckUserInterfaceAuth
|
|
from module_admin.entity.vo.user_vo import CurrentUserModel
|
|
from module_admin.service.login_service import LoginService
|
|
from module_admin.service.identification_statistics_service import Identification_statisticsService
|
|
from module_admin.entity.vo.identification_statistics_vo import DeleteIdentification_statisticsModel, Identification_statisticsModel, Identification_statisticsPageQueryModel
|
|
from utils.common_util import bytes2file_response
|
|
from utils.log_util import logger
|
|
from utils.page_util import PageResponseModel
|
|
from utils.response_util import ResponseUtil
|
|
|
|
|
|
identification_statisticsController = APIRouter(prefix='/system/identification_statistics', dependencies=[Depends(LoginService.get_current_user)])
|
|
|
|
# 获取今天的识别统计数据
|
|
@identification_statisticsController.get('/today')
|
|
async def get_today_identification_statistics(request: Request, query_db: AsyncSession = Depends(get_db)):
|
|
"""
|
|
获取今天的识别统计数据
|
|
:param request:
|
|
:param query_db:
|
|
:return:
|
|
"""
|
|
logger.info('获取今天的识别统计数据')
|
|
identification_statistics = await Identification_statisticsService.get_today_identification_statistics_services(query_db)
|
|
return ResponseUtil.success(data = identification_statistics)
|
|
|
|
# 获取总的识别统计数据
|
|
@identification_statisticsController.get('/total')
|
|
async def get_total_identification_statistics(request: Request, query_db: AsyncSession = Depends(get_db)):
|
|
"""
|
|
获取今天的识别统计数据
|
|
:param request:
|
|
:param query_db:
|
|
:return:
|
|
"""
|
|
logger.info('获取今天的识别统计数据')
|
|
identification_statistics = await Identification_statisticsService.get_total_identification_statistics_services(query_db)
|
|
return ResponseUtil.success(data = identification_statistics)
|
|
|
|
|
|
|
|
|
|
# @identification_statisticsController.get(
|
|
# '/list', response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('system:identification_statistics:list'))]
|
|
# )
|
|
# async def get_system_identification_statistics_list(
|
|
# request: Request,
|
|
# identification_statistics_page_query: Identification_statisticsPageQueryModel = Depends(Identification_statisticsPageQueryModel.as_query),
|
|
# query_db: AsyncSession = Depends(get_db),
|
|
# ):
|
|
# # 获取分页数据
|
|
# identification_statistics_page_query_result = await Identification_statisticsService.get_identification_statistics_list_services(query_db, identification_statistics_page_query, is_page=True)
|
|
# logger.info('获取成功')
|
|
|
|
# return ResponseUtil.success(model_content=identification_statistics_page_query_result)
|
|
|
|
|
|
# @identification_statisticsController.post('', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_statistics:add'))])
|
|
# @ValidateFields(validate_model='add_identification_statistics')
|
|
# @Log(title='识别统计', business_type=BusinessType.INSERT)
|
|
# async def add_system_identification_statistics(
|
|
# request: Request,
|
|
# add_identification_statistics: Identification_statisticsModel,
|
|
# query_db: AsyncSession = Depends(get_db),
|
|
# current_user: CurrentUserModel = Depends(LoginService.get_current_user),
|
|
# ):
|
|
# add_identification_statistics.create_time = datetime.now()
|
|
# add_identification_statistics.create_by = current_user.user.user_name
|
|
# add_identification_statistics_result = await Identification_statisticsService.add_identification_statistics_services(query_db, add_identification_statistics)
|
|
# logger.info(add_identification_statistics_result.message)
|
|
|
|
# return ResponseUtil.success(msg=add_identification_statistics_result.message)
|
|
|
|
|
|
# @identification_statisticsController.put('', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_statistics:edit'))])
|
|
# @ValidateFields(validate_model='edit_identification_statistics')
|
|
# @Log(title='识别统计', business_type=BusinessType.UPDATE)
|
|
# async def edit_system_identification_statistics(
|
|
# request: Request,
|
|
# edit_identification_statistics: Identification_statisticsModel,
|
|
# query_db: AsyncSession = Depends(get_db),
|
|
# current_user: CurrentUserModel = Depends(LoginService.get_current_user),
|
|
# ):
|
|
# edit_identification_statistics.update_by = current_user.user.user_name
|
|
# edit_identification_statistics.update_time = datetime.now()
|
|
# edit_identification_statistics_result = await Identification_statisticsService.edit_identification_statistics_services(query_db, edit_identification_statistics)
|
|
# logger.info(edit_identification_statistics_result.message)
|
|
|
|
# return ResponseUtil.success(msg=edit_identification_statistics_result.message)
|
|
|
|
|
|
# @identification_statisticsController.delete('/{ids}', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_statistics:remove'))])
|
|
# @Log(title='识别统计', business_type=BusinessType.DELETE)
|
|
# async def delete_system_identification_statistics(request: Request, ids: str, query_db: AsyncSession = Depends(get_db)):
|
|
# delete_identification_statistics = DeleteIdentification_statisticsModel(ids=ids)
|
|
# delete_identification_statistics_result = await Identification_statisticsService.delete_identification_statistics_services(query_db, delete_identification_statistics)
|
|
# logger.info(delete_identification_statistics_result.message)
|
|
|
|
# return ResponseUtil.success(msg=delete_identification_statistics_result.message)
|
|
|
|
|
|
# @identification_statisticsController.get(
|
|
# '/{id}', response_model=Identification_statisticsModel, dependencies=[Depends(CheckUserInterfaceAuth('system:identification_statistics:query'))]
|
|
# )
|
|
# async def query_detail_system_identification_statistics(request: Request, id: int, query_db: AsyncSession = Depends(get_db)):
|
|
# identification_statistics_detail_result = await Identification_statisticsService.identification_statistics_detail_services(query_db, id)
|
|
# logger.info(f'获取id为{id}的信息成功')
|
|
|
|
# return ResponseUtil.success(data=identification_statistics_detail_result)
|
|
|
|
|
|
# @identification_statisticsController.post('/export', dependencies=[Depends(CheckUserInterfaceAuth('system:identification_statistics:export'))])
|
|
# @Log(title='识别统计', business_type=BusinessType.EXPORT)
|
|
# async def export_system_identification_statistics_list(
|
|
# request: Request,
|
|
# identification_statistics_page_query: Identification_statisticsPageQueryModel = Form(),
|
|
# query_db: AsyncSession = Depends(get_db),
|
|
# ):
|
|
# # 获取全量数据
|
|
# identification_statistics_query_result = await Identification_statisticsService.get_identification_statistics_list_services(query_db, identification_statistics_page_query, is_page=False)
|
|
# identification_statistics_export_result = await Identification_statisticsService.export_identification_statistics_list_services(identification_statistics_query_result)
|
|
# logger.info('导出成功')
|
|
|
|
# return ResponseUtil.streaming(data=bytes2file_response(identification_statistics_export_result))
|