# 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_content_type_service import Explanation_content_typeService
# from module_admin.entity.vo.explanation_content_type_vo import DeleteExplanation_content_typeModel, Explanation_content_typeModel, Explanation_content_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


# explanation_content_typeController = APIRouter(prefix='/system/explanation_content_type'
#                                                , dependencies=[Depends(LoginService.get_current_user)]
#                                                )
#
#
# @explanation_content_typeController.get(
#     '/list', response_model=PageResponseModel
#     # , dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_content_type:list'))]
# )
# async def get_system_explanation_content_type_list(
#     request: Request,
# # explanation_content_type_page_query: Explanation_content_typePageQueryModel = Depends(Explanation_content_typePageQueryModel.as_query),
#     query_db: AsyncSession = Depends(get_db),
# ):
#     # 获取分页数据
#     # explanation_content_type_page_query_result = await Explanation_content_typeService.get_explanation_content_type_list_services(query_db, explanation_content_type_page_query, is_page=True)
#
#     explanation_content_type_query_result = await Explanation_content_typeService.get_explanation_content_type_list_services(query_db, is_page=False)
#
#     logger.info('获取成功')
#
#     return ResponseUtil.success(model_content=explanation_content_type_query_result)


# @explanation_content_typeController.post('', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_content_type:add'))])
# @ValidateFields(validate_model='add_explanation_content_type')
# @Log(title='讲解内容类型', business_type=BusinessType.INSERT)
# async def add_system_explanation_content_type(
#     request: Request,
#     add_explanation_content_type: Explanation_content_typeModel,
#     query_db: AsyncSession = Depends(get_db),
#     current_user: CurrentUserModel = Depends(LoginService.get_current_user),
# ):
#     add_explanation_content_type.create_time = datetime.now()
#     add_explanation_content_type.create_by = current_user.user.user_name
#     add_explanation_content_type.update_time = datetime.now()
#     add_explanation_content_type.update_by = current_user.user.user_name
#     add_explanation_content_type_result = await Explanation_content_typeService.add_explanation_content_type_services(query_db, add_explanation_content_type)
#     logger.info(add_explanation_content_type_result.message)
#
#     return ResponseUtil.success(msg=add_explanation_content_type_result.message)
#
#
# @explanation_content_typeController.put('', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_content_type:edit'))])
# @ValidateFields(validate_model='edit_explanation_content_type')
# @Log(title='讲解内容类型', business_type=BusinessType.UPDATE)
# async def edit_system_explanation_content_type(
#     request: Request,
#     edit_explanation_content_type: Explanation_content_typeModel,
#     query_db: AsyncSession = Depends(get_db),
#     current_user: CurrentUserModel = Depends(LoginService.get_current_user),
# ):
#     edit_explanation_content_type.update_by = current_user.user.user_name
#     edit_explanation_content_type.update_time = datetime.now()
#     edit_explanation_content_type_result = await Explanation_content_typeService.edit_explanation_content_type_services(query_db, edit_explanation_content_type)
#     logger.info(edit_explanation_content_type_result.message)
#
#     return ResponseUtil.success(msg=edit_explanation_content_type_result.message)
#
#
# @explanation_content_typeController.delete('/{content_type_ids}', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_content_type:remove'))])
# @Log(title='讲解内容类型', business_type=BusinessType.DELETE)
# async def delete_system_explanation_content_type(request: Request, content_type_ids: str, query_db: AsyncSession = Depends(get_db)):
#     delete_explanation_content_type = DeleteExplanation_content_typeModel(contentTypeIds=content_type_ids)
#     delete_explanation_content_type_result = await Explanation_content_typeService.delete_explanation_content_type_services(query_db, delete_explanation_content_type)
#     logger.info(delete_explanation_content_type_result.message)
#
#     return ResponseUtil.success(msg=delete_explanation_content_type_result.message)
#
#
# @explanation_content_typeController.get(
#     '/{content_type_id}', response_model=Explanation_content_typeModel, dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_content_type:query'))]
# )
# async def query_detail_system_explanation_content_type(request: Request, content_type_id: int, query_db: AsyncSession = Depends(get_db)):
#     explanation_content_type_detail_result = await Explanation_content_typeService.explanation_content_type_detail_services(query_db, content_type_id)
#     logger.info(f'获取content_type_id为{content_type_id}的信息成功')
#
#     return ResponseUtil.success(data=explanation_content_type_detail_result)
#
#
# @explanation_content_typeController.post('/export', dependencies=[Depends(CheckUserInterfaceAuth('system:explanation_content_type:export'))])
# @Log(title='讲解内容类型', business_type=BusinessType.EXPORT)
# async def export_system_explanation_content_type_list(
#     request: Request,
#     explanation_content_type_page_query: Explanation_content_typePageQueryModel = Form(),
#     query_db: AsyncSession = Depends(get_db),
# ):
#     # 获取全量数据
#     explanation_content_type_query_result = await Explanation_content_typeService.get_explanation_content_type_list_services(query_db, explanation_content_type_page_query, is_page=False)
#     explanation_content_type_export_result = await Explanation_content_typeService.export_explanation_content_type_list_services(explanation_content_type_query_result)
#     logger.info('导出成功')
#
#     return ResponseUtil.streaming(data=bytes2file_response(explanation_content_type_export_result))
