Forráskód Böngészése

fix: 修复指标为0的情况

zqbao 10 hónapja
szülő
commit
cca7ab3d66
2 módosított fájl, 22 hozzáadás és 20 törlés
  1. 2 1
      .gitignore
  2. 20 19
      controllers/base_from_predict_calculate.go

+ 2 - 1
.gitignore

@@ -12,4 +12,5 @@ eta_index_lib
 /static/imgs/python/*
 /etalogs
 *.gz
-*.exe
+*.exe
+/.vscode/

+ 20 - 19
controllers/base_from_predict_calculate.go

@@ -603,13 +603,6 @@ func (this *PredictCalculateController) CalculateBatchSave() {
 	}
 	//加入缓存机制,避免创建同一个名称的指标 end
 
-	oldEdbInfo, err := models.GetEdbInfoById(req.EdbInfoId)
-	if err != nil {
-		br.Msg = "获取指标信息失败"
-		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
-		return
-	}
-
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
 	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(1, req.EdbInfoId, req.EdbName, this.Lang)
 	if err != nil {
@@ -899,18 +892,26 @@ func (this *PredictCalculateController) CalculateBatchSave() {
 		return
 	}
 
-	// 记录操作变更记录
-	newEdbInfo := new(models.EdbInfoEditRecord)
-	newEdbInfo.EdbName = req.EdbName
-	newEdbInfo.Frequency = req.Frequency
-	newEdbInfo.Unit = req.Unit
-	newEdbInfo.OperateUserId = req.AdminId
-	newEdbInfo.OperateUserRealName = req.AdminName
-	err = services.AddEditEdbInfoRcord(oldEdbInfo, newEdbInfo)
-	if err != nil {
-		br.Msg = "保存失败"
-		br.ErrMsg = "保存失败,Err:" + err.Error()
-		return
+	if req.EdbInfoId > 0 {
+		oldEdbInfo, err := models.GetEdbInfoById(req.EdbInfoId)
+		if err != nil {
+			br.Msg = "获取指标信息失败"
+			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
+			return
+		}
+		// 记录操作变更记录
+		newEdbInfo := new(models.EdbInfoEditRecord)
+		newEdbInfo.EdbName = req.EdbName
+		newEdbInfo.Frequency = req.Frequency
+		newEdbInfo.Unit = req.Unit
+		newEdbInfo.OperateUserId = req.AdminId
+		newEdbInfo.OperateUserRealName = req.AdminName
+		err = services.AddEditEdbInfoRcord(oldEdbInfo, newEdbInfo)
+		if err != nil {
+			br.Msg = "保存失败"
+			br.ErrMsg = "保存失败,Err:" + err.Error()
+			return
+		}
 	}
 
 	resp := models.AddEdbInfoResp{