diff --git a/ruoyi-fastapi-backend/module_admin/annotation/log_annotation.py b/ruoyi-fastapi-backend/module_admin/annotation/log_annotation.py index 3bc1c2d..19ac84e 100644 --- a/ruoyi-fastapi-backend/module_admin/annotation/log_annotation.py +++ b/ruoyi-fastapi-backend/module_admin/annotation/log_annotation.py @@ -175,9 +175,14 @@ class Log: await LoginLogService.add_login_log_services(query_db, LogininforModel(**login_log)) else: - current_user = await LoginService.get_current_user(request, token, query_db) - oper_name = current_user.user.user_name if current_user.user else None - dept_name = current_user.user.dept.dept_name if current_user.user.dept else None + try: + current_user = await LoginService.get_current_user(request, token, query_db) + oper_name = current_user.user.user_name if current_user.user else None + dept_name = current_user.user.dept.dept_name if current_user.user.dept else None + except: + oper_name = None + dept_name = None + operation_log = OperLogModel( title=self.title, businessType=self.business_type, diff --git a/ruoyi-fastapi-backend/module_admin/controller/test_controller.py b/ruoyi-fastapi-backend/module_admin/controller/test_controller.py index 292c720..8413c12 100644 --- a/ruoyi-fastapi-backend/module_admin/controller/test_controller.py +++ b/ruoyi-fastapi-backend/module_admin/controller/test_controller.py @@ -23,8 +23,9 @@ async def hello(request: Request, print("名称", name) user_name = await TestService.get_user_name(query_db,) return user_name -@Log(title='测试Log', business_type=BusinessType.OTHER, log_type='operation') + @testController.post('/hello_post_json', response_model=str) +@Log(title='测试Log', business_type=BusinessType.OTHER, log_type='operation') async def hello_post_json( request: Request, login_info: TestUserNamePage,