Selaa lähdekoodia

Merge remote-tracking branch 'origin/eta/1.7.6' into debug

Roc 1 vuosi sitten
vanhempi
commit
4fc02a1b49

+ 34 - 31
models/data_manage/data_manage_permission/data_manage_permission.go

@@ -21,7 +21,7 @@ type SetDataIsPermissionReq struct {
 // @author: Roc
 // @datetime 2024-03-27 14:15:42
 // @param classifyIdList []int
-func SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList []int) (err error) {
+func SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList []int, classifyType int) (err error) {
 	num := len(classifyIdList)
 	if num <= 0 {
 		return
@@ -51,16 +51,16 @@ func SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList []int) (err error
 	//}
 
 	// 先将所有已经设置了涉密的分类设置为不涉密
-	sql := `UPDATE edb_classify SET is_join_permission=?,modify_time=now() WHERE is_join_permission = 1 `
-	_, err = o.Raw(sql, 0).Exec()
+	sql := `UPDATE edb_classify SET is_join_permission=?,modify_time=now() WHERE is_join_permission = 1 AND classify_type = ?`
+	_, err = o.Raw(sql, 0, classifyType).Exec()
 	if err != nil {
 		return
 	}
 
 	if len(classifyIdList) > 0 {
 		// 将对应的分类设置为涉密
-		sql = `UPDATE edb_classify SET is_join_permission=?,modify_time=now() WHERE classify_id in (` + utils.GetOrmInReplace(num) + `) `
-		_, err = o.Raw(sql, 1, classifyIdList).Exec()
+		sql = `UPDATE edb_classify SET is_join_permission=?,modify_time=now() WHERE classify_type = ? AND classify_id in (` + utils.GetOrmInReplace(num) + `) `
+		_, err = o.Raw(sql, 1, classifyType, classifyIdList).Exec()
 		if err != nil {
 			return
 		}
@@ -88,21 +88,23 @@ type SetEdbChartPermissionReq struct {
 // EdbInfoPermission
 // @Description: 指标权限表
 type EdbInfoPermission struct {
-	PermissionId int64     `json:"permission_id" orm:"column(permission_id);pk"`
-	EdbInfoId    int32     `json:"edb_info_id"` // 指标id
-	SysUserId    int32     `json:"sys_user_id"` // 系统用户id
-	ModifyTime   time.Time `json:"modify_time"` // 变更时间
-	CreateTime   time.Time `json:"create_time"` // 关系建立时间
+	EdbInfoPermissionId int64     `json:"edb_info_permission_id" orm:"column(edb_info_permission_id);pk"`
+	EdbInfoId           int32     `json:"edb_info_id"`   // 指标id
+	EdbInfoType         int32     `json:"edb_info_type"` // 指标类型,0:普通指标,1:预测指标
+	SysUserId           int32     `json:"sys_user_id"`   // 系统用户id
+	ModifyTime          time.Time `json:"modify_time"`   // 变更时间
+	CreateTime          time.Time `json:"create_time"`   // 关系建立时间
 }
 
 // EdbClassifyPermission
 // @Description: 指标分类权限表
 type EdbClassifyPermission struct {
-	PermissionId  int64     `json:"permission_id" orm:"column(permission_id);pk"`
-	EdbClassifyId int32     `json:"edb_classify_id"` // 分类id
-	SysUserId     int32     `json:"sys_user_id"`     // 系统用户id
-	ModifyTime    time.Time `json:"modify_time"`     // 变更时间
-	CreateTime    time.Time `json:"create_time"`     // 关系建立时间
+	EdbClassifyPermissionId int64     `json:"edb_classify_permission_id" orm:"column(edb_classify_permission_id);pk"`
+	EdbClassifyId           int32     `json:"edb_classify_id"`   // 分类id
+	EdbClassifyType         int32     `json:"edb_classify_type"` // 分类类型,0:普通指标分类,1:预测指标分类
+	SysUserId               int32     `json:"sys_user_id"`       // 系统用户id
+	ModifyTime              time.Time `json:"modify_time"`       // 变更时间
+	CreateTime              time.Time `json:"create_time"`       // 关系建立时间
 }
 
 // SetPermissionEdbChartByEdbIdList
@@ -112,7 +114,7 @@ type EdbClassifyPermission struct {
 // @param edbIdList []string
 // @param userIdList []int
 // @return err error
-func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err error) {
+func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int, edbInfoType int) (err error) {
 	edbNum := len(edbIdList)
 	if edbNum <= 0 {
 		return
@@ -131,8 +133,8 @@ func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err
 
 	// 获取已经配置的指标权限用户
 	edbInfoPermissionList := make([]*EdbInfoPermission, 0)
-	sql := `SELECT * FROM edb_info_permission WHERE edb_info_id in (` + utils.GetOrmInReplace(edbNum) + `) `
-	_, err = o.Raw(sql, edbIdList).QueryRows(&edbInfoPermissionList)
+	sql := `SELECT * FROM edb_info_permission WHERE edb_info_type = ? AND edb_info_id in (` + utils.GetOrmInReplace(edbNum) + `) `
+	_, err = o.Raw(sql, edbInfoType, edbIdList).QueryRows(&edbInfoPermissionList)
 	if err != nil {
 		return
 	}
@@ -150,8 +152,8 @@ func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err
 			// 标记指标为不纳入权限管控
 			isJoinPermission = 0
 		}
-		sql = `UPDATE edb_info SET is_join_permission=?,modify_time=now() WHERE edb_info_id in (` + utils.GetOrmInReplace(edbNum) + `) `
-		_, err = o.Raw(sql, isJoinPermission, edbIdList).Exec()
+		sql = `UPDATE edb_info SET is_join_permission=?,modify_time=now() WHERE edb_info_type = ? AND edb_info_id in (` + utils.GetOrmInReplace(edbNum) + `) `
+		_, err = o.Raw(sql, isJoinPermission, edbInfoType, edbIdList).Exec()
 		if err != nil {
 			return
 		}
@@ -198,12 +200,12 @@ func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err
 		// 待移除的配置项
 		deletePermissionIdList := make([]int64, 0)
 		for _, v := range edbInfoPermissionMap {
-			deletePermissionIdList = append(deletePermissionIdList, v.PermissionId)
+			deletePermissionIdList = append(deletePermissionIdList, v.EdbInfoPermissionId)
 		}
 
 		deletePermissionIdNum := len(deletePermissionIdList)
 		if deletePermissionIdNum > 0 {
-			sql = "DELETE FROM edb_info_permission WHERE permission_id in (" + utils.GetOrmInReplace(deletePermissionIdNum) + ")"
+			sql = "DELETE FROM edb_info_permission WHERE edb_info_permission_id in (" + utils.GetOrmInReplace(deletePermissionIdNum) + ")"
 			_, err = o.Raw(sql, deletePermissionIdList).Exec()
 			if err != nil {
 				return
@@ -230,7 +232,7 @@ type SetEdbChartClassifyPermissionReq struct {
 // @param classifyIdList []int
 // @param userIdList []int
 // @return err error
-func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userIdList []int) (err error) {
+func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userIdList []int, classifyType int) (err error) {
 	userNum := len(userIdList)
 	if userNum <= 0 {
 		return
@@ -249,8 +251,8 @@ func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userI
 
 	// 获取当前选择用户已经配置的指标分类权限
 	classifyPermissionList := make([]*EdbClassifyPermission, 0)
-	sql := `SELECT * FROM edb_classify_permission WHERE sys_user_id in (` + utils.GetOrmInReplace(userNum) + `) `
-	_, err = o.Raw(sql, userIdList).QueryRows(&classifyPermissionList)
+	sql := `SELECT * FROM edb_classify_permission WHERE edb_classify_type = ? AND sys_user_id in (` + utils.GetOrmInReplace(userNum) + `) `
+	_, err = o.Raw(sql, classifyType, userIdList).QueryRows(&classifyPermissionList)
 	if err != nil {
 		return
 	}
@@ -273,10 +275,11 @@ func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userI
 				// 如果不存在,那么就提那家
 				addList = append(addList, &EdbClassifyPermission{
 					//PermissionId: 0,
-					EdbClassifyId: int32(classifyId),
-					SysUserId:     int32(userId),
-					ModifyTime:    time.Now(),
-					CreateTime:    time.Now(),
+					EdbClassifyId:   int32(classifyId),
+					EdbClassifyType: int32(classifyType),
+					SysUserId:       int32(userId),
+					ModifyTime:      time.Now(),
+					CreateTime:      time.Now(),
 				})
 			}
 		}
@@ -295,12 +298,12 @@ func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userI
 		// 获取移除的配置项
 		deletePermissionIdList := make([]int64, 0)
 		for _, v := range classifyPermissionMap {
-			deletePermissionIdList = append(deletePermissionIdList, v.PermissionId)
+			deletePermissionIdList = append(deletePermissionIdList, v.EdbClassifyPermissionId)
 		}
 
 		deletePermissionIdNum := len(deletePermissionIdList)
 		if deletePermissionIdNum > 0 {
-			sql = "DELETE FROM edb_classify_permission WHERE permission_id in (" + utils.GetOrmInReplace(deletePermissionIdNum) + ")"
+			sql = "DELETE FROM edb_classify_permission WHERE edb_classify_permission_id in (" + utils.GetOrmInReplace(deletePermissionIdNum) + ")"
 			_, err = o.Raw(sql, deletePermissionIdList).Exec()
 			if err != nil {
 				return

+ 15 - 3
services/data/data_manage_permission/edb_permission.go

@@ -62,7 +62,11 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
 		//if len(tmpList) > 0 {
 		//}
 		// 重新设置权限
-		err = data_manage_permission.SetPermissionEdbChartByEdbIdList(dataId, userList)
+		edbInfoType := 0
+		if source == 4 {
+			edbInfoType = 1
+		}
+		err = data_manage_permission.SetPermissionEdbChartByEdbIdList(dataId, userList, edbInfoType)
 	//case 5: //图库
 	//	tmpList, tmpErr := data_manage.GetChartInfoListGroupByUserId(dataId)
 	//	if tmpErr != nil {
@@ -126,7 +130,11 @@ func SetDataIsPermission(source, subSource int, classifyIdList []int) (err error
 		//if len(tmpList) > 0 {
 		//}
 		// 重新设置权限
-		err = data_manage_permission.SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList)
+		classifyType := 0
+		if source == 4 {
+			classifyType = 1
+		}
+		err = data_manage_permission.SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList, classifyType)
 	//case 5: //图库
 
 	//case 6: // ETA表格
@@ -165,7 +173,11 @@ func SetEdbChartClassifyPermission(source, subSource int, userList []int, classi
 		//if len(tmpList) > 0 {
 		//}
 		// 重新设置权限
-		err = data_manage_permission.SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList, userList)
+		classifyType := 0
+		if source == 4 {
+			classifyType = 1
+		}
+		err = data_manage_permission.SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList, userList, classifyType)
 	//case 5: //图库
 	//	tmpList, tmpErr := data_manage.GetChartInfoListGroupByUserId(dataId)
 	//	if tmpErr != nil {