23 lines
1.2 KiB
Plaintext
23 lines
1.2 KiB
Plaintext
# api/pbl_world_get_context.dspy — 契约端点:get_world_with_pbl_context(设计 §3.2 接口 9)
|
||
# 实现:pbl_domain_ext/api.py:get_world_with_pbl_context(env.pbl_get_world_with_pbl_context)
|
||
# 出参:world 基表字段 + pbl_context{tenant_id,blueprint_id,class_id,team_id,ext_json}
|
||
debug('pbl_world_get_context.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_get_world_with_pbl_context(
|
||
params_kw.get('world_id'),
|
||
params_kw.get('tenant_id'),
|
||
)
|
||
debug('pbl_world_get_context.dspy: OK world_id=%s' % params_kw.get('world_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_world_get_context.dspy: FAIL code=%s msg=%s' % (_code, _msg))
|
||
return {'success': False, 'error_code': _code, 'message': _msg,
|
||
'detail': _detail, 'http_status': _HTTP.get(_code, 500)}
|