# 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.explanation_style_service import Explanation_styleService
# from module_admin.entity.vo.explanation_style_vo import DeleteExplanation_styleModel, Explanation_styleModel, Explanation_stylePageQueryModel
# 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
#
#
# explanation_styleController = APIRouter(prefix='/system/explanation_style', dependencies=[Depends(LoginService.get_current_user)])
#
#
# @explanation_styleController.get(
#     '/list', response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_style:list'))]
# )
# async def get_system_explanation_style_list(
#     request: Request,
# explanation_style_page_query: Explanation_stylePageQueryModel = Depends(Explanation_stylePageQueryModel.as_query),
#     query_db: AsyncSession = Depends(get_db),
# ):
#     # 获取分页数据
#     explanation_style_page_query_result = await Explanation_styleService.get_explanation_style_list_services(query_db, explanation_style_page_query, is_page=True)
#     logger.info('获取成功')
#
#     return ResponseUtil.success(model_content=explanation_style_page_query_result)
#
#
# @explanation_styleController.post('', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_style:add'))])
# @ValidateFields(validate_model='add_explanation_style')
# @Log(title='讲解风格', business_type=BusinessType.INSERT)
# async def add_system_explanation_style(
#     request: Request,
#     add_explanation_style: Explanation_styleModel,
#     query_db: AsyncSession = Depends(get_db),
#     current_user: CurrentUserModel = Depends(LoginService.get_current_user),
# ):
#     add_explanation_style.create_time = datetime.now()
#     add_explanation_style.create_by = current_user.user.user_name
#     add_explanation_style.update_time = datetime.now()
#     add_explanation_style.update_by = current_user.user.user_name
#     add_explanation_style_result = await Explanation_styleService.add_explanation_style_services(query_db, add_explanation_style)
#     logger.info(add_explanation_style_result.message)
#
#     return ResponseUtil.success(msg=add_explanation_style_result.message)
#
#
# @explanation_styleController.put('', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_style:edit'))])
# @ValidateFields(validate_model='edit_explanation_style')
# @Log(title='讲解风格', business_type=BusinessType.UPDATE)
# async def edit_system_explanation_style(
#     request: Request,
#     edit_explanation_style: Explanation_styleModel,
#     query_db: AsyncSession = Depends(get_db),
#     current_user: CurrentUserModel = Depends(LoginService.get_current_user),
# ):
#     edit_explanation_style.update_by = current_user.user.user_name
#     edit_explanation_style.update_time = datetime.now()
#     edit_explanation_style_result = await Explanation_styleService.edit_explanation_style_services(query_db, edit_explanation_style)
#     logger.info(edit_explanation_style_result.message)
#
#     return ResponseUtil.success(msg=edit_explanation_style_result.message)
#
#
# @explanation_styleController.delete('/{explanation_style_ids}', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_style:remove'))])
# @Log(title='讲解风格', business_type=BusinessType.DELETE)
# async def delete_system_explanation_style(request: Request, explanation_style_ids: str, query_db: AsyncSession = Depends(get_db)):
#     delete_explanation_style = DeleteExplanation_styleModel(explanationStyleIds=explanation_style_ids)
#     delete_explanation_style_result = await Explanation_styleService.delete_explanation_style_services(query_db, delete_explanation_style)
#     logger.info(delete_explanation_style_result.message)
#
#     return ResponseUtil.success(msg=delete_explanation_style_result.message)
#
#
# @explanation_styleController.get(
#     '/{explanation_style_id}', response_model=Explanation_styleModel, dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_style:query'))]
# )
# async def query_detail_system_explanation_style(request: Request, explanation_style_id: int, query_db: AsyncSession = Depends(get_db)):
#     explanation_style_detail_result = await Explanation_styleService.explanation_style_detail_services(query_db, explanation_style_id)
#     logger.info(f'获取explanation_style_id为{explanation_style_id}的信息成功')
#
#     return ResponseUtil.success(data=explanation_style_detail_result)
#
#
# @explanation_styleController.post('/export', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_style:export'))])
# @Log(title='讲解风格', business_type=BusinessType.EXPORT)
# async def export_system_explanation_style_list(
#     request: Request,
#     explanation_style_page_query: Explanation_stylePageQueryModel = Form(),
#     query_db: AsyncSession = Depends(get_db),
# ):
#     # 获取全量数据
#     explanation_style_query_result = await Explanation_styleService.get_explanation_style_list_services(query_db, explanation_style_page_query, is_page=False)
#     explanation_style_export_result = await Explanation_styleService.export_explanation_style_list_services(explanation_style_query_result)
#     logger.info('导出成功')
#
#     return ResponseUtil.streaming(data=bytes2file_response(explanation_style_export_result))
