# 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.visitor_type_service import Visitor_typeService
# from module_admin.entity.vo.visitor_type_vo import DeleteVisitor_typeModel, Visitor_typeModel, Visitor_typePageQueryModel
# 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
#
#
# visitor_typeController = APIRouter(prefix='/system/visitor_type', dependencies=[Depends(LoginService.get_current_user)])
#
#
# @visitor_typeController.get(
#     '/list', response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('system:visitor_type:list'))]
# )
# async def get_system_visitor_type_list(
#     request: Request,
# visitor_type_page_query: Visitor_typePageQueryModel = Depends(Visitor_typePageQueryModel.as_query),
#     query_db: AsyncSession = Depends(get_db),
# ):
#     # 获取分页数据
#     visitor_type_page_query_result = await Visitor_typeService.get_visitor_type_list_services(query_db, visitor_type_page_query, is_page=True)
#     logger.info('获取成功')
#
#     return ResponseUtil.success(model_content=visitor_type_page_query_result)
#
#
# @visitor_typeController.post('', dependencies=[Depends(CheckUserInterfaceAuth('system:visitor_type:add'))])
# @ValidateFields(validate_model='add_visitor_type')
# @Log(title='访客类型', business_type=BusinessType.INSERT)
# async def add_system_visitor_type(
#     request: Request,
#     add_visitor_type: Visitor_typeModel,
#     query_db: AsyncSession = Depends(get_db),
#     current_user: CurrentUserModel = Depends(LoginService.get_current_user),
# ):
#     add_visitor_type.create_time = datetime.now()
#     add_visitor_type.create_by = current_user.user.user_name
#     add_visitor_type.update_time = datetime.now()
#     add_visitor_type.update_by = current_user.user.user_name
#     add_visitor_type_result = await Visitor_typeService.add_visitor_type_services(query_db, add_visitor_type)
#     logger.info(add_visitor_type_result.message)
#
#     return ResponseUtil.success(msg=add_visitor_type_result.message)
#
#
# @visitor_typeController.put('', dependencies=[Depends(CheckUserInterfaceAuth('system:visitor_type:edit'))])
# @ValidateFields(validate_model='edit_visitor_type')
# @Log(title='访客类型', business_type=BusinessType.UPDATE)
# async def edit_system_visitor_type(
#     request: Request,
#     edit_visitor_type: Visitor_typeModel,
#     query_db: AsyncSession = Depends(get_db),
#     current_user: CurrentUserModel = Depends(LoginService.get_current_user),
# ):
#     edit_visitor_type.update_by = current_user.user.user_name
#     edit_visitor_type.update_time = datetime.now()
#     edit_visitor_type_result = await Visitor_typeService.edit_visitor_type_services(query_db, edit_visitor_type)
#     logger.info(edit_visitor_type_result.message)
#
#     return ResponseUtil.success(msg=edit_visitor_type_result.message)
#
#
# @visitor_typeController.delete('/{type_ids}', dependencies=[Depends(CheckUserInterfaceAuth('system:visitor_type:remove'))])
# @Log(title='访客类型', business_type=BusinessType.DELETE)
# async def delete_system_visitor_type(request: Request, type_ids: str, query_db: AsyncSession = Depends(get_db)):
#     delete_visitor_type = DeleteVisitor_typeModel(typeIds=type_ids)
#     delete_visitor_type_result = await Visitor_typeService.delete_visitor_type_services(query_db, delete_visitor_type)
#     logger.info(delete_visitor_type_result.message)
#
#     return ResponseUtil.success(msg=delete_visitor_type_result.message)
#
#
# @visitor_typeController.get(
#     '/{type_id}', response_model=Visitor_typeModel, dependencies=[Depends(CheckUserInterfaceAuth('system:visitor_type:query'))]
# )
# async def query_detail_system_visitor_type(request: Request, type_id: int, query_db: AsyncSession = Depends(get_db)):
#     visitor_type_detail_result = await Visitor_typeService.visitor_type_detail_services(query_db, type_id)
#     logger.info(f'获取type_id为{type_id}的信息成功')
#
#     return ResponseUtil.success(data=visitor_type_detail_result)
#
#
# @visitor_typeController.post('/export', dependencies=[Depends(CheckUserInterfaceAuth('system:visitor_type:export'))])
# @Log(title='访客类型', business_type=BusinessType.EXPORT)
# async def export_system_visitor_type_list(
#     request: Request,
#     visitor_type_page_query: Visitor_typePageQueryModel = Form(),
#     query_db: AsyncSession = Depends(get_db),
# ):
#     # 获取全量数据
#     visitor_type_query_result = await Visitor_typeService.get_visitor_type_list_services(query_db, visitor_type_page_query, is_page=False)
#     visitor_type_export_result = await Visitor_typeService.export_visitor_type_list_services(visitor_type_query_result)
#     logger.info('导出成功')
#
#     return ResponseUtil.streaming(data=bytes2file_response(visitor_type_export_result))
