diff --git a/dashboard/src2/components/JsiteDomainDNSRecords.vue b/dashboard/src2/components/JsiteDomainDNSRecords.vue index 1defca3..9a67360 100644 --- a/dashboard/src2/components/JsiteDomainDNSRecords.vue +++ b/dashboard/src2/components/JsiteDomainDNSRecords.vue @@ -383,7 +383,7 @@ export default { try { const request = createResource({ - url: 'jcloud.api.domain_west.get_west_domain_dns_records', + url: 'jcloud.api.domain_west.get_jingrow_domain_dns_records', params: { domain: this.$domain.pg.domain, limit: this.pagination.limit, diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index 3e2c5e1..9aab0cd 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -917,6 +917,79 @@ def get_west_domain_dns_records(**data): 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() def west_domain_modify_dns(**data): """修改域名DNS记录(批量修改,兼容旧版本)"""