新增域名解析记录成功后异步创建本地对应的域名解析记录
This commit is contained in:
parent
c5bf3092db
commit
852ce46ad7
@ -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,
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user