fix:列表查询

This commit is contained in:
gongwenxin
2025-08-08 15:35:09 +08:00
parent 4bf7ee9988
commit e776736966
4 changed files with 29 additions and 775554 deletions
+12 -20
View File
@@ -683,34 +683,26 @@ class InputParser:
create_request_body_schema = {"type": "object", "properties": {"version": {"type": "string", "example": version}, "act": {"type": "integer", "example": 0}, "data": {"type": "array", "items": model}}, "required": ["data"]}
endpoints.append(DMSEndpoint(path=create_path, method='post', title=f"Create {name}", request_body={'content': {'application/json': {'schema': create_request_body_schema}}}, responses=success_response, test_mode='scenario_only', operation_id=f"create_{name}", category_name=category_name, raw_record=item, model_pk_name=pk_name, identity_id_list=identity_id_list))
# List Endpoint (POST)
# List Endpoint (POST) - 🔧 添加pageNo和pageSize查询参数
list_path = f"/api/dms/{dms_instance_code}/v1/{name}/{version}"
list_response_schema = {"type": "object", "properties": {"code": {"type": "integer"}, "message": {"type": "string"}, "data": {"type": "array", "items": model}}}
endpoints.append(DMSEndpoint(path=list_path, method='post', title=f"List {name}", request_body={'content': {'application/json': {'schema': {}}}}, responses={'200': {'description': 'Successful Operation', 'content': {'application/json': {'schema': list_response_schema}}}}, test_mode='standalone', operation_id=f"list_{name}", category_name=category_name, raw_record=item, model_pk_name=pk_name, identity_id_list=identity_id_list))
list_parameters = [
{'name': 'pageNo', 'in': 'query', 'required': False, 'description': '页码(从1开始)', 'schema': {'type': 'integer', 'default': 1}},
{'name': 'pageSize', 'in': 'query', 'required': False, 'description': '分页大小(最大值200)', 'schema': {'type': 'integer', 'default': 1000}}
]
endpoints.append(DMSEndpoint(path=list_path, method='post', title=f"List {name}", request_body={'content': {'application/json': {'schema': {}}}}, responses={'200': {'description': 'Successful Operation', 'content': {'application/json': {'schema': list_response_schema}}}}, parameters=list_parameters, test_mode='standalone', operation_id=f"list_{name}", category_name=category_name, raw_record=item, model_pk_name=pk_name, identity_id_list=identity_id_list))
# Read Endpoint (GET)
# Read Endpoint (GET) - 🔧 只为单主键模型生成查询详情接口
if isinstance(identity_id_list, list) and len(identity_id_list) > 1:
# 多主键:使用复合路径参数
path_params = []
read_parameters = []
for pk_field in identity_id_list:
path_params.append(f"{{{pk_field}}}")
if pk_field in model['properties']:
pk_field_schema = model['properties'][pk_field]
else:
pk_field_schema = {"type": "string"}
read_parameters.append({'name': pk_field, 'in': 'path', 'required': True, 'description': f'The {pk_field} of the {name}', 'schema': pk_field_schema})
read_path = f"/api/dms/{dms_instance_code}/v1/{name}/{version}/" + "/".join(path_params)
self.logger.info(f"创建多主键读取端点 '{name}',路径参数: {identity_id_list}")
# 🚫 多主键模型:不生成查询详情接口
self.logger.info(f"跳过多主键模型 '{name}' 的查询详情接口生成,主键数量: {len(identity_id_list)}")
else:
# 单主键:使用单个id参数
# 单主键模型:生成查询详情接口
read_path = f"/api/dms/{dms_instance_code}/v1/{name}/{version}/{{id}}"
read_parameters = [{'name': 'id', 'in': 'path', 'required': True, 'description': f'The ID of the {name}, maps to {pk_name}', 'schema': pk_schema}]
read_response_schema = {"type": "object", "properties": {"code": {"type": "integer"}, "message": {"type": "string"}, "data": model}}
endpoints.append(DMSEndpoint(path=read_path, method='get', title=f"Read {name}", request_body=None, responses={'200': {'description': 'Successful Operation', 'content': {'application/json': {'schema': read_response_schema}}}}, parameters=read_parameters, test_mode='scenario_only', operation_id=f"read_{name}", category_name=category_name, raw_record=item, model_pk_name=pk_name, identity_id_list=identity_id_list))
self.logger.info(f"创建单主键读取端点 '{name}',路径参数: id")
read_response_schema = {"type": "object", "properties": {"code": {"type": "integer"}, "message": {"type": "string"}, "data": model}}
endpoints.append(DMSEndpoint(path=read_path, method='get', title=f"Read {name}", request_body=None, responses={'200': {'description': 'Successful Operation', 'content': {'application/json': {'schema': read_response_schema}}}}, parameters=read_parameters, test_mode='scenario_only', operation_id=f"read_{name}", category_name=category_name, raw_record=item, model_pk_name=pk_name, identity_id_list=identity_id_list))
# Update Endpoint (PUT)
update_path = f"/api/dms/{dms_instance_code}/v1/{name}"