瀏覽代碼

区间计算删除

xyxie 7 月之前
父節點
當前提交
436762b043

+ 15 - 0
controllers/data_manage/range_analysis/chart_classify.go

@@ -516,6 +516,21 @@ func (this *RangeChartClassifyController) DeleteChartClassify() {
 			//go data.EsDeleteMyChartInfoByChartInfoId(chartInfo.ChartInfoId)
 			go data.EsDeleteMyChartInfoByMyChartIds(myIds)
 		}
+		// 删除配置关联指标数据
+		multiConfig, e := data_manage.GetMultipleGraphConfigChartMappingByChartId(chartInfo.ChartInfoId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			br.Msg = "删除失败"
+			br.ErrMsg = "获取图表关联配置失败, Err: " + e.Error()
+			return
+		}
+		if multiConfig != nil { // 删除配置关联指标数据
+			e = data_manage.DeleteMultipleGraphConfigEdbMappingByChartInfoId(chartInfo.ChartInfoId, multiConfig.MultipleGraphConfigId, utils.CHART_SOURCE_RANGE_ANALYSIS)
+			if e != nil {
+				br.Msg = "删除失败"
+				br.ErrMsg = "删除图表关联配置失败, Err: " + e.Error()
+				return
+			}
+		}
 
 		var condition string
 		var pars []interface{}

+ 24 - 0
models/data_manage/multiple_graph_config_edb_mapping.go

@@ -74,3 +74,27 @@ func DeleteMultipleGraphConfigEdbMappingByEdbIds(configId, source int, edbIds []
 	_, err = o.Raw(sql, configId, source, edbIds).Exec()
 	return
 }
+
+func DeleteMultipleGraphConfigEdbMappingByChartInfoId(chartInfoId, configId, source int) (err error) {
+	o := orm.NewOrmUsingDB("data")
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+
+	sql := ` DELETE FROM multiple_graph_config_chart_mapping WHERE chart_info_id=? and multiple_graph_config_id = ? and	source=?`
+	_, err = to.Raw(sql, chartInfoId, configId, source).Exec()
+	if err != nil {
+		return
+	}
+	sql = ` DELETE FROM  multiple_graph_config_edb_mapping WHERE multiple_graph_config_id = ? and	source=? `
+	_, err = to.Raw(sql, configId, source).Exec()
+	return
+}