diff --git a/apps/api/app/api/routes/health.py b/apps/api/app/api/routes/health.py index f897e7f44..644196b32 100644 --- a/apps/api/app/api/routes/health.py +++ b/apps/api/app/api/routes/health.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timezone import psycopg2 import redis @@ -13,7 +13,7 @@ router = APIRouter(tags=["Health"]) async def health_check(): return { "status": "healthy", - "timestamp": datetime.utcnow().isoformat(), + "timestamp": datetime.now(timezone.utc).isoformat(), "version": settings.APP_VERSION, } @@ -33,7 +33,7 @@ async def startup_check(): all_ready = all(check["status"] == "healthy" for check in checks.values()) response = { "status": "started" if all_ready else "starting", - "timestamp": datetime.utcnow().isoformat(), + "timestamp": datetime.now(timezone.utc).isoformat(), "checks": checks, } if not all_ready: diff --git a/packages/application/auth/jwt_service.py b/packages/application/auth/jwt_service.py old mode 100755 new mode 100644 index 2a08bc450..0d7f17b1b --- a/packages/application/auth/jwt_service.py +++ b/packages/application/auth/jwt_service.py @@ -1,6 +1,6 @@ """JWT Token 生成、验证、解析服务""" -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from typing import Any, Dict, Optional import jwt @@ -88,7 +88,7 @@ class JWTService(JWTServicePort): Returns: JWT Token 字符串 """ - now = datetime.utcnow() + now = datetime.now(timezone.utc) expire = now + timedelta(minutes=self.config.ACCESS_TOKEN_EXPIRE_MINUTES) # noqa: E501 payload = { @@ -115,7 +115,7 @@ class JWTService(JWTServicePort): Returns: JWT Token 字符串 """ - now = datetime.utcnow() + now = datetime.now(timezone.utc) expire = now + timedelta(days=self.config.REFRESH_TOKEN_EXPIRE_DAYS) payload = {