|
@ -12,6 +12,7 @@ from typing import Optional |
|
|
from module_admin.service.login_service import LoginService |
|
|
from module_admin.service.login_service import LoginService |
|
|
from module_admin.service.log_service import OperationLogService, LoginLogService |
|
|
from module_admin.service.log_service import OperationLogService, LoginLogService |
|
|
from module_admin.entity.vo.log_vo import OperLogModel, LogininforModel |
|
|
from module_admin.entity.vo.log_vo import OperLogModel, LogininforModel |
|
|
|
|
|
from config.env import AppConfig |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def log_decorator(title: str, business_type: int, log_type: Optional[str] = 'operation'): |
|
|
def log_decorator(title: str, business_type: int, log_type: Optional[str] = 'operation'): |
|
@ -50,6 +51,7 @@ def log_decorator(title: str, business_type: int, log_type: Optional[str] = 'ope |
|
|
# 获取请求的ip及ip归属区域 |
|
|
# 获取请求的ip及ip归属区域 |
|
|
oper_ip = request.headers.get("X-Forwarded-For") |
|
|
oper_ip = request.headers.get("X-Forwarded-For") |
|
|
oper_location = '内网IP' |
|
|
oper_location = '内网IP' |
|
|
|
|
|
if AppConfig.app_ip_location_query: |
|
|
try: |
|
|
try: |
|
|
if oper_ip != '127.0.0.1' and oper_ip != 'localhost': |
|
|
if oper_ip != '127.0.0.1' and oper_ip != 'localhost': |
|
|
ip_result = requests.get(f'https://qifu-api.baidubce.com/ip/geo/v1/district?ip={oper_ip}') |
|
|
ip_result = requests.get(f'https://qifu-api.baidubce.com/ip/geo/v1/district?ip={oper_ip}') |
|
@ -65,7 +67,6 @@ def log_decorator(title: str, business_type: int, log_type: Optional[str] = 'ope |
|
|
except Exception as e: |
|
|
except Exception as e: |
|
|
oper_location = '未知' |
|
|
oper_location = '未知' |
|
|
print(e) |
|
|
print(e) |
|
|
finally: |
|
|
|
|
|
# 根据不同的请求类型使用不同的方法获取请求参数 |
|
|
# 根据不同的请求类型使用不同的方法获取请求参数 |
|
|
content_type = request.headers.get("Content-Type") |
|
|
content_type = request.headers.get("Content-Type") |
|
|
if content_type and ("multipart/form-data" in content_type or 'application/x-www-form-urlencoded' in content_type): |
|
|
if content_type and ("multipart/form-data" in content_type or 'application/x-www-form-urlencoded' in content_type): |
|
|