Browse Source

Merge branch 'feature/gn_edb' into dm

hsun 5 months ago
parent
commit
8244561b7b

+ 4 - 4
controllers/data_manage/data_manage_permission/data_manage_permission.go

@@ -107,7 +107,7 @@ func (c *DataMangePermissionController) SetPermissionEdbChartClassifyIsPermissio
 		return
 	}
 
-	if req.Source <= 0 || req.Source > 6 {
+	if req.Source <= 0 || req.Source > 7 {
 		br.Msg = "错误的来源"
 		br.IsSendEmail = false
 		return
@@ -165,7 +165,7 @@ func (c *DataMangePermissionController) SetEdbChartClassifyPermission() {
 		return
 	}
 
-	if req.Source <= 0 || req.Source > 6 {
+	if req.Source <= 0 || req.Source > 7 {
 		br.Msg = "错误的来源"
 		br.IsSendEmail = false
 		return
@@ -282,7 +282,7 @@ func (c *DataMangePermissionController) GetEdbChartClassifyPermission() {
 	}
 
 	source, _ := c.GetInt("Source")
-	if source <= 0 || source > 6 {
+	if source <= 0 || source > 7 {
 		br.Msg = "错误的来源"
 		br.IsSendEmail = false
 		return
@@ -356,7 +356,7 @@ func (c *DataMangePermissionController) GetEdbChartNoPermission() {
 	}
 
 	source, _ := c.GetInt("Source")
-	if source <= 0 || source > 6 {
+	if source <= 0 || source > 7 {
 		br.Msg = "错误的来源"
 		br.IsSendEmail = false
 		return

+ 1 - 1
controllers/data_manage/data_manage_permission/data_move.go

@@ -247,7 +247,7 @@ func (c *DataMangePermissionController) MoveEdbChartUser() {
 		return
 	}
 
-	if req.Source <= 0 || req.Source > 6 {
+	if req.Source <= 0 || req.Source > 7 {
 		br.Msg = "错误的来源"
 		br.IsSendEmail = false
 		return

+ 1 - 0
controllers/data_manage/edb_info.go

@@ -4503,6 +4503,7 @@ func (this *EdbInfoController) RelationEdbList() {
 			}
 
 			item.DataList = dataList
+			item.ConvertToResp()
 			edbList = append(edbList, item)
 		}
 	}

+ 2 - 2
models/data_manage/data_manage_permission/edb.go

@@ -171,8 +171,8 @@ func SetPermissionByEdbIdList(edbIdList []string, userIdList []int, edbInfoType
 		//	return
 		//}
 
-		sql = `UPDATE edb_info SET is_join_permission=?,modify_time=now() WHERE edb_info_type = ? AND edb_info_id in (` + utils.GetOrmInReplace(edbNum) + `) `
-		err = to.Raw(sql, isJoinPermission, edbInfoType, edbIdList).Error
+		sql = `UPDATE edb_info SET is_join_permission=?,modify_time=now() WHERE edb_info_type = ? AND edb_info_id in (?) `
+		err = to.Exec(sql, isJoinPermission, edbInfoType, edbIdList).Error
 		if err != nil {
 			return
 		}

+ 11 - 7
services/data/data_manage_permission/data_move.go

@@ -304,7 +304,7 @@ func GetMoveEdbChartList(source, subSource, userId int, keyword, classify string
 				CreateUserName: v.SysUserRealName,
 			})
 		}
-	case 3, 4, 7: //ETA指标库、ETA预测指标、指标加工
+	case 3, 4, utils.EdbPermissionSourceCalculate: //ETA指标库、ETA预测指标、指标加工
 		if keyword != `` {
 			condition += " AND (edb_code like ? OR edb_name like ? OR edb_name_en like ? OR sys_user_real_name like ? ) "
 			pars = utils.GetLikeKeywordPars(pars, keyword, 4)
@@ -326,9 +326,9 @@ func GetMoveEdbChartList(source, subSource, userId int, keyword, classify string
 
 		// 指标加工
 		if source != 4 {
-			edbType := 1
-			if source == 7 {
-				edbType = 2
+			edbType := utils.EdbTypeBase
+			if source == utils.EdbPermissionSourceCalculate {
+				edbType = utils.EdbTypeCalculate
 			}
 			condition += ` AND edb_type = ? `
 			pars = append(pars, edbType)
@@ -500,7 +500,7 @@ func GetMoveEdbChartList(source, subSource, userId int, keyword, classify string
 }
 
 // MoveEdbChart 转移指标/图表创建人
-// @param source 来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
+// @param source 来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格;7:计算指标库
 func MoveEdbChart(source, subSource, oldUserId, newUserId int, isSelectAll bool, dataId, noDataId []string, keyword, classify string, opUserId int, opUserName string) (err error, errMsg string) {
 	adminInfo, err := system.GetSysAdminById(newUserId)
 	if err != nil {
@@ -612,12 +612,16 @@ func MoveEdbChart(source, subSource, oldUserId, newUserId int, isSelectAll bool,
 			err = data_manage.ModifyMysteelChemicalIndexUserIdByCodeList(dataId, adminInfo.AdminId, adminInfo.RealName)
 		}
 
-	case 3, 4: //ETA指标库、ETA预测指标
+	case 3, 4, utils.EdbPermissionSourceCalculate: //ETA指标库、ETA预测指标
 		if source == 3 {
 			content += `(ETA指标库)`
-		} else {
+		}
+		if source == 4 {
 			content += `(ETA预测指标)`
 		}
+		if source == utils.EdbPermissionSourceCalculate {
+			content += `(ETA计算指标)`
+		}
 		tmpList, tmpErr := data_manage.GetEdbInfoListByEdbInfoId(dataId)
 		if tmpErr != nil {
 			err = tmpErr

+ 21 - 10
services/data/data_manage_permission/edb_permission.go

@@ -61,7 +61,7 @@ func SetEdbChartPermission(source, subSource, userId int, authUserList []int, is
 	dataList := make([]data_manage_permission.DataItem, 0)
 
 	switch source {
-	case 3, 4, 7:
+	case 3, 4, utils.EdbPermissionSourceCalculate:
 		//ETA指标库、ETA预测指标
 		if source == 3 {
 			content += `(ETA指标库)`
@@ -69,7 +69,7 @@ func SetEdbChartPermission(source, subSource, userId int, authUserList []int, is
 		if source == 4 {
 			content += `(ETA预测指标)`
 		}
-		if source == 7 {
+		if source == utils.EdbPermissionSourceCalculate {
 			content += `(ETA计算指标)`
 		}
 
@@ -216,13 +216,17 @@ func SetDataClassifyIsPermission(source, subSource int, classifyIdList []int, op
 	classifyDataList := make([]data_manage_permission.ClassifyDataItem, 0)
 
 	switch source {
-	case 3, 4:
+	case 3, 4, utils.EdbPermissionSourceCalculate:
 		//ETA指标库、ETA预测指标
 		if source == 3 {
 			content += `(ETA指标库)`
-		} else {
+		}
+		if source == 4 {
 			content += `(ETA预测指标)`
 		}
+		if source == utils.EdbPermissionSourceCalculate {
+			content += `(ETA计算指标)`
+		}
 		{
 			// 分类信息
 			classifyInfoList, tmpErr := data_manage.GetEdbClassifyByIdList(classifyIdList)
@@ -352,14 +356,18 @@ func SetEdbChartClassifyPermission(source, subSource int, authUserList []int, cl
 	// 先获取所有的涉密分类,然后根据用户去判断那些分类给权限了
 
 	switch source {
-	case 3, 4: //ETA指标库、ETA预测指标
+	case 3, 4, utils.EdbPermissionSourceCalculate: //ETA指标库、ETA预测指标
 
 		//ETA指标库、ETA预测指标
 		if source == 3 {
 			content += `(ETA指标库)`
-		} else {
+		}
+		if source == 4 {
 			content += `(ETA预测指标)`
 		}
+		if source == utils.EdbPermissionSourceCalculate {
+			content += `(ETA计算指标)`
+		}
 
 		classifyType := 0
 		if source == 4 {
@@ -469,7 +477,7 @@ func SetEdbChartClassifyPermission(source, subSource int, authUserList []int, cl
 // @return err error
 func GetEdbChartClassifyIdListPermissionByUserId(source, subSource, userId int) (idList []int, err error) {
 	switch source {
-	case 3, 4: //ETA指标库、ETA预测指标
+	case 3, 4, utils.EdbPermissionSourceCalculate: //ETA指标库、ETA预测指标
 		//tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
 		//if tmpErr != nil {
 		//	err = tmpErr
@@ -482,6 +490,9 @@ func GetEdbChartClassifyIdListPermissionByUserId(source, subSource, userId int)
 		if source == 4 {
 			classifyType = 1
 		}
+		if source == utils.EdbPermissionSourceCalculate {
+			classifyType = utils.EdbClassifyTypeCalculate
+		}
 		idList, err = data_manage_permission.GetPermissionEdbClassifyIdListByUserId(userId, classifyType)
 	case 5:
 		//图库
@@ -507,7 +518,7 @@ func GetEdbChartClassifyIdListPermissionByUserId(source, subSource, userId int)
 // @return err error
 func GetUserIdListPermissionByDataId(source, subSource, dataId int) (idList []int, err error) {
 	switch source {
-	case 3, 4, 7:
+	case 3, 4, utils.EdbPermissionSourceCalculate:
 		// ETA指标库、ETA预测指标
 		edbInfoType := 0
 		if source == 4 {
@@ -545,7 +556,7 @@ func GetUserIdListNoPermissionByDataId(source, subSource, dataId int) (idList []
 	authIdList := make([]int, 0)
 
 	switch source {
-	case 3, 4:
+	case 3, 4, utils.EdbPermissionSourceCalculate:
 		// ETA指标库、ETA预测指标
 		edbInfoType := 0
 		if source == 4 {
@@ -668,7 +679,7 @@ func InheritParentClassify(source, subSource, classifyId, parentClassifyId int,
 	}
 	uniqueCode := uuid.NewUUID().Hex32()
 	switch source {
-	case 3, 4:
+	case 3, 4, utils.EdbPermissionSourceCalculate:
 		//ETA指标库、ETA预测指标
 		// 分类信息
 		parentClassifyInfo, tmpErr := data_manage.GetEdbClassifyById(parentClassifyId)

+ 5 - 2
services/data/edb_classify.go

@@ -320,8 +320,8 @@ func AddEdbClassify(classifyName string, parentId, level int, classifyType uint8
 	}
 
 	// 层级校验
-	if level > 9 {
-		errMsg = `最高只支持添加9级分类`
+	if level > utils.EdbClassifyMaxLevel {
+		errMsg = fmt.Sprintf("最高只支持添加%d级分类", level)
 		return
 	}
 
@@ -378,6 +378,9 @@ func AddEdbClassify(classifyName string, parentId, level int, classifyType uint8
 		if classifyType == 1 {
 			source = 4
 		}
+		if classifyType == utils.EdbClassifyTypeCalculate {
+			source = utils.EdbPermissionSourceCalculate
+		}
 		go data_manage_permission.InheritParentClassify(source, int(classifyType), int(newId), classifyInfo.ParentId, classifyInfo.ClassifyName)
 	}
 

+ 4 - 0
utils/constants.go

@@ -491,3 +491,7 @@ const (
 	EdbTypeBase      = 1 // 指标类型-基础指标
 	EdbTypeCalculate = 2 // 指标类型-计算指标
 )
+
+const (
+	EdbPermissionSourceCalculate = 7 // 指标权限来源-计算指标
+)