xiziwen před 4 dny
rodič
revize
950985ac79

+ 4 - 4
controllers/data_manage/clarksons_data.go

@@ -169,7 +169,7 @@ func (this *ClarksonsDataController) EditClassify() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-	if req.BaseFromClassifyId < 0 {
+	if req.BaseFromClassifyId <= 0 {
 		br.Msg = "参数错误"
 		return
 	}
@@ -240,7 +240,7 @@ func (this *ClarksonsDataController) MoveClassify() {
 		return
 	}
 
-	err, errMsg := data.MoveClarksonsClassify(req.BaseFromClassifyId, req.ParentId, req.PrevClassifyId, req.NextClassifyId)
+	err, errMsg := data.MoveClarksonsClassify(req.BaseFromClassifyId, req.ParentClassifyId, req.PrevClassifyId, req.NextClassifyId)
 	if errMsg != `` {
 		br.Msg = errMsg
 		br.ErrMsg = errMsg
@@ -1003,7 +1003,7 @@ func (this *ClarksonsDataController) BatchAdd() {
 			edbLog.Method = this.Ctx.Input.URI()
 			go data_manage.AddEdbInfoLog(edbLog)
 		}
-		
+
 		// 更新es
 		go data.AddOrEditEdbInfoToEs(edbInfo.EdbInfoId)
 	}
@@ -1183,7 +1183,7 @@ func (this *ClarksonsDataController) EditClarksons() {
 		br.IsSendEmail = false
 		return
 	}
-	if req.BaseFromClassifyId <= 0 {
+	if req.BaseFromClassifyId < 0 {
 		br.Msg = "请选择分类"
 		br.IsSendEmail = false
 		return

+ 8 - 8
models/data_manage/request/clarksons_data.go

@@ -40,19 +40,19 @@ type ClarksonsDataBatchAddCheckReq struct {
 
 // ClarksonsDataBatchListReq 卓创红期指标批量列表
 type ClarksonsDataBatchListReq struct {
-	ClassifyIds string `description:"分类id"`
-	KeyWord     string `description:"关键字"`
-	Frequencies string `description:"频度"`
-	SelectedId  []int  `description:"已选指标id, 为true时表示反选"`
-	IsSelectAll bool   `description:"是否查询全部, 默认false, true:全选, false:查询已选"`
-	PageSize   int    `description:"每页条数"`
-	CurrentIndex int   `description:"当前页"`
+	ClassifyIds  string `description:"分类id"`
+	KeyWord      string `description:"关键字"`
+	Frequencies  string `description:"频度"`
+	SelectedId   []int  `description:"已选指标id, 为true时表示反选"`
+	IsSelectAll  bool   `description:"是否查询全部, 默认false, true:全选, false:查询已选"`
+	PageSize     int    `description:"每页条数"`
+	CurrentIndex int    `description:"当前页"`
 }
 
 // MoveBaseFromClarksonsClassifyReq 移动分类请求参数
 type MoveBaseFromClarksonsClassifyReq struct {
 	BaseFromClassifyId int `description:"分类id"`
-	ParentId           int `description:"父级分类id"`
+	ParentClassifyId   int `description:"父级分类id"`
 	PrevClassifyId     int `description:"上一个兄弟节点分类id"`
 	NextClassifyId     int `description:"下一个兄弟节点分类id"`
 }

+ 32 - 20
services/data/base_from_clarksons.go

@@ -32,12 +32,12 @@ func AddClarksonsClassify(classifyName string, parentId int) (ok bool, msg strin
 			return false, "", errors.New("父分类不存在")
 		}
 		clarksonsClassify := &data_manage.BaseFromClarksonsClassify{
-			ClassifyName:   classifyName,
-			ParentId:       parentId,
-			Level:          2,
-			Sort:           sort + 1,
-			ModifyTime:     time.Now(),
-			CreateTime:     time.Now(),
+			ClassifyName: classifyName,
+			ParentId:     parentId,
+			Level:        2,
+			Sort:         sort + 1,
+			ModifyTime:   time.Now(),
+			CreateTime:   time.Now(),
 		}
 		_, err = clarksonsClassify.Add()
 		if err != nil {
@@ -45,12 +45,12 @@ func AddClarksonsClassify(classifyName string, parentId int) (ok bool, msg strin
 		}
 	} else {
 		clarksonsClassify := &data_manage.BaseFromClarksonsClassify{
-			ClassifyName:   classifyName,
-			ParentId:       0,
-			Level:          1,
-			Sort:           sort + 1,
-			ModifyTime:     time.Now(),
-			CreateTime:     time.Now(),
+			ClassifyName: classifyName,
+			ParentId:     0,
+			Level:        1,
+			Sort:         sort + 1,
+			ModifyTime:   time.Now(),
+			CreateTime:   time.Now(),
 		}
 		_, er := clarksonsClassify.Add()
 		if er != nil {
@@ -136,7 +136,7 @@ func ResetClarksonsIndex(indexId int) (err error) {
 	return
 }
 
-// 批量删除卓创红期指标
+// 批量删除克拉克森指标
 func BatchDelClarksonsData(indexIds []int) (existIndex []*data_manage.BaseFromClarksonsIndex, err error) {
 	clarksonsIndexList, err := data_manage.GetClarksonsIndexListByIndexIds(indexIds)
 	if err != nil {
@@ -173,7 +173,7 @@ func BatchDelClarksonsData(indexIds []int) (existIndex []*data_manage.BaseFromCl
 	return
 }
 
-// DelClarksonsData 删除卓创红期指标
+// DelClarksonsData 删除克拉克森指标
 func DelClarksonsData(indexId int) (err error, errMsg string) {
 	baseFromClarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId)
 	if err != nil {
@@ -207,7 +207,7 @@ func DelClarksonsData(indexId int) (err error, errMsg string) {
 	return
 }
 
-// EditClarksonsIndex 编辑卓创红期指标
+// EditClarksonsIndex 编辑克拉克森指标
 func EditClarksonsIndex(indexId, classifyId int) (baseFromClarksonsIndex *data_manage.BaseFromClarksonsIndex, errMsg string, err error) {
 	baseFromClarksonsIndex, err = data_manage.GetClarksonsIndexByIndexId(indexId)
 	if err != nil {
@@ -252,7 +252,7 @@ type ClarksonsIndexSource2EdbReq struct {
 	AdminRealName string
 }
 
-// ClarksonsIndexSource2Edb 新增卓创红期数据从数据源到指标库
+// ClarksonsIndexSource2Edb 新增克拉克森数据从数据源到指标库
 func ClarksonsIndexSource2Edb(req ClarksonsIndexSource2EdbReq, lang string) (edb *data_manage.EdbInfo, errMsg string, skip bool, err error) {
 	if req.EdbCode == "" {
 		err = fmt.Errorf("指标ID为空")
@@ -294,7 +294,7 @@ func ClarksonsIndexSource2Edb(req ClarksonsIndexSource2EdbReq, lang string) (edb
 	return
 }
 
-// MoveClarksonsClassify 移动卓创红期分类
+// MoveClarksonsClassify 移动克拉克森分类
 func MoveClarksonsClassify(classifyId, parentClassifyId, prevClassifyId, nextClassifyId int) (err error, errMsg string) {
 	//判断分类是否存在
 	classifyInfo, err := data_manage.GetClarksonsClassifyById(classifyId)
@@ -304,6 +304,19 @@ func MoveClarksonsClassify(classifyId, parentClassifyId, prevClassifyId, nextCla
 		return
 	}
 
+	// 校验移动的父级目录下是否有重名分类
+	count, e := data_manage.GetBaseFromClarksonsClassifyCount(classifyInfo.ClassifyName, parentClassifyId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		errMsg = "移动失败"
+		err = errors.New("获取父级目录下的同名分类失败, Err: " + e.Error())
+		return
+	}
+	if count > 0 {
+		errMsg = "移动失败,分类名称已存在"
+		err = errors.New("该父级目录下已存在同名分类,请重新命名")
+		return
+	}
+
 	updateCol := make([]string, 0)
 
 	//判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
@@ -405,7 +418,7 @@ func MoveClarksonsClassify(classifyId, parentClassifyId, prevClassifyId, nextCla
 	return
 }
 
-// MoveClarksonsData 移动卓创红期指标
+// MoveClarksonsData 移动克拉克森指标
 func MoveClarksonsData(indexId, classifyId, prevIndexId, nextIndexId int) (err error, errMsg string) {
 	//分类信息
 	clarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId)
@@ -607,7 +620,6 @@ func GetClarksonsIndexInfo(keyWord string, classifyIdList []string, frequencyLis
 	return &indexPage, nil
 }
 
-
 // GetClarkssonsIndexList 获取指标列表
 func GetClarkssonsIndexList(searchParams string) (rzdIndexInfoList []*data_manage.BaseFromRzdIndexList, err error) {
 
@@ -624,4 +636,4 @@ func GetClarkssonsIndexList(searchParams string) (rzdIndexInfoList []*data_manag
 	}
 
 	return rzdIndexList, nil
-}
+}

+ 2 - 1
static/ErrMsgConfig.json

@@ -60,5 +60,6 @@
   "删除失败": "Deletion failed.",
   "指标数据异常,请检查": "The metric data is abnormal, please check.",
   "原指标与替换指标存在引用关系,不允许替换": "Original indicators and replacement indicators have a referencing relationship, which is not allowed to be replaced.",
-  "请选择分类": "Please Select a Category"
+  "请选择分类": "Please Select a Category",
+  "分类已存在": "The category already exists."
 }