mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 13:12:24 +00:00
Fix typos in code and comments (#1115)
This commit is contained in:
@@ -16,14 +16,14 @@ class OperaLog(DataClassBase):
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
trace_id: Mapped[str] = mapped_column(sa.String(32), comment='请求跟踪 ID')
|
||||
username: Mapped[str | None] = mapped_column(sa.String(64), comment='用户名')
|
||||
method: Mapped[str] = mapped_column(sa.String(32), comment='请求类型')
|
||||
method: Mapped[str] = mapped_column(sa.String(32), comment='请求方法')
|
||||
title: Mapped[str] = mapped_column(sa.String(256), comment='操作模块')
|
||||
path: Mapped[str] = mapped_column(sa.String(512), comment='请求路径')
|
||||
ip: Mapped[str] = mapped_column(sa.String(64), comment='IP地址')
|
||||
ip: Mapped[str] = mapped_column(sa.String(64), comment='IP 地址')
|
||||
country: Mapped[str | None] = mapped_column(sa.String(64), comment='国家')
|
||||
region: Mapped[str | None] = mapped_column(sa.String(64), comment='地区')
|
||||
city: Mapped[str | None] = mapped_column(sa.String(64), comment='城市')
|
||||
user_agent: Mapped[str | None] = mapped_column(sa.String(512), comment='请求头')
|
||||
user_agent: Mapped[str | None] = mapped_column(sa.String(512), comment='用户代理')
|
||||
os: Mapped[str | None] = mapped_column(sa.String(64), comment='操作系统')
|
||||
browser: Mapped[str | None] = mapped_column(sa.String(64), comment='浏览器')
|
||||
device: Mapped[str | None] = mapped_column(sa.String(64), comment='设备')
|
||||
|
||||
@@ -93,7 +93,7 @@ class OperaLogCipherType(IntEnum):
|
||||
aes = 0
|
||||
md5 = 1
|
||||
itsdangerous = 2
|
||||
plan = 3
|
||||
plain = 3
|
||||
|
||||
|
||||
class StatusType(IntEnum):
|
||||
|
||||
@@ -54,7 +54,7 @@ class I18n:
|
||||
case 'json':
|
||||
self.locales[lang] = json.loads(f.read())
|
||||
case 'yaml' | 'yml':
|
||||
self.locales[lang] = yaml.full_load(f.read())
|
||||
self.locales[lang] = yaml.safe_load(f.read())
|
||||
|
||||
def t(self, key: str, default: Any | None = None, **kwargs) -> str:
|
||||
"""
|
||||
|
||||
@@ -25,18 +25,18 @@ class AccessMiddleware(BaseHTTPMiddleware):
|
||||
:param call_next: 下一个中间件或路由处理函数
|
||||
:return:
|
||||
"""
|
||||
path = request.url.path
|
||||
method = request.method
|
||||
|
||||
if method != 'OPTIONS':
|
||||
log.debug(f'--> 请求开始[{path if not request.url.query else request.url.path + "/" + request.url.query}]')
|
||||
|
||||
perf_time = time.perf_counter()
|
||||
ctx.perf_time = perf_time
|
||||
|
||||
start_time = timezone.now()
|
||||
ctx.start_time = start_time
|
||||
|
||||
path = request.url.path
|
||||
method = request.method
|
||||
|
||||
if method != 'OPTIONS':
|
||||
log.debug(f'--> 请求开始[{path if not request.url.query else request.url.path + "?" + request.url.query}]')
|
||||
|
||||
if path.startswith(settings.FASTAPI_API_V1_PATH):
|
||||
PROMETHEUS_REQUEST_IN_PROGRESS_GAUGE.labels(app_name=PROMETHEUS_APP_NAME, method=method, path=path).inc()
|
||||
PROMETHEUS_REQUEST_COUNTER.labels(app_name=PROMETHEUS_APP_NAME, method=method, path=path).inc()
|
||||
|
||||
@@ -3,6 +3,7 @@ from collections.abc import Sequence
|
||||
from jinja2 import Environment, FileSystemLoader, Template, select_autoescape
|
||||
from pydantic.alias_generators import to_pascal
|
||||
|
||||
from backend.common.enums import PrimaryKeyType
|
||||
from backend.core.conf import settings
|
||||
from backend.plugin.code_generator.model import GenBusiness, GenColumn
|
||||
from backend.plugin.code_generator.path_conf import JINJA2_TEMPLATE_DIR
|
||||
@@ -109,7 +110,7 @@ class GenTemplate:
|
||||
'now': timezone.now(),
|
||||
}
|
||||
|
||||
if settings.DATABASE_PK_MODE == 'snowflake':
|
||||
if PrimaryKeyType.snowflake == settings.DATABASE_PK_MODE:
|
||||
vars_dict['parent_menu_id'] = snowflake.generate()
|
||||
vars_dict['button_ids'] = [snowflake.generate() for _ in range(4)]
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ def get_request_ip(request: Request) -> str:
|
||||
if forwarded:
|
||||
return forwarded.split(',')[0]
|
||||
|
||||
if request.client is None:
|
||||
return '127.0.0.1'
|
||||
|
||||
# 忽略 pytest
|
||||
if request.client.host == 'testclient':
|
||||
return '127.0.0.1'
|
||||
|
||||
Reference in New Issue
Block a user