ForcePilot/backend/package/yuxi/channels/adapters/identity_resolver_adapter.py
Kris b88c0ae29e feat(channels): 批量新增多渠道网关限界上下文基础代码与契约
新增完整的 channels 限界上下文模块,包含契约层、领域核心层、应用服务、管道编排、插件体系、基础设施组合根等全层级代码,新增飞书与微信 iLink 渠道插件基础结构,补充各类 DTO、端口协议与领域服务实现。
2026-07-02 03:22:12 +08:00

53 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""IdentityResolverAdapter实现 IdentityResolverPort默认降级实现。
- 默认降级实现,由插件可覆盖
- resolve 返回 None触发降级至 DB 查询)
- getConfidence 返回 0.0
依赖边界:只依赖 yuxi.channels.contract端口 + DTO
"""
from __future__ import annotations
from yuxi.channels.contract.dtos.identity import (
IdentityResolveCmd,
IdentityResolveResult,
)
from yuxi.channels.contract.ports.driven.identity_resolver_port import IdentityResolverPort
class IdentityResolverAdapter(IdentityResolverPort):
"""身份解析被驱动适配器(默认降级实现)。
默认实现不接入外部身份源,``resolve`` 返回 ``None`` 触发降级至 DB
查询,``getConfidence`` 返回 ``0.0``。实际身份解析逻辑由插件注册时
注入。
"""
async def resolve(self, cmd: IdentityResolveCmd) -> IdentityResolveResult | None:
"""解析身份(默认降级,返回 None
默认不接入外部身份源,返回 None 触发降级至 DB 查询。
实际解析逻辑由插件覆盖。
Args:
cmd: 身份解析命令,携带渠道类型、对端 ID 与账户 ID。
Returns:
None默认降级
"""
return None
async def getConfidence(self, identity_id: str) -> float:
"""查询身份置信度(默认降级,返回 0.0)。
默认返回 ``0.0``,实际置信度由插件覆盖。
Args:
identity_id: 统一身份 ID。
Returns:
0.0(默认降级)。
"""
return 0.0