|
@@ -273,7 +273,7 @@ func (r *wafLogRepository) AddWafLog(ctx context.Context, log *model.WafLog) err
|
|
|
|
|
|
|
|
|
|
// 获取最优的写入表(考虑数据量阈值)
|
|
// 获取最优的写入表(考虑数据量阈值)
|
|
- tableName, err := r.Manager.GetOptimalWriteTable(ctx, r.DBWithName(ctx, "admin"), log, r.getMaxRowsForTable("waf_log"))
|
|
|
|
|
|
+ tableName, err := r.Manager.GetOptimalWriteTable(ctx, r.DBWithName(ctx, "admin"), log, r.Manager.GetMaxRowsForTable("waf_log"))
|
|
if err != nil {
|
|
if err != nil {
|
|
return fmt.Errorf("获取写入表失败: %v", err)
|
|
return fmt.Errorf("获取写入表失败: %v", err)
|
|
}
|
|
}
|
|
@@ -295,7 +295,7 @@ func (r *wafLogRepository) BatchAddWafLog(ctx context.Context, logs []*model.Waf
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
- maxRows := r.getMaxRowsForTable("waf_log")
|
|
|
|
|
|
+ maxRows := r.Manager.GetMaxRowsForTable("waf_log")
|
|
|
|
|
|
// 按表名分组
|
|
// 按表名分组
|
|
tableGroups := make(map[string][]*model.WafLog)
|
|
tableGroups := make(map[string][]*model.WafLog)
|
|
@@ -391,17 +391,6 @@ func (r *wafLogRepository) GetWafLogExportCount(ctx context.Context, req adminAp
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-// getMaxRowsForTable 获取指定表的最大行数配置
|
|
|
|
-func (r *wafLogRepository) getMaxRowsForTable(tableName string) int64 {
|
|
|
|
- switch tableName {
|
|
|
|
- case "log":
|
|
|
|
- return 3000000 // 300万条
|
|
|
|
- case "waf_log":
|
|
|
|
- return 5000000 // 500万条
|
|
|
|
- default:
|
|
|
|
- return 3000000 // 默认300万条
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
|
|
// applyWafLogFilters 应用WafLog查询过滤条件
|
|
// applyWafLogFilters 应用WafLog查询过滤条件
|
|
func (r *wafLogRepository) applyWafLogFilters(query *gorm.DB, req adminApi.SearchWafLogParams) *gorm.DB {
|
|
func (r *wafLogRepository) applyWafLogFilters(query *gorm.DB, req adminApi.SearchWafLogParams) *gorm.DB {
|