Переглянути джерело

refactor(admin): 优化 WAF 日志导出功能

- 修改字段名称:
  - 将"host_id"改为"实例ID"  - 将"api_name"改为"操作名称"
  -将"created_at"改为"操作时间"
- 移除不必要的字段"comment"
- 增加对 HTTPS 地址的处理,为导出的暴露地址添加 https:// 前缀
fusu 3 днів тому
батько
коміт
d0b0a7e915
1 змінених файлів з 11 додано та 5 видалено
  1. 11 5
      internal/service/admin/waflog.go

+ 11 - 5
internal/service/admin/waflog.go

@@ -273,20 +273,20 @@ func (s *wafLogService) SmartExportWafLog(ctx context.Context, req adminApi.Expo
 	exportType := excel.SmartExport(count, 200)
 	
 	// 3. 设置Excel表头映射
-	headers := []string{"name", "request_ip", "host_id", "rule_id", "api_name", "addr_backend_list", "allow_and_deny_ips", "domain", "comment", "custom_host", "expose_addr", "created_at"}
+	headers := []string{"name", "request_ip", "host_id", "rule_id", "api_name", "addr_backend_list", "allow_and_deny_ips", "domain", "custom_host", "expose_addr", "comment", "created_at"}
 	headerMap := map[string]string{
 		"name":             "用户名",
 		"request_ip":       "请求IP",
-		"host_id":          "主机ID",
+		"host_id":          "实例ID",
 		"rule_id":          "规则ID",
-		"api_name":         "API名称",
+		"api_name":         "操作名称",
 		"addr_backend_list": "后端地址",
 		"allow_and_deny_ips": "黑白名单",
 		"domain":           "域名",
-		"comment":          "备注",
 		"custom_host":      "回源地址",
 		"expose_addr":      "暴露地址",
-		"created_at":       "创建时间",
+		"comment":          "备注",
+		"created_at":       "操作时间",
 	}
 
 	// 4. 创建Excel生成器
@@ -496,6 +496,12 @@ func (s *wafLogService) convertRawDataToExportResults(ctx context.Context, rawDa
 			ruleIds = []int64{int64(v.RuleId)}
 		}
 
+		if cleanedData.IsHttps == 1 {
+			for i := range exposeAddr {
+				exposeAddr[i] = "https://" + exposeAddr[i]
+			}
+		}
+
 		// 构造结果,代码更清晰
 		res = append(res, adminApi.ExportWafLogRes{
 			Name:            v.Name,