From fedaab20408e547158c4a54b4ccc14b461b96421 Mon Sep 17 00:00:00 2001 From: jingrow Date: Sun, 3 Aug 2025 12:22:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E5=AE=9E=E5=90=8D=E4=BF=A1=E6=81=AF=E7=9A=84api?= =?UTF-8?q?=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 | 143 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index 89f1b71..7b35951 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -401,6 +401,22 @@ class WestDomain: return self._make_request('/audit/', 'POST', body_params=encoded_data) + def get_domain_real_info(self, domain: str) -> Dict[str, Any]: + """ + 获取域名实名信息 + + Args: + domain: 域名 + + Returns: + 域名实名信息,包含所有者、管理联系人、技术联系人、缴费联系人等信息 + """ + body_params = { + 'act': 'domaininfo', + 'domain': domain, + } + return self._make_request('/audit/', 'POST', body_params=body_params) + def format_date(date): """格式化域名到期时间""" @@ -1565,3 +1581,130 @@ def test_create_domain_owner_with_template(): except Exception as e: jingrow.log_error("测试API异常", str(e)) return {"status": "Error", "message": f"测试API调用失败: {str(e)}"} + + +@jingrow.whitelist() +def get_west_domain_real_info(**data): + """获取域名实名信息""" + client = get_west_client() + if not client: + return {"status": "error", "message": "API客户端初始化失败"} + + domain = data.get('domain') + if not domain: + return {"status": "error", "message": "缺少域名参数"} + + response = client.get_domain_real_info(domain) + + 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": { + "domain": data.get("domain"), + "c_sysid": data.get("c_sysid"), + "c_regtype": data.get("c_regtype"), + "c_status": data.get("c_status"), + "c_failinfo": data.get("c_failinfo"), + "status": data.get("status"), + "regdate": data.get("regdate"), + "rexpiredate": data.get("rexpiredate"), + "dns_hosts": { + "dns_host1": data.get("dns_host1"), + "dns_host2": data.get("dns_host2"), + "dns_host3": data.get("dns_host3"), + "dns_host4": data.get("dns_host4"), + "dns_host5": data.get("dns_host5"), + "dns_host6": data.get("dns_host6") + }, + "owner": { + "dom_ln": data.get("dom_ln"), + "dom_fn": data.get("dom_fn"), + "dom_ln_m": data.get("dom_ln_m"), + "dom_fn_m": data.get("dom_fn_m"), + "dom_org": data.get("dom_org"), + "dom_org_m": data.get("dom_org_m"), + "dom_co": data.get("dom_co"), + "dom_st": data.get("dom_st"), + "dom_st_m": data.get("dom_st_m"), + "dom_ct": data.get("dom_ct"), + "dom_ct_m": data.get("dom_ct_m"), + "dom_adr1": data.get("dom_adr1"), + "dom_adr_m": data.get("dom_adr_m"), + "dom_pc": data.get("dom_pc"), + "dom_ph": data.get("dom_ph"), + "dom_fax": data.get("dom_fax"), + "dom_em": data.get("dom_em") + }, + "admin": { + "admi_ln": data.get("admi_ln"), + "admi_fn": data.get("admi_fn"), + "admi_ln_m": data.get("admi_ln_m"), + "admi_fn_m": data.get("admi_fn_m"), + "admi_co": data.get("admi_co"), + "admi_st": data.get("admi_st"), + "admi_st_m": data.get("admi_st_m"), + "admi_ct": data.get("admi_ct"), + "admi_ct_m": data.get("admi_ct_m"), + "admi_adr1": data.get("admi_adr1"), + "admi_adr_m": data.get("admi_adr_m"), + "admi_pc": data.get("admi_pc"), + "admi_ph": data.get("admi_ph"), + "admi_fax": data.get("admi_fax"), + "admi_em": data.get("admi_em") + }, + "tech": { + "tech_ln": data.get("tech_ln"), + "tech_fn": data.get("tech_fn"), + "tech_ln_m": data.get("tech_ln_m"), + "tech_fn_m": data.get("tech_fn_m"), + "tech_co": data.get("tech_co"), + "tech_st": data.get("tech_st"), + "tech_st_m": data.get("tech_st_m"), + "tech_ct": data.get("tech_ct"), + "tech_ct_m": data.get("tech_ct_m"), + "tech_adr1": data.get("tech_adr1"), + "tech_adr_m": data.get("tech_adr_m"), + "tech_pc": data.get("tech_pc"), + "tech_ph": data.get("tech_ph"), + "tech_fax": data.get("tech_fax"), + "tech_em": data.get("tech_em") + }, + "billing": { + "bill_ln": data.get("bill_ln"), + "bill_fn": data.get("bill_fn"), + "bill_ln_m": data.get("bill_ln_m"), + "bill_fn_m": data.get("bill_fn_m"), + "bill_co": data.get("bill_co"), + "bill_st": data.get("bill_st"), + "bill_st_m": data.get("bill_st_m"), + "bill_ct": data.get("bill_ct"), + "bill_ct_m": data.get("bill_ct_m"), + "bill_adr1": data.get("bill_adr1"), + "bill_adr_m": data.get("bill_adr_m"), + "bill_pc": data.get("bill_pc"), + "bill_ph": data.get("bill_ph"), + "bill_fax": data.get("bill_fax"), + "bill_em": data.get("bill_em") + }, + "real_name_status": { + "r_status": data.get("r_status"), + "r_failinfo": data.get("r_failinfo"), + "c_ispublic": data.get("c_ispublic") + }, + "orgfile": data.get("orgfile", {}) + } + } + + except Exception as e: + jingrow.log_error("域名实名信息查询响应解析失败", error=str(e)) + return {"status": "error", "message": "域名实名信息查询响应解析失败"}