```
feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from typing import Any
|
||||
from uuid import uuid4
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
from sqlalchemy import func, select
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from app.core.config import get_settings
|
||||
from app.core.constants import ActorValue
|
||||
@@ -35,7 +37,10 @@ class EventQueryMixin:
|
||||
settings = get_settings()
|
||||
now = utc_now()
|
||||
record = DomainEvent(
|
||||
event_id=f"{EVENT_CODE_PREFIX}-{now:%Y%m%d%H%M%S%f}",
|
||||
event_id=(
|
||||
f"{EVENT_CODE_PREFIX}-{now:%Y%m%d%H%M%S%f}-"
|
||||
f"{uuid4().hex[:8]}"
|
||||
),
|
||||
event_type=event_type,
|
||||
source=source,
|
||||
aggregate_type=aggregate_type,
|
||||
@@ -46,8 +51,20 @@ class EventQueryMixin:
|
||||
next_attempt_at=now,
|
||||
max_attempts=settings.event_dispatch_max_attempts,
|
||||
)
|
||||
self.db.add(record)
|
||||
self.db.flush()
|
||||
if not idempotency_key:
|
||||
self.db.add(record)
|
||||
self.db.flush()
|
||||
return record
|
||||
|
||||
try:
|
||||
with self.db.begin_nested():
|
||||
self.db.add(record)
|
||||
self.db.flush()
|
||||
except IntegrityError:
|
||||
existing = self._find_idempotent_event(idempotency_key)
|
||||
if existing is None:
|
||||
raise
|
||||
return existing
|
||||
return record
|
||||
|
||||
def emit(
|
||||
|
||||
Reference in New Issue
Block a user