|
@@ -21,7 +21,7 @@ type SetDataIsPermissionReq struct {
|
|
// @author: Roc
|
|
// @author: Roc
|
|
// @datetime 2024-03-27 14:15:42
|
|
// @datetime 2024-03-27 14:15:42
|
|
// @param classifyIdList []int
|
|
// @param classifyIdList []int
|
|
-func SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList []int) (err error) {
|
|
|
|
|
|
+func SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList []int, classifyType int) (err error) {
|
|
num := len(classifyIdList)
|
|
num := len(classifyIdList)
|
|
if num <= 0 {
|
|
if num <= 0 {
|
|
return
|
|
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 {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
if len(classifyIdList) > 0 {
|
|
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 {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -88,21 +88,23 @@ type SetEdbChartPermissionReq struct {
|
|
// EdbInfoPermission
|
|
// EdbInfoPermission
|
|
// @Description: 指标权限表
|
|
// @Description: 指标权限表
|
|
type EdbInfoPermission struct {
|
|
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
|
|
// EdbClassifyPermission
|
|
// @Description: 指标分类权限表
|
|
// @Description: 指标分类权限表
|
|
type EdbClassifyPermission struct {
|
|
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
|
|
// SetPermissionEdbChartByEdbIdList
|
|
@@ -112,7 +114,7 @@ type EdbClassifyPermission struct {
|
|
// @param edbIdList []string
|
|
// @param edbIdList []string
|
|
// @param userIdList []int
|
|
// @param userIdList []int
|
|
// @return err error
|
|
// @return err error
|
|
-func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err error) {
|
|
|
|
|
|
+func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int, edbInfoType int) (err error) {
|
|
edbNum := len(edbIdList)
|
|
edbNum := len(edbIdList)
|
|
if edbNum <= 0 {
|
|
if edbNum <= 0 {
|
|
return
|
|
return
|
|
@@ -131,8 +133,8 @@ func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err
|
|
|
|
|
|
// 获取已经配置的指标权限用户
|
|
// 获取已经配置的指标权限用户
|
|
edbInfoPermissionList := make([]*EdbInfoPermission, 0)
|
|
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 {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -150,8 +152,8 @@ func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err
|
|
// 标记指标为不纳入权限管控
|
|
// 标记指标为不纳入权限管控
|
|
isJoinPermission = 0
|
|
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 {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -198,12 +200,12 @@ func SetPermissionEdbChartByEdbIdList(edbIdList []string, userIdList []int) (err
|
|
// 待移除的配置项
|
|
// 待移除的配置项
|
|
deletePermissionIdList := make([]int64, 0)
|
|
deletePermissionIdList := make([]int64, 0)
|
|
for _, v := range edbInfoPermissionMap {
|
|
for _, v := range edbInfoPermissionMap {
|
|
- deletePermissionIdList = append(deletePermissionIdList, v.PermissionId)
|
|
|
|
|
|
+ deletePermissionIdList = append(deletePermissionIdList, v.EdbInfoPermissionId)
|
|
}
|
|
}
|
|
|
|
|
|
deletePermissionIdNum := len(deletePermissionIdList)
|
|
deletePermissionIdNum := len(deletePermissionIdList)
|
|
if deletePermissionIdNum > 0 {
|
|
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()
|
|
_, err = o.Raw(sql, deletePermissionIdList).Exec()
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
@@ -230,7 +232,7 @@ type SetEdbChartClassifyPermissionReq struct {
|
|
// @param classifyIdList []int
|
|
// @param classifyIdList []int
|
|
// @param userIdList []int
|
|
// @param userIdList []int
|
|
// @return err error
|
|
// @return err error
|
|
-func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userIdList []int) (err error) {
|
|
|
|
|
|
+func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userIdList []int, classifyType int) (err error) {
|
|
userNum := len(userIdList)
|
|
userNum := len(userIdList)
|
|
if userNum <= 0 {
|
|
if userNum <= 0 {
|
|
return
|
|
return
|
|
@@ -249,8 +251,8 @@ func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userI
|
|
|
|
|
|
// 获取当前选择用户已经配置的指标分类权限
|
|
// 获取当前选择用户已经配置的指标分类权限
|
|
classifyPermissionList := make([]*EdbClassifyPermission, 0)
|
|
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 {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -273,10 +275,11 @@ func SetPermissionEdbChartClassifyIdByClassifyIdList(classifyIdList []int, userI
|
|
// 如果不存在,那么就提那家
|
|
// 如果不存在,那么就提那家
|
|
addList = append(addList, &EdbClassifyPermission{
|
|
addList = append(addList, &EdbClassifyPermission{
|
|
//PermissionId: 0,
|
|
//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)
|
|
deletePermissionIdList := make([]int64, 0)
|
|
for _, v := range classifyPermissionMap {
|
|
for _, v := range classifyPermissionMap {
|
|
- deletePermissionIdList = append(deletePermissionIdList, v.PermissionId)
|
|
|
|
|
|
+ deletePermissionIdList = append(deletePermissionIdList, v.EdbClassifyPermissionId)
|
|
}
|
|
}
|
|
|
|
|
|
deletePermissionIdNum := len(deletePermissionIdList)
|
|
deletePermissionIdNum := len(deletePermissionIdList)
|
|
if deletePermissionIdNum > 0 {
|
|
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()
|
|
_, err = o.Raw(sql, deletePermissionIdList).Exec()
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|