pbl_domain_ext/wwwroot/api/pbl_domain_ref_update.dspy

37 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_update.dspy — 契约端点update_ref设计 §3.1 接口 5
# 实现pbl_domain_ext/api.py:update_refenv.pbl_update_ref
# 入参ref_type ref_id data{class_id,team_id,ext_json,blueprint_id} tenant_id
debug('pbl_domain_ref_update.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}
_data_in = params_kw.get('data')
if isinstance(_data_in, str) and _data_in.strip():
try:
_data_in = json.loads(_data_in)
except Exception:
_data_in = None
if not isinstance(_data_in, dict):
_data_in = {}
for _k in ('blueprint_id', 'class_id', 'team_id', 'ext_json'):
if _k not in _data_in and params_kw.get(_k) is not None:
_data_in[_k] = params_kw.get(_k)
try:
_data = await pbl_update_ref(
params_kw.get('ref_type'),
params_kw.get('ref_id'),
_data_in,
tenant_id=params_kw.get('tenant_id'),
)
debug('pbl_domain_ref_update.dspy: OK id=%s' % (_data or {}).get('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_update.dspy: FAIL code=%s msg=%s' % (_code, _msg))
return {'success': False, 'error_code': _code, 'message': _msg,
'detail': _detail, 'http_status': _HTTP.get(_code, 500)}