entity/wwwroot/api/entity_list.dspy

13 lines
793 B
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.

# entity_list.dspy —— 实体分页列表查询REST /api/*,宿主挂载后 /entity/api/entity_list.dspy
# 返回 {list, total};错误统一 {code, message, field, detail}
try:
result = await list_entities(params_kw)
if isinstance(result, dict) and 'list' in result and 'total' in result:
return {'code': 'OK', 'message': 'success', 'data': result}
return {'code': 'OK', 'message': 'success', 'data': {'list': result.get('list', []), 'total': result.get('total', 0)}}
except Exception as e:
if hasattr(e, 'to_dict'):
err = e.to_dict()
return {'code': err['code'], 'message': err['message'], 'field': err['field'], 'detail': err['detail']}
return {'code': 'DB_ERROR', 'message': '查询实体列表失败', 'field': '', 'detail': str(e)}