Skip to content

Commit c597b56

Browse files
author
tangjiawei
committed
#830 custom template add string_code_map
1 parent a91c61c commit c597b56

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

monitor-server/services/db/log_template.go

+9
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ func getUpdateLogMonitorTemplateActions(param *models.LogMonitorTemplateDto, ope
210210
logParamObj.Name, logParamObj.DisplayName, logParamObj.JsonKey, logParamObj.Regular, logParamObj.DemoMatchValue, operator, nowTime, logParamObj.Guid,
211211
}})
212212
}
213+
tmpStringMapGuidList := guid.CreateGuidList(len(logParamObj.StringMap))
214+
for stringMapIndex, stringMapObj := range logParamObj.StringMap {
215+
actions = append(actions, &Action{Sql: "insert into log_metric_string_map(guid,log_monitor_template,log_param_name,value_type,source_value,regulative,target_value,update_time) values (?,?,?,?,?,?,?,?)", Param: []interface{}{
216+
"lmsm_" + tmpStringMapGuidList[stringMapIndex], param.Guid, logParamObj.Name, stringMapObj.ValueType, stringMapObj.SourceValue, stringMapObj.Regulative, stringMapObj.TargetValue, nowTime.Format(models.DatetimeFormat),
217+
}})
218+
}
213219
}
214220
for _, existParamObj := range existLogMonitorObj.ParamList {
215221
deleteFlag := true
@@ -222,6 +228,9 @@ func getUpdateLogMonitorTemplateActions(param *models.LogMonitorTemplateDto, ope
222228
if deleteFlag {
223229
actions = append(actions, &Action{Sql: "delete from log_param_template where guid=?", Param: []interface{}{existParamObj.Guid}})
224230
}
231+
for _, stringMapObj := range existParamObj.StringMap {
232+
actions = append(actions, &Action{Sql: "delete from log_metric_string_map where guid=?", Param: []interface{}{stringMapObj.Guid}})
233+
}
225234
}
226235
logMetricGuidList := guid.CreateGuidList(len(param.MetricList))
227236
for i, logMetricObj := range param.MetricList {

0 commit comments

Comments
 (0)