From 852ce46ad7981261abe7c781f28bcfb68980e639 Mon Sep 17 00:00:00 2001 From: jingrow Date: Tue, 5 Aug 2025 01:23:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9F=9F=E5=90=8D=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E8=AE=B0=E5=BD=95=E6=88=90=E5=8A=9F=E5=90=8E=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E5=88=9B=E5=BB=BA=E6=9C=AC=E5=9C=B0=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E5=9F=9F=E5=90=8D=E8=A7=A3=E6=9E=90=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/api/domain_west.py | 36 ++++++++++++++++++- .../dns_resolution/dns_resolution.json | 10 +++++- .../pagetype/dns_resolution/dns_resolution.py | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index 215e800..8a3bf02 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -1050,12 +1050,46 @@ def west_domain_add_dns_record(**data): error_msg = response.get('msg', response.get('message', '未知错误')) return {"status": "error", "message": f"添加DNS记录失败: {error_msg}"} + # 获取新增记录的ID + record_id = response.get("data", {}).get("id") + + # 异步添加记录到本地数据库 + if record_id: + try: + # 查找对应的域名记录 + domain_records = jingrow.get_all( + "Jsite Domain", + {"domain": domain}, + ["name"] + ) + + if domain_records: + domain_record = domain_records[0] + jingrow.enqueue( + "jingrow.client.insert_pg", + pg={ + "pagetype": "Dns Resolution", + "parenttype": "Jsite Domain", + "parent": domain_record.name, + "parentfield": "dns_resolution", + "host": host, + "type": record_type, + "value": value, + "ttl": str(ttl), + "level": str(level), + "line": line, + "record_id": record_id + } + ) + except Exception as e: + jingrow.log_error(f"域名 {domain} DNS记录异步添加失败", f"错误: {str(e)}") + # 返回成功结果 return { "status": "success", "message": "DNS记录添加成功", "data": { - "id": response.get("data", {}).get("id"), + "id": record_id, "domain": domain, "host": host, "type": record_type, diff --git a/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.json b/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.json index 65fffa9..975ff90 100644 --- a/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.json +++ b/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.json @@ -5,6 +5,7 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ + "record_id", "host", "type", "line", @@ -69,13 +70,20 @@ "fieldtype": "Data", "in_list_view": 1, "label": "状态" + }, + { + "columns": 1, + "fieldname": "record_id", + "fieldtype": "Data", + "label": "记录ID", + "read_only": 1 } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2025-07-31 20:34:50.907647", + "modified": "2025-08-05 01:00:02.459889", "modified_by": "Administrator", "module": "Jcloud", "name": "Dns Resolution", diff --git a/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.py b/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.py index ce454b1..a04a6af 100644 --- a/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.py +++ b/jcloud/jcloud/pagetype/dns_resolution/dns_resolution.py @@ -20,6 +20,7 @@ class DnsResolution(Document): parent: DF.Data parentfield: DF.Data parenttype: DF.Data + record_id: DF.Data | None record_status: DF.Data | None ttl: DF.Data | None type: DF.Literal["", "A", "CNAME", "MX", "TXT", "AAAA", "SRV"]