pbl_domain_ext/wwwroot/api/pbl_domain_ref_bind.dspy

30 lines
1.5 KiB
Plaintext
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.

# 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_json tenant_id
# 说明ext_json 原样透传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_json=params_kw.get('ext_json'),
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)}