浏览代码

fix:ETA预测指标库,只看我的勾选后,显示图表有别人创建的图表

Roc 1 年之前
父节点
当前提交
3a75294afb
共有 3 个文件被更改,包括 26 次插入6 次删除
  1. 1 1
      controllers/data_manage/edb_classify.go
  2. 13 1
      controllers/data_manage/predict_edb_info.go
  3. 12 4
      models/data_manage/edb_info.go

+ 1 - 1
controllers/data_manage/edb_classify.go

@@ -762,7 +762,7 @@ func (this *EdbClassifyController) ClassifyEdbInfoList() {
 		noPermissionEdbInfoIdMap[v.EdbInfoId] = true
 	}
 
-	allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(classifyId, 0)
+	allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(classifyId, 0, 0)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()

+ 13 - 1
controllers/data_manage/predict_edb_info.go

@@ -1798,9 +1798,11 @@ func (this *PredictEdbInfoController) Modify() {
 //	data.AddOrEditAllEdbInfoToEs()
 //}
 
+// ClassifyEdbInfoItems
 // @Title 获取分类下指标接口
 // @Description 获取分类下指标接口
 // @Param   ClassifyId   query   int  true       "分类id"
+// @Param   IsOnlyMe   query   bool  false       "是否只看我的"
 // @Success 200 {object} data_manage.EdbClassifyListResp
 // @router /predict_edb_info/items [get]
 func (this *PredictEdbInfoController) ClassifyEdbInfoItems() {
@@ -1816,6 +1818,9 @@ func (this *PredictEdbInfoController) ClassifyEdbInfoItems() {
 		return
 	}
 
+	// 是否只看我的
+	isOnlyMe, _ := this.GetBool("IsOnlyMe")
+
 	// 获取当前账号的不可见指标
 	obj := data_manage.EdbInfoNoPermissionAdmin{}
 	confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
@@ -1829,7 +1834,13 @@ func (this *PredictEdbInfoController) ClassifyEdbInfoItems() {
 		noPermissionEdbInfoIdMap[v.EdbInfoId] = true
 	}
 
-	allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(classifyId, 1)
+	// 如果选择了只看我的,那么只查询归属于我的账号
+	sysUserId := 0
+	if isOnlyMe {
+		sysUserId = this.SysUser.AdminId
+	}
+
+	allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(classifyId, 1, sysUserId)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -1842,6 +1853,7 @@ func (this *PredictEdbInfoController) ClassifyEdbInfoItems() {
 		if _, ok := noPermissionEdbInfoIdMap[v.EdbInfoId]; ok {
 			continue
 		}
+
 		button := data.GetEdbOpButton(this.SysUser, v.SysUserId, v.EdbType, utils.EDB_INFO_TYPE)
 		button.AddButton = false //不管有没有权限,指标都是没有添加按钮的
 		v.Button = button

+ 12 - 4
models/data_manage/edb_info.go

@@ -1709,11 +1709,19 @@ type SetEdbDataInsertConfigReq struct {
 	Value     float64 `description:"值"`
 }
 
-// GetEdbInfoAll 用于分类展示
-func GetEdbInfoByClassifyId(classifyId, edbInfoType int) (items []*EdbClassifyItems, err error) {
+// GetEdbInfoByClassifyId 用于分类展示
+func GetEdbInfoByClassifyId(classifyId, edbInfoType, adminId int) (items []*EdbClassifyItems, err error) {
 	o := orm.NewOrmUsingDB("data")
-	sql := ` SELECT edb_info_id,classify_id,edb_name_source AS classify_name,edb_name_en AS classify_name_en,unique_code,source_name,source,sys_user_id,sys_user_real_name,start_date,edb_code,edb_type FROM edb_info WHERE classify_id = ? AND edb_info_type = ? order by sort asc,edb_info_id asc`
-	_, err = o.Raw(sql, classifyId, edbInfoType).QueryRows(&items)
+	sql := ` SELECT edb_info_id,classify_id,edb_name_source AS classify_name,edb_name_en AS classify_name_en,unique_code,source_name,source,sys_user_id,sys_user_real_name,start_date,edb_code,edb_type FROM edb_info WHERE classify_id = ? AND edb_info_type = ?`
+
+	pars := []interface{}{classifyId, edbInfoType}
+	// 如果筛选了用户id
+	if adminId > 0 {
+		sql += ` AND sys_user_id = ? `
+		pars = append(pars, adminId)
+	}
+	sql += ` order by sort asc,edb_info_id asc `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }