From e723ada8fb34f3ab221042eff0dcaea32b1d362c Mon Sep 17 00:00:00 2001 From: jingrow Date: Sun, 3 Aug 2025 19:14:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=9F=E5=90=8D=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=9F=9F=E5=90=8D=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E8=AE=B0=E5=BD=95=E7=9A=84api=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/api/domain_west.py | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index 2666005..ea1c75d 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -280,6 +280,23 @@ class WestDomain: } return self._make_request('/domain/?act=getdns', 'POST', body_params=body_params) + def get_dns_records_paginated(self, domain: str, limit: int = 20, pageno: int = 1) -> Dict[str, Any]: + """ + 获取域名解析记录(支持分页) + + Args: + domain: 域名 + limit: 每页大小,默认20 + pageno: 第几页,默认为1 + """ + body_params = { + 'act': 'getdnsrecord', + 'domain': domain, + 'limit': limit, + 'pageno': pageno, + } + return self._make_request('/domain/', 'POST', body_params=body_params) + def modify_dns_records(self, domain: str, records: List[Dict]) -> Dict[str, Any]: """ 修改域名DNS记录 @@ -754,6 +771,49 @@ def west_domain_get_dns(**data): return client.get_dns_records(domain) +@jingrow.whitelist() +def get_west_domain_dns_records(**data): + """获取域名解析记录(支持分页)""" + client = get_west_client() + if not client: + return {"status": "error", "message": "API客户端初始化失败"} + + domain = data.get('domain') + limit = data.get('limit', 20) + pageno = data.get('pageno', 1) + + if not domain: + return {"status": "error", "message": "缺少域名参数"} + + response = client.get_dns_records_paginated(domain, limit, pageno) + + if response.get("status") == "error": + return response + + try: + # 检查响应格式 + if response.get("result") != 200: + return {"status": "error", "message": "API查询失败"} + + data = response.get("data", {}) + + # 返回格式化的解析记录信息 + return { + "status": "success", + "data": { + "pageno": data.get("pageno", 1), + "limit": data.get("limit", 20), + "total": data.get("total", 0), + "pagecount": data.get("pagecount", 0), + "items": data.get("items", []) + } + } + + except Exception as e: + jingrow.log_error("域名解析记录查询响应解析失败", error=str(e)) + return {"status": "error", "message": "域名解析记录查询响应解析失败"} + + @jingrow.whitelist() def west_domain_modify_dns(**data): """修改域名DNS记录"""