Просмотр исходного кода

Merge remote-tracking branch 'origin/dm' into dm

Roc 6 месяцев назад
Родитель
Сommit
8ce7b392c1

+ 25 - 1
controllers/bi_dashboard.go

@@ -555,7 +555,7 @@ func (this *BIDaShboardController) PublicList() {
 	resp := make([]*bi_dashboard.RespPublicGroupListItem, 0)
 	// 获取公共看板列表
 	publicCond := ` AND state = 6 AND bi_dashboard_classify_id > 0 `
-	publicPars := []interface{}{this.SysUser.AdminId}
+	publicPars := make([]interface{}, 0)
 	publicList, err := bi_dashboard.GetBiDashboardList(publicCond, publicPars)
 	if err != nil {
 		err = errors.New("我的看板列表查询出错:" + err.Error())
@@ -686,6 +686,16 @@ func (this *BIDaShboardController) AddDashboardClassify() {
 		br.ErrMsg = "获取最大排序值失败,Err:" + err.Error()
 		return
 	}
+	count, err := bi_dashboard.GetBiDashboardClassifyByName(req.ClassifyName)
+	if err != nil {
+		br.Msg = "获取分类名称失败"
+		br.ErrMsg = "获取分类名称失败,Err:" + err.Error()
+		return
+	}
+	if count > 0 {
+		br.Msg = "分类名称已存在"
+		return
+	}
 
 	item := &bi_dashboard.BiDashboardClassify{
 		BiDashboardClassifyName: req.ClassifyName,
@@ -785,6 +795,20 @@ func (this *BIDaShboardController) DelDashboardClassify() {
 		return
 	}
 
+	publicCond := ` AND state = 6 AND bi_dashboard_classify_id = ? `
+	publicPars := make([]interface{}, 0)
+	publicPars = append(publicPars, req.BiDashboardClassifyId)
+	publicList, err := bi_dashboard.GetBiDashboardList(publicCond, publicPars)
+	if err != nil {
+		err = errors.New("我的看板列表查询出错:" + err.Error())
+		return
+	}
+	if len(publicList) > 0 {
+		br.Msg = "该分类下有关联看板,无法删除"
+		return
+	}
+
+
 	err = bi_dashboard.DelBiDashboardClassify(req.BiDashboardClassifyId)
 	if err != nil {
 		br.Msg = "编辑失败"

+ 1 - 1
controllers/data_manage/chart_classify.go

@@ -791,7 +791,7 @@ func (this *ChartClassifyController) ChartClassifyMove() {
 	}
 
 	// 校验移动的父级目录下是否有重名分类
-	exists, e := data_manage.GetChartClassifyByParentIdAndName(req.ParentClassifyId, chartClassifyInfo.ChartClassifyName, req.ClassifyId)
+	exists, e := data_manage.GetChartClassifyByParentIdAndName(utils.CHART_SOURCE_DEFAULT, req.ParentClassifyId, chartClassifyInfo.ChartClassifyName, req.ClassifyId)
 	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "移动失败"
 		br.ErrMsg = "获取父级目录下的同名分类失败, Err: " + e.Error()

+ 3 - 3
controllers/speech_recognition/speech_recognition_menu.go

@@ -521,10 +521,10 @@ func (this *SpeechRecognitionMenuController) Move() {
 		return
 	}
 
-	e, _ := services.MoveSpeechMenu(req)
-	if e != nil {
+	e, errMsg := services.MoveSpeechMenu(req)
+	if e != nil || errMsg != "" {
 		br.Msg = "操作失败"
-		br.ErrMsg = "移动目录/语音识别失败, Err: " + e.Error()
+		br.ErrMsg = "移动目录/语音识别失败, Err: " + e.Error() + ";errMsg:" + errMsg
 		return
 	}
 

+ 6 - 0
models/bi_dashboard/bi_dashboard_classify.go

@@ -118,3 +118,9 @@ type RespPublicGroupListItem struct {
 	DashboardList []*BiDashboard
 	Children      []*RespPublicGroupListItem
 }
+
+// getByName
+func GetBiDashboardClassifyByName(classifyName string) (count int64, err error) {
+	err = global.DEFAULT_DmSQL.Model(&BiDashboardClassify{}).Where("bi_dashboard_classify_name = ?", classifyName).Count(&count).Error
+	return
+}

+ 3 - 3
models/data_manage/chart_classify.go

@@ -346,10 +346,10 @@ func GetCrossVarietyChartClassifyBySysUserId(sysUserId int) (item *ChartClassify
 }
 
 // GetChartClassifyByParentIdAndName 根据父级ID和名称获取分类
-func GetChartClassifyByParentIdAndName(parentId int, classifyName string, classifyId int) (item *ChartClassify, err error) {
+func GetChartClassifyByParentIdAndName(source, parentId int, classifyName string, classifyId int) (item *ChartClassify, err error) {
 	o := global.DmSQL["data"]
-	sql := `SELECT * FROM chart_classify WHERE parent_id = ? AND chart_classify_name = ? AND chart_classify_id <> ? LIMIT 1`
-	err = o.Raw(sql, parentId, classifyName, classifyId).First(&item).Error
+	sql := `SELECT * FROM chart_classify WHERE source = ? AND parent_id = ? AND chart_classify_name = ? AND chart_classify_id <> ? LIMIT 1`
+	err = o.Raw(sql, source, parentId, classifyName, classifyId).First(&item).Error
 
 	return
 }

+ 1 - 1
models/data_manage/chart_info_range_analysis.go

@@ -224,7 +224,7 @@ func EditRangeChartInfoAndMapping(req *EditChartInfoReq, edbInfoIdStr, lang stri
 	sql += `WHERE chart_info_id = ?`
 
 	pars = append(pars, req.ChartInfoId)
-	err = to.Exec(sql, pars).Error
+	err = to.Exec(sql, pars...).Error
 	if err != nil {
 		fmt.Println("UPDATE  chart_info Err:", err.Error())
 		return err

+ 1 - 1
services/data/chart_classify.go

@@ -469,7 +469,7 @@ func MoveChartClassify(req data_manage.MoveChartClassifyReq, sysUser *system.Adm
 			return
 		}
 		// 如果是移动目录, 那么校验一下父级目录下是否有重名目录
-		exists, e := data_manage.GetChartClassifyByParentIdAndName(parentClassifyId, chartClassifyInfo.ChartClassifyName, classifyId)
+		exists, e := data_manage.GetChartClassifyByParentIdAndName(utils.CHART_SOURCE_RANGE_ANALYSIS, parentClassifyId, chartClassifyInfo.ChartClassifyName, classifyId)
 		if e != nil && !utils.IsErrNoRow(e) {
 			errMsg = "移动失败"
 			err = fmt.Errorf("获取父级分类下的同名分类失败, Err: %s", e.Error())

+ 1 - 1
services/speech_recognition.go

@@ -333,7 +333,7 @@ func MoveSpeechMenu(req speech_recognition.SpeechRecognitionMenuMoveReq) (err er
 				err = fmt.Errorf("获取父级目录下的同名目录失败, Err: %s", e.Error())
 				return
 			}
-			if exists != nil {
+			if exists != nil && exists.SpeechRecognitionMenuId > 0 {
 				errMsg = "移动失败,目录名称已存在"
 				return
 			}

+ 2 - 2
utils/constants.go

@@ -278,8 +278,8 @@ const (
 
 // 图表类型
 const (
-	CHART_SOURCE_DEFAULT                         = 1
-	CHART_SOURCE_FUTURE_GOOD                     = 2
+	CHART_SOURCE_DEFAULT                         = 1  //图表
+	CHART_SOURCE_FUTURE_GOOD                     = 2  //商品价格曲线
 	CHART_SOURCE_CORRELATION                     = 3  // 相关性图表
 	CHART_SOURCE_ROLLING_CORRELATION             = 4  // 滚动相关性图表
 	CHART_SOURCE_FUTURE_GOOD_PROFIT              = 5  // 商品利润曲线