域名解析记录列表改为从get_jingrow_domain_dns_records获取

This commit is contained in:
jingrow 2025-08-05 02:23:55 +08:00
parent e85bb9bb5a
commit d9dd92d231
2 changed files with 74 additions and 1 deletions

View File

@ -383,7 +383,7 @@ export default {
try { try {
const request = createResource({ const request = createResource({
url: 'jcloud.api.domain_west.get_west_domain_dns_records', url: 'jcloud.api.domain_west.get_jingrow_domain_dns_records',
params: { params: {
domain: this.$domain.pg.domain, domain: this.$domain.pg.domain,
limit: this.pagination.limit, limit: this.pagination.limit,

View File

@ -917,6 +917,79 @@ def get_west_domain_dns_records(**data):
return {"status": "error", "message": "域名解析记录查询响应解析失败"} return {"status": "error", "message": "域名解析记录查询响应解析失败"}
@jingrow.whitelist()
def get_jingrow_domain_dns_records(**data):
"""获取域名解析记录(从本地数据库获取,支持分页)"""
try:
domain = data.get('domain')
limit = data.get('limit', 20)
pageno = data.get('pageno', 1)
if not domain:
return {"status": "error", "message": "缺少域名参数"}
# 查找对应的域名记录
domain_records = jingrow.get_all(
"Jsite Domain",
{"domain": domain},
["name"]
)
if not domain_records:
return {"status": "error", "message": "未找到指定的域名记录"}
domain_record = domain_records[0]
# 获取该域名的所有DNS解析记录
dns_records = jingrow.get_all(
"Dns Resolution",
{"parent": domain_record.name},
["name", "host", "type", "value", "ttl", "level", "line", "record_id"]
)
# 转换为API格式的数据结构
all_items = []
for record in dns_records:
item = {
"id": record.record_id or record.name,
"host": record.host or "",
"type": record.type or "",
"value": record.value or "",
"ttl": int(record.ttl) if record.ttl else 600,
"level": int(record.level) if record.level else 10,
"line": record.line or "",
"record_id": record.record_id or record.name
}
all_items.append(item)
# 对所有记录按类型排序
sorted_items = sorted(all_items, key=lambda x: x.get('type', ''))
# 计算分页
total = len(sorted_items)
pagecount = (total + limit - 1) // limit
start_index = (pageno - 1) * limit
end_index = start_index + limit
# 返回当前页的记录
current_page_items = sorted_items[start_index:end_index]
# 返回格式化的解析记录信息
return {
"status": "success",
"data": {
"pageno": pageno,
"limit": limit,
"total": total,
"pagecount": pagecount,
"items": current_page_items
}
}
except Exception as e:
return {"status": "error", "message": f"域名解析记录查询失败: {str(e)}"}
@jingrow.whitelist() @jingrow.whitelist()
def west_domain_modify_dns(**data): def west_domain_modify_dns(**data):
"""修改域名DNS记录批量修改兼容旧版本""" """修改域名DNS记录批量修改兼容旧版本"""