소스 검색

Merge branch 'BI_Dashboard' into dm

zwxi 6 달 전
부모
커밋
0069e162d3
2개의 변경된 파일31개의 추가작업 그리고 1개의 파일을 삭제
  1. 25 1
      controllers/bi_dashboard.go
  2. 6 0
      models/bi_dashboard/bi_dashboard_classify.go

+ 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 = "编辑失败"

+ 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.Where("bi_dashboard_classify_name = ?", classifyName).Count(&count).Error
+	return
+}