30 lines
1.5 KiB
Plaintext
30 lines
1.5 KiB
Plaintext
# api/pbl_domain_ref_bind.dspy — 契约端点:bind_ref(设计 §3.1 接口 1)
|
||
# 实现:pbl_domain_ext/api.py:bind_ref(经 init.py 注册为 env.pbl_bind_ref)
|
||
# 入参:ref_type(world/scene/entity) ref_id blueprint_id class_id team_id ext tenant_id
|
||
# 说明:ext 原样透传(dict 或 JSON 字符串均可,由 api._dump_ext 统一校验/序列化)
|
||
debug('pbl_domain_ref_bind.dspy: START params_kw=%s' % dict(params_kw))
|
||
|
||
_HTTP = {'PBL_E_VALIDATION': 400, 'PBL_E_NOT_FOUND': 404, 'PBL_E_DUPLICATE': 409,
|
||
'PBL_E_FORBIDDEN': 403, 'PBL_E_INTERNAL': 500}
|
||
|
||
try:
|
||
_data = await pbl_bind_ref(
|
||
params_kw.get('ref_type'),
|
||
params_kw.get('ref_id'),
|
||
blueprint_id=params_kw.get('blueprint_id'),
|
||
class_id=params_kw.get('class_id'),
|
||
team_id=params_kw.get('team_id'),
|
||
ext=params_kw.get('ext'),
|
||
tenant_id=params_kw.get('tenant_id'),
|
||
)
|
||
debug('pbl_domain_ref_bind.dspy: OK ref_type=%s ref_id=%s'
|
||
% (params_kw.get('ref_type'), params_kw.get('ref_id')))
|
||
return {'success': True, 'error_code': None, 'message': 'ok', 'data': _data}
|
||
except Exception as exc:
|
||
_code = getattr(exc, 'code', None) or 'PBL_E_INTERNAL'
|
||
_msg = getattr(exc, 'message', None) or str(exc)
|
||
_detail = getattr(exc, 'detail', None) or {}
|
||
debug('pbl_domain_ref_bind.dspy: FAIL code=%s msg=%s' % (_code, _msg))
|
||
return {'success': False, 'error_code': _code, 'message': _msg,
|
||
'detail': _detail, 'http_status': _HTTP.get(_code, 500)}
|