소스 검색

fix: 萝卜投研分类移动

hsun 2 주 전
부모
커밋
66d5807e0e
2개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 0
      models/data_manage/base_from_radish_research_classify.go
  2. 1 1
      services/data/base_from_radish_research_classify.go

+ 7 - 0
models/data_manage/base_from_radish_research_classify.go

@@ -300,3 +300,10 @@ func (m *BaseFromRadishResearchClassify) UpdateLevelPath(classifyId int, levelPa
 	err = global.DbMap[utils.DbNameIndex].Exec(sql, levelPath, classifyId).Error
 	return
 }
+
+// GetRadishResearchClassifyByParentIdAndName 根据父级ID和名称获取分类
+func GetRadishResearchClassifyByParentIdAndName(parentId int, classifyName string, classifyId int) (item *EdbClassify, err error) {
+	sql := `SELECT * FROM base_from_radish_research_classify WHERE parent_id = ? AND classify_name = ? AND base_from_radish_research_classify_id <> ? LIMIT 1`
+	err = global.DbMap[utils.DbNameIndex].Raw(sql, parentId, classifyName, classifyId).First(&item).Error
+	return
+}

+ 1 - 1
services/data/base_from_radish_research_classify.go

@@ -87,7 +87,7 @@ func RadishResearchMoveClassify(req data_manage.BaseFromRadishResearchClassifyMo
 			return
 		}
 		// 如果是移动目录, 那么校验一下父级目录下是否有重名目录
-		exists, e := data_manage.GetEdbClassifyByParentIdAndName(parentClassifyId, edbClassifyInfo.ClassifyName, classifyId)
+		exists, e := data_manage.GetRadishResearchClassifyByParentIdAndName(parentClassifyId, edbClassifyInfo.ClassifyName, classifyId)
 		if e != nil && !utils.IsErrNoRow(e) {
 			errMsg = "移动失败"
 			err = fmt.Errorf("获取父级分类下的同名分类失败, Err: %s", e.Error())