```
feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
This commit is contained in:
@@ -9,6 +9,7 @@ from app.application.feishu.results import command_result
|
||||
from app.core.config import get_settings
|
||||
from app.modules.feishu.constants import FeishuCommandName, FeishuReplyType
|
||||
from app.modules.feishu.service import FeishuService
|
||||
from app.modules.feishu_users.principal import FeishuPrincipal
|
||||
from app.modules.market.chart import render_market_chart
|
||||
from app.modules.market.service import MarketService
|
||||
|
||||
@@ -38,6 +39,7 @@ def handle_market_command(
|
||||
chat_id: str | None,
|
||||
actor: str,
|
||||
auto_reply: bool,
|
||||
principal: FeishuPrincipal | None = None,
|
||||
) -> dict[str, Any] | None:
|
||||
"""Handle market analysis and watchlist commands."""
|
||||
|
||||
@@ -54,6 +56,31 @@ def handle_market_command(
|
||||
and not comparison
|
||||
):
|
||||
return None
|
||||
service = MarketService(db)
|
||||
owner_id = principal.owner_id if principal is not None else None
|
||||
if add:
|
||||
item = service.add_watchlist(actor, add.group(1), owner_id=owner_id)
|
||||
return _text_result(
|
||||
feishu,
|
||||
FeishuCommandName.WATCHLIST_ADD,
|
||||
"自选股",
|
||||
f"已加入自选:{item['symbol']}",
|
||||
chat_id,
|
||||
actor,
|
||||
auto_reply,
|
||||
)
|
||||
if text == "查看自选":
|
||||
items = service.watchlist(actor, owner_id=owner_id)
|
||||
content = "自选股:" + ("、".join(item["symbol"] for item in items) or "暂无")
|
||||
return _text_result(
|
||||
feishu,
|
||||
FeishuCommandName.WATCHLIST_LIST,
|
||||
"自选股",
|
||||
content,
|
||||
chat_id,
|
||||
actor,
|
||||
auto_reply,
|
||||
)
|
||||
if not get_settings().market_analysis_enabled:
|
||||
return _text_result(
|
||||
feishu,
|
||||
@@ -65,40 +92,6 @@ def handle_market_command(
|
||||
auto_reply,
|
||||
)
|
||||
|
||||
service = MarketService(db)
|
||||
if add:
|
||||
if get_settings().read_only_mode:
|
||||
return _text_result(
|
||||
feishu,
|
||||
FeishuCommandName.WATCHLIST_ADD,
|
||||
"自选股",
|
||||
"当前为只读模式,不能修改自选股。请由管理员启用操作后重试。",
|
||||
chat_id,
|
||||
actor,
|
||||
auto_reply,
|
||||
)
|
||||
item = service.add_watchlist(actor, add.group(1))
|
||||
return _text_result(
|
||||
feishu,
|
||||
FeishuCommandName.WATCHLIST_ADD,
|
||||
"自选股",
|
||||
f"已加入自选:{item['symbol']}",
|
||||
chat_id,
|
||||
actor,
|
||||
auto_reply,
|
||||
)
|
||||
if text == "查看自选":
|
||||
items = service.watchlist(actor)
|
||||
content = "自选股:" + ("、".join(item["symbol"] for item in items) or "暂无")
|
||||
return _text_result(
|
||||
feishu,
|
||||
FeishuCommandName.WATCHLIST_LIST,
|
||||
"自选股",
|
||||
content,
|
||||
chat_id,
|
||||
actor,
|
||||
auto_reply,
|
||||
)
|
||||
if text == "最新公告":
|
||||
items = service.announcements(limit=10)["items"]
|
||||
content = (
|
||||
|
||||
Reference in New Issue
Block a user