pbl_domain_ext/wwwroot/api/pbl_team_bind_world.dspy

35 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_team_bind_world.dspy — 契约端点bind_team_to_world设计 §3.3 接口 12
# 实现pbl_domain_ext/api.py:bind_team_to_worldenv.pbl_bind_team_to_world
# 错误分支PBL_E_NOT_FOUNDworld 基表不存在)/ PBL_E_DUPLICATE同团队重复绑定
debug('pbl_team_bind_world.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}
_ext = params_kw.get('ext_json')
if isinstance(_ext, str) and _ext.strip():
try:
_ext = json.loads(_ext)
except Exception:
pass
try:
_data = await pbl_bind_team_to_world(
params_kw.get('world_id'),
params_kw.get('team_id'),
params_kw.get('tenant_id'),
class_id=params_kw.get('class_id'),
blueprint_id=params_kw.get('blueprint_id'),
ext_json=_ext,
)
debug('pbl_team_bind_world.dspy: OK world_id=%s team_id=%s'
% (params_kw.get('world_id'), params_kw.get('team_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_team_bind_world.dspy: FAIL code=%s msg=%s' % (_code, _msg))
return {'success': False, 'error_code': _code, 'message': _msg,
'detail': _detail, 'http_status': _HTTP.get(_code, 500)}