|
@@ -2224,11 +2224,11 @@ func AddChartInfo(req data_manage.AddChartInfoReq, sysUserId int, sysUserRealNam
|
|
|
|
|
|
switch lang {
|
|
|
case utils.EnLangVersion:
|
|
|
- condition += " AND chart_name_en = ? AND source = ? "
|
|
|
+ condition += " AND chart_name_en = ? AND source = ? AND sys_suer_id = ? "
|
|
|
default:
|
|
|
- condition += " AND chart_name = ? AND source = ? "
|
|
|
+ condition += " AND chart_name = ? AND source = ? AND sys_suer_id = ? "
|
|
|
}
|
|
|
- pars = append(pars, req.ChartName, utils.CHART_SOURCE_DEFAULT)
|
|
|
+ pars = append(pars, req.ChartName, utils.CHART_SOURCE_DEFAULT, sysUserId)
|
|
|
|
|
|
count, err = data_manage.GetChartInfoCountByCondition(condition, pars)
|
|
|
if err != nil {
|
|
@@ -2661,11 +2661,11 @@ func EditChartInfo(req data_manage.EditChartInfoReq, sysUser *system.Admin, lang
|
|
|
|
|
|
switch lang {
|
|
|
case utils.EnLangVersion:
|
|
|
- condition += " AND chart_name_en = ? AND source = ? "
|
|
|
+ condition += " AND chart_name_en = ? AND source = ? AND sys_suer_id = ? "
|
|
|
default:
|
|
|
- condition += " AND chart_name = ? AND source = ? "
|
|
|
+ condition += " AND chart_name = ? AND source = ? AND sys_suer_id = ? "
|
|
|
}
|
|
|
- pars = append(pars, req.ChartName, utils.CHART_SOURCE_DEFAULT)
|
|
|
+ pars = append(pars, req.ChartName, utils.CHART_SOURCE_DEFAULT, sysUser.AdminId)
|
|
|
|
|
|
count, err = data_manage.GetChartInfoCountByCondition(condition, pars)
|
|
|
if err != nil {
|
|
@@ -5034,3 +5034,103 @@ func CheckChartReferencedByOthers(chartInfoIdList []int, chartUniqueCodeList []s
|
|
|
noReferenced = true
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// CheckExistByEdbNameAndEdbInfoId
|
|
|
+// @Description: 根据指标名称和指标ID校验库中是否还存在其他同名指标
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-04-18 15:01:44
|
|
|
+// @param chartInfoType int
|
|
|
+// @param chartInfoId int
|
|
|
+// @param chartName string
|
|
|
+// @param lang string
|
|
|
+// @return has bool
|
|
|
+// @return err error
|
|
|
+func CheckExistByChartNameAndChartInfoId(source, chartInfoId, userId int, chartName, lang string) (has bool, err error) {
|
|
|
+ // 指标没有入库的情况
|
|
|
+ if chartInfoId == 0 {
|
|
|
+ return checkExistByChartName(source, userId, chartName, lang)
|
|
|
+ }
|
|
|
+
|
|
|
+ //指标已经入库的情况
|
|
|
+ return checkExistByChartNameAndChartInfoId(source, userId, chartInfoId, chartName, lang)
|
|
|
+}
|
|
|
+
|
|
|
+// checkExistByChartName
|
|
|
+// @Description: 根据指标名称校验该指标是否存在库中
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-04-18 14:58:52
|
|
|
+// @param source int
|
|
|
+// @param chartName string
|
|
|
+// @param lang string
|
|
|
+// @return has bool
|
|
|
+// @return err error
|
|
|
+func checkExistByChartName(source, userId int, chartName, lang string) (has bool, err error) {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ condition += " AND source=? AND sys_user_id=? "
|
|
|
+ pars = append(pars, source, userId)
|
|
|
+
|
|
|
+ switch lang {
|
|
|
+ case utils.EnLangVersion:
|
|
|
+ condition += " AND chart_name_en = ? "
|
|
|
+ default:
|
|
|
+ condition += " AND chart_name=? "
|
|
|
+ }
|
|
|
+
|
|
|
+ pars = append(pars, chartName)
|
|
|
+
|
|
|
+ count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count > 0 {
|
|
|
+ has = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// checkExistByChartNameAndChartInfoId
|
|
|
+// @Description: 根据指标名称和指标ID校验库中是否还存在其他同名指标
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-04-18 15:00:19
|
|
|
+// @param source int
|
|
|
+// @param chartInfoId int
|
|
|
+// @param chartName string
|
|
|
+// @param lang string
|
|
|
+// @return has bool
|
|
|
+// @return err error
|
|
|
+func checkExistByChartNameAndChartInfoId(source, userId, chartInfoId int, chartName, lang string) (has bool, err error) {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ condition += " AND source=? AND sys_user_id=? "
|
|
|
+ pars = append(pars, source, userId)
|
|
|
+
|
|
|
+ condition += " AND chart_info_id<>? "
|
|
|
+ pars = append(pars, chartInfoId)
|
|
|
+
|
|
|
+ switch lang {
|
|
|
+ case utils.EnLangVersion:
|
|
|
+ condition += " AND chart_name_en = ? "
|
|
|
+ default:
|
|
|
+ condition += " AND chart_name=? "
|
|
|
+ }
|
|
|
+
|
|
|
+ pars = append(pars, chartName)
|
|
|
+
|
|
|
+ count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if count > 0 {
|
|
|
+ has = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|