浏览代码

Merge remote-tracking branch 'origin/eta/1.7.3' into debug

Roc 11 月之前
父节点
当前提交
670b40b5c3
共有 4 个文件被更改,包括 109 次插入110 次删除
  1. 3 3
      controllers/base_from_calculate.go
  2. 3 4
      controllers/base_from_predict_calculate.go
  3. 102 3
      logic/predict_edb.go
  4. 1 100
      services/base_from_calculate.go

+ 3 - 3
controllers/base_from_calculate.go

@@ -223,7 +223,7 @@ func (this *CalculateController) Edit() {
 	}
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(0, req.EdbInfoId, req.EdbName, this.Lang)
+	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(0, req.EdbInfoId, req.EdbName, this.Lang)
 	if err != nil {
 		br.Msg = "判断指标名称是否存在失败"
 		br.ErrMsg = "判断指标名称是否存在失败,Err:" + err.Error()
@@ -485,7 +485,7 @@ func (this *CalculateController) BatchSave() {
 	//加入缓存机制,避免创建同一个名称的指标 end
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(0, req.EdbInfoId, req.EdbName, this.Lang)
+	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(0, req.EdbInfoId, req.EdbName, this.Lang)
 	if err != nil {
 		br.Msg = "判断指标名称是否存在失败"
 		br.ErrMsg = "判断指标名称是否存在失败,Err:" + err.Error()
@@ -837,7 +837,7 @@ func (this *CalculateController) BatchEdit() {
 	}
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(0, req.EdbInfoId, req.EdbName, this.Lang)
+	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(0, req.EdbInfoId, req.EdbName, this.Lang)
 	if err != nil {
 		br.Msg = "判断指标名称是否存在失败"
 		br.ErrMsg = "判断指标名称是否存在失败,Err:" + err.Error()

+ 3 - 4
controllers/base_from_predict_calculate.go

@@ -4,7 +4,6 @@ import (
 	"encoding/json"
 	"eta/eta_index_lib/logic"
 	"eta/eta_index_lib/models"
-	"eta/eta_index_lib/services"
 	"eta/eta_index_lib/utils"
 	"fmt"
 	"strconv"
@@ -127,7 +126,7 @@ func addPredictCalculate(br *models.BaseResponse, req models.EdbInfoCalculateSav
 	}
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(1, 0, req.EdbName, lang)
+	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(1, 0, req.EdbName, lang)
 	if err != nil {
 		br.Msg = "判断指标名称是否存在失败"
 		br.ErrMsg = "判断指标名称是否存在失败,Err:" + err.Error()
@@ -380,7 +379,7 @@ func editPredictCalculate(br *models.BaseResponse, req models.EdbInfoCalculateSa
 	}
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(edbInfo.EdbInfoType, edbInfo.EdbInfoId, req.EdbName, lang)
+	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(edbInfo.EdbInfoType, edbInfo.EdbInfoId, req.EdbName, lang)
 	if err != nil {
 		br.Msg = "判断指标名称是否存在失败"
 		br.ErrMsg = "判断指标名称是否存在失败,Err:" + err.Error()
@@ -579,7 +578,7 @@ func (this *PredictCalculateController) CalculateBatchSave() {
 	//加入缓存机制,避免创建同一个名称的指标 end
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(1, req.EdbInfoId, req.EdbName, this.Lang)
+	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(1, req.EdbInfoId, req.EdbName, this.Lang)
 	if err != nil {
 		br.Msg = "判断指标名称是否存在失败"
 		br.ErrMsg = "判断指标名称是否存在失败,Err:" + err.Error()

+ 102 - 3
logic/predict_edb.go

@@ -3,7 +3,6 @@ package logic
 import (
 	"errors"
 	"eta/eta_index_lib/models"
-	"eta/eta_index_lib/services"
 	"eta/eta_index_lib/utils"
 	"fmt"
 	"strconv"
@@ -67,7 +66,7 @@ func AddPredictEdbInfo(sourceEdbInfoId, classifyId int, edbName, dataDateType st
 	edbCode := sourceEdbInfo.EdbCode + "_" + time.Now().Format(utils.FormatShortDateTimeUnSpace)
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(0, 0, edbName, lang)
+	existEdbName, err := CheckExistByEdbNameAndEdbInfoId(0, 0, edbName, lang)
 	if err != nil {
 		errMsg = "判断指标名称是否存在失败"
 		err = errors.New("判断指标名称是否存在失败,Err:" + err.Error())
@@ -443,7 +442,7 @@ func EditPredictEdbInfo(edbInfoId, classifyId int, edbName, dataDateType string,
 	}
 
 	// 根据指标名称和指标ID校验库中是否还存在其他同名指标
-	existEdbName, err := services.CheckExistByEdbNameAndEdbInfoId(1, edbInfoId, edbName, lang)
+	existEdbName, err := CheckExistByEdbNameAndEdbInfoId(1, edbInfoId, edbName, lang)
 	if err != nil {
 		errMsg = "判断指标名称是否存在失败"
 		err = errors.New("判断指标名称是否存在失败,Err:" + err.Error())
@@ -978,3 +977,103 @@ func RefreshPredictEdbInfo(edbInfoId int) (edbInfo *models.EdbInfo, err error, e
 
 	return
 }
+
+
+// checkExistByEdbName
+// @Description: 根据指标名称校验该指标是否存在库中
+// @author: Roc
+// @datetime 2024-04-18 14:58:52
+// @param edbInfoType int
+// @param edbName string
+// @param lang string
+// @return has bool
+// @return err error
+func checkExistByEdbName(edbInfoType int, edbName, lang string) (has bool, err error) {
+	var condition string
+	var pars []interface{}
+
+	condition += " AND edb_info_type=? "
+	pars = append(pars, 0)
+
+	switch lang {
+	case utils.EnLangVersion:
+		condition += " AND edb_name_en = ? "
+	default:
+		condition += " AND edb_name=? "
+	}
+
+	pars = append(pars, edbName)
+
+	count, err := models.GetEdbInfoCountByCondition(condition, pars)
+	if err != nil {
+		return
+	}
+
+	if count > 0 {
+		has = true
+		return
+	}
+
+	return
+}
+
+// checkExistByEdbNameAndEdbInfoId
+// @Description: 根据指标名称和指标ID校验库中是否还存在其他同名指标
+// @author: Roc
+// @datetime 2024-04-18 15:00:19
+// @param edbInfoType int
+// @param edbInfoId int
+// @param edbName string
+// @param lang string
+// @return has bool
+// @return err error
+func checkExistByEdbNameAndEdbInfoId(edbInfoType, edbInfoId int, edbName, lang string) (has bool, err error) {
+	var condition string
+	var pars []interface{}
+	condition += " AND edb_info_type=? "
+	pars = append(pars, edbInfoType)
+
+	condition += " AND edb_info_id<>? "
+	pars = append(pars, edbInfoId)
+
+	switch lang {
+	case utils.EnLangVersion:
+		condition += " AND edb_name_en = ? "
+	default:
+		condition += " AND edb_name=? "
+	}
+
+	pars = append(pars, edbName)
+
+	count, err := models.GetEdbInfoCountByCondition(condition, pars)
+	if err != nil {
+		return
+	}
+
+	if count > 0 {
+		has = true
+		return
+	}
+
+	return
+}
+
+// CheckExistByEdbNameAndEdbInfoId
+// @Description: 根据指标名称和指标ID校验库中是否还存在其他同名指标
+// @author: Roc
+// @datetime 2024-04-18 15:01:44
+// @param edbInfoType int
+// @param edbInfoId int
+// @param edbName string
+// @param lang string
+// @return has bool
+// @return err error
+func CheckExistByEdbNameAndEdbInfoId(edbInfoType, edbInfoId int, edbName, lang string) (has bool, err error) {
+	// 指标没有入库的情况
+	if edbInfoId == 0 {
+		return checkExistByEdbName(edbInfoType, edbName, lang)
+	}
+
+	//指标已经入库的情况
+	return checkExistByEdbNameAndEdbInfoId(edbInfoType, edbInfoId, edbName, lang)
+}

+ 1 - 100
services/base_from_calculate.go

@@ -899,7 +899,7 @@ func EdbCalculateAdd(req models.EdbInfoCalculateSaveReq, lang string) (edbInfo *
 	}
 
 	// 校验指标名称是否存在
-	existEdbName, err := CheckExistByEdbNameAndEdbInfoId(0, 0, req.EdbName, lang)
+	existEdbName, err := logic.CheckExistByEdbNameAndEdbInfoId(0, 0, req.EdbName, lang)
 	if err != nil {
 		errMsg = "判断指标名称是否存在失败,Err:" + err.Error()
 		err = fmt.Errorf("判断指标名称是否存在失败")
@@ -1010,102 +1010,3 @@ func EdbCalculateAdd(req models.EdbInfoCalculateSaveReq, lang string) (edbInfo *
 
 	return
 }
-
-// checkExistByEdbName
-// @Description: 根据指标名称校验该指标是否存在库中
-// @author: Roc
-// @datetime 2024-04-18 14:58:52
-// @param edbInfoType int
-// @param edbName string
-// @param lang string
-// @return has bool
-// @return err error
-func checkExistByEdbName(edbInfoType int, edbName, lang string) (has bool, err error) {
-	var condition string
-	var pars []interface{}
-
-	condition += " AND edb_info_type=? "
-	pars = append(pars, 0)
-
-	switch lang {
-	case utils.EnLangVersion:
-		condition += " AND edb_name_en = ? "
-	default:
-		condition += " AND edb_name=? "
-	}
-
-	pars = append(pars, edbName)
-
-	count, err := models.GetEdbInfoCountByCondition(condition, pars)
-	if err != nil {
-		return
-	}
-
-	if count > 0 {
-		has = true
-		return
-	}
-
-	return
-}
-
-// checkExistByEdbNameAndEdbInfoId
-// @Description: 根据指标名称和指标ID校验库中是否还存在其他同名指标
-// @author: Roc
-// @datetime 2024-04-18 15:00:19
-// @param edbInfoType int
-// @param edbInfoId int
-// @param edbName string
-// @param lang string
-// @return has bool
-// @return err error
-func checkExistByEdbNameAndEdbInfoId(edbInfoType, edbInfoId int, edbName, lang string) (has bool, err error) {
-	var condition string
-	var pars []interface{}
-	condition += " AND edb_info_type=? "
-	pars = append(pars, edbInfoType)
-
-	condition += " AND edb_info_id<>? "
-	pars = append(pars, edbInfoId)
-
-	switch lang {
-	case utils.EnLangVersion:
-		condition += " AND edb_name_en = ? "
-	default:
-		condition += " AND edb_name=? "
-	}
-
-	pars = append(pars, edbName)
-
-	count, err := models.GetEdbInfoCountByCondition(condition, pars)
-	if err != nil {
-		return
-	}
-
-	if count > 0 {
-		has = true
-		return
-	}
-
-	return
-}
-
-// CheckExistByEdbNameAndEdbInfoId
-// @Description: 根据指标名称和指标ID校验库中是否还存在其他同名指标
-// @author: Roc
-// @datetime 2024-04-18 15:01:44
-// @param edbInfoType int
-// @param edbInfoId int
-// @param edbName string
-// @param lang string
-// @return has bool
-// @return err error
-func CheckExistByEdbNameAndEdbInfoId(edbInfoType, edbInfoId int, edbName, lang string) (has bool, err error) {
-	// 指标没有入库的情况
-	if edbInfoId == 0 {
-		return checkExistByEdbName(edbInfoType, edbName, lang)
-	}
-
-	//指标已经入库的情况
-	return checkExistByEdbNameAndEdbInfoId(edbInfoType, edbInfoId, edbName, lang)
-}