|
@@ -18,7 +18,7 @@ import (
|
|
|
// @param source int
|
|
|
// @param subSource int
|
|
|
// @param userId int
|
|
|
-// @param userList []int
|
|
|
+// @param authUserList []int
|
|
|
// @param isSelectAll bool
|
|
|
// @param dataId []string
|
|
|
// @param noDataId []string
|
|
@@ -27,7 +27,7 @@ import (
|
|
|
// @param opUserId int 操作人
|
|
|
// @return err error
|
|
|
// @return errMsg string
|
|
|
-func SetEdbChartPermission(source, subSource, userId int, userList []int, isSelectAll bool, dataIdList, noDataIdList []string, keyword, classify string, opUserId int) (err error, errMsg string) {
|
|
|
+func SetEdbChartPermission(source, subSource, userId int, authUserList []int, isSelectAll bool, dataIdList, noDataIdList []string, keyword, classify string, opUserId int) (err error, errMsg string) {
|
|
|
// 如果勾选全部数据,那么
|
|
|
if isSelectAll {
|
|
|
// 找出不要的指标ID列表
|
|
@@ -51,7 +51,7 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if len(userList) <= 0 {
|
|
|
+ if len(authUserList) <= 0 {
|
|
|
// 说明是取消权限管控
|
|
|
}
|
|
|
|
|
@@ -60,7 +60,8 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
dataList := make([]data_manage_permission.DataItem, 0)
|
|
|
|
|
|
switch source {
|
|
|
- case 3, 4: //ETA指标库、ETA预测指标
|
|
|
+ case 3, 4:
|
|
|
+ //ETA指标库、ETA预测指标
|
|
|
if source == 3 {
|
|
|
content += `(ETA指标库)`
|
|
|
} else {
|
|
@@ -87,10 +88,11 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
if source == 4 {
|
|
|
edbInfoType = 1
|
|
|
}
|
|
|
- err = data_manage_permission.SetPermissionByEdbIdList(dataIdList, userList, edbInfoType)
|
|
|
+ err = data_manage_permission.SetPermissionByEdbIdList(dataIdList, authUserList, edbInfoType)
|
|
|
}
|
|
|
|
|
|
- case 5: //图库
|
|
|
+ case 5:
|
|
|
+ //图库
|
|
|
content += `(ETA图库)`
|
|
|
tmpList, tmpErr := data_manage.GetChartInfoListByChartIdList(dataIdList)
|
|
|
if tmpErr != nil {
|
|
@@ -110,10 +112,11 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
|
|
|
// 重新设置权限
|
|
|
chartSource := utils.CHART_SOURCE_DEFAULT
|
|
|
- err = data_manage_permission.SetPermissionByChartIdList(dataIdList, userList, chartSource)
|
|
|
+ err = data_manage_permission.SetPermissionByChartIdList(dataIdList, authUserList, chartSource)
|
|
|
}
|
|
|
|
|
|
- case 6: // ETA表格
|
|
|
+ case 6:
|
|
|
+ // ETA表格
|
|
|
content += `(ETA表格)`
|
|
|
tmpList, tmpErr := excel.GetNoContentExcelListByExcelInfoIdList(dataIdList)
|
|
|
if tmpErr != nil {
|
|
@@ -132,7 +135,7 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
}
|
|
|
|
|
|
// 重新设置权限
|
|
|
- err = data_manage_permission.SetPermissionByExcelIdList(dataIdList, userList, subSource)
|
|
|
+ err = data_manage_permission.SetPermissionByExcelIdList(dataIdList, authUserList, subSource)
|
|
|
}
|
|
|
default:
|
|
|
return
|
|
@@ -145,7 +148,7 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
var authRecordErr error
|
|
|
defer func() {
|
|
|
if authRecordErr != nil {
|
|
|
- utils.FileLog.Error(fmt.Sprintf("记录未设置记录资产权限的记录失败:%s;source:%d;sub_source:%d;数据ID列表:%s;授权人列表:%v", authRecordErr.Error(), source, subSource, strings.Join(dataIdList, ","), userList))
|
|
|
+ utils.FileLog.Error(fmt.Sprintf("记录未设置记录资产权限的记录失败:%s;source:%d;sub_source:%d;数据ID列表:%s;授权人列表:%v", authRecordErr.Error(), source, subSource, strings.Join(dataIdList, ","), authUserList))
|
|
|
|
|
|
}
|
|
|
}()
|
|
@@ -160,13 +163,13 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
}
|
|
|
|
|
|
// 如果没有授权人,那么就删除未授权记录
|
|
|
- if len(userList) < 0 {
|
|
|
+ if len(authUserList) < 0 {
|
|
|
authRecordErr = data_manage_permission.DeleteRecordBySourceAndDataIdList(source, subSource, dataIdList)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
userIdMap := make(map[int]int)
|
|
|
- for _, tmpUserId := range userList {
|
|
|
+ for _, tmpUserId := range authUserList {
|
|
|
userIdMap[tmpUserId] = tmpUserId
|
|
|
}
|
|
|
|
|
@@ -177,32 +180,52 @@ func SetEdbChartPermission(source, subSource, userId int, userList []int, isSele
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- authRecordErr = data_manage_permission.AddRecordBySourceAndDataIdList(source, subSource, dataIdList, dataList, noAuthUserIdList, userList, uniqueCode, content, opUserId)
|
|
|
+ content += "已关闭"
|
|
|
+
|
|
|
+ // 添加未授权记录
|
|
|
+ authRecordErr = data_manage_permission.AddRecordBySourceAndDataIdList(source, subSource, dataList, noAuthUserIdList, authUserList, uniqueCode, content, opUserId)
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// SetDataIsPermission
|
|
|
+// SetDataClassifyIsPermission
|
|
|
// @Description: 设置资产(指标、图表、ETA表格)分类是否涉密
|
|
|
// @author: Roc
|
|
|
// @datetime 2024-03-27 10:52:32
|
|
|
// @param source int
|
|
|
// @param subSource int
|
|
|
// @param dataId []string
|
|
|
+// @param opUserId int 操作人id
|
|
|
// @return err error
|
|
|
// @return errMsg string
|
|
|
-func SetDataIsPermission(source, subSource int, classifyIdList []int) (err error, errMsg string) {
|
|
|
- // TODO 消息通知
|
|
|
+func SetDataClassifyIsPermission(source, subSource int, classifyIdList []int, opUserId int) (err error, errMsg string) {
|
|
|
+ uniqueCode := uuid.NewUUID().Hex32()
|
|
|
+ content := `分类权限`
|
|
|
+ classifyDataList := make([]data_manage_permission.ClassifyDataItem, 0)
|
|
|
|
|
|
switch source {
|
|
|
- case 3, 4: //ETA指标库、ETA预测指标
|
|
|
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
|
|
|
- //if tmpErr != nil {
|
|
|
- // err = tmpErr
|
|
|
- // return
|
|
|
- //}
|
|
|
- //if len(tmpList) > 0 {
|
|
|
- //}
|
|
|
+ case 3, 4:
|
|
|
+ //ETA指标库、ETA预测指标
|
|
|
+ if source == 3 {
|
|
|
+ content += `(ETA指标库)`
|
|
|
+ } else {
|
|
|
+ content += `(ETA预测指标)`
|
|
|
+ }
|
|
|
+ {
|
|
|
+ // 分类信息
|
|
|
+ classifyInfoList, tmpErr := data_manage.GetEdbClassifyByIdList(classifyIdList)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range classifyInfoList {
|
|
|
+ classifyDataList = append(classifyDataList, data_manage_permission.ClassifyDataItem{
|
|
|
+ ClassifyId: v.ClassifyId,
|
|
|
+ ClassifyName: v.ClassifyName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 重新设置权限
|
|
|
classifyType := 0
|
|
|
if source == 4 {
|
|
@@ -210,19 +233,85 @@ func SetDataIsPermission(source, subSource int, classifyIdList []int) (err error
|
|
|
}
|
|
|
err = data_manage_permission.SetIsPermissionEdbChartByEdbClassifyIdList(classifyIdList, classifyType)
|
|
|
|
|
|
- case 5: //图库
|
|
|
+ case 5:
|
|
|
+ //图库
|
|
|
+ content += `(ETA图库)`
|
|
|
+ {
|
|
|
+ // 分类信息
|
|
|
+ classifyInfoList, tmpErr := data_manage.GetChartClassifyByIdList(classifyIdList)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range classifyInfoList {
|
|
|
+ classifyDataList = append(classifyDataList, data_manage_permission.ClassifyDataItem{
|
|
|
+ ClassifyId: v.ChartClassifyId,
|
|
|
+ ClassifyName: v.ChartClassifyName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 重新设置权限
|
|
|
chartClassifySource := utils.CHART_SOURCE_DEFAULT
|
|
|
err = data_manage_permission.SetIsPermissionByChartClassifyIdList(classifyIdList, chartClassifySource)
|
|
|
|
|
|
case 6:
|
|
|
// ETA表格
|
|
|
+ content += `(ETA表格)`
|
|
|
+ {
|
|
|
+ // 分类信息
|
|
|
+ classifyInfoList, tmpErr := excel.GetExcelClassifyByIdList(classifyIdList)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range classifyInfoList {
|
|
|
+ classifyDataList = append(classifyDataList, data_manage_permission.ClassifyDataItem{
|
|
|
+ ClassifyId: v.ExcelClassifyId,
|
|
|
+ ClassifyName: v.ExcelClassifyName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
// 重新设置权限
|
|
|
err = data_manage_permission.SetIsPermissionByExcelClassifyIdList(classifyIdList, subSource)
|
|
|
|
|
|
default:
|
|
|
return
|
|
|
}
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var authRecordErr error
|
|
|
+ defer func() {
|
|
|
+ if authRecordErr != nil {
|
|
|
+ utils.FileLog.Error(fmt.Sprintf("记录未设置记录资产权限的记录失败:%s;source:%d;sub_source:%d;分类ID列表:%v", authRecordErr.Error(), source, subSource, classifyIdList))
|
|
|
+
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ // 如果没有涉密的分类,那么就移除所有删除未授权记录
|
|
|
+ if len(classifyIdList) <= 0 {
|
|
|
+ authRecordErr = data_manage_permission.DeleteClassifyNoAuthRecordBySourceAndClassifyIdList(source, subSource)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取所有在用的用户
|
|
|
+ cond := ` AND enabled = 1`
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+
|
|
|
+ adminList, authRecordErr := system.GetSysAdminList(cond, pars, []string{}, "")
|
|
|
+ if authRecordErr != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ noAuthUserIdList := make([]int, 0)
|
|
|
+ for _, v := range adminList {
|
|
|
+ noAuthUserIdList = append(noAuthUserIdList, v.AdminId)
|
|
|
+ }
|
|
|
+
|
|
|
+ content += "已关闭"
|
|
|
+ // 添加未授权记录
|
|
|
+ authRecordErr = data_manage_permission.AddClassifyNoAuthRecordBySourceAndClassifyIdList(source, subSource, classifyDataList, noAuthUserIdList, uniqueCode, content, opUserId)
|
|
|
|
|
|
return
|
|
|
}
|
|
@@ -233,51 +322,126 @@ func SetDataIsPermission(source, subSource int, classifyIdList []int) (err error
|
|
|
// @datetime 2024-03-28 14:22:30
|
|
|
// @param source int
|
|
|
// @param subSource int
|
|
|
-// @param userList []int
|
|
|
+// @param authUserList []int
|
|
|
// @param classifyIdList []int
|
|
|
+// @param opUserId int 操作人id
|
|
|
// @return err error
|
|
|
// @return errMsg string
|
|
|
-func SetEdbChartClassifyPermission(source, subSource int, userList []int, classifyIdList []int) (err error, errMsg string) {
|
|
|
- // TODO 消息通知
|
|
|
+func SetEdbChartClassifyPermission(source, subSource int, authUserList []int, classifyIdList []int, opUserId int) (err error, errMsg string) {
|
|
|
+ uniqueCode := uuid.NewUUID().Hex32()
|
|
|
+ content := `分类权限`
|
|
|
+ secretClassifyInfoList := make([]data_manage_permission.ClassifyDataItem, 0)
|
|
|
|
|
|
if len(classifyIdList) <= 0 {
|
|
|
// 说明是取消权限管控
|
|
|
}
|
|
|
|
|
|
+ // 先获取所有的涉密分类,然后根据用户去判断那些分类给权限了
|
|
|
+
|
|
|
switch source {
|
|
|
case 3, 4: //ETA指标库、ETA预测指标
|
|
|
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
|
|
|
- //if tmpErr != nil {
|
|
|
- // err = tmpErr
|
|
|
- // return
|
|
|
- //}
|
|
|
- //if len(tmpList) > 0 {
|
|
|
- //}
|
|
|
- // 重新设置权限
|
|
|
+
|
|
|
+ //ETA指标库、ETA预测指标
|
|
|
+ if source == 3 {
|
|
|
+ content += `(ETA指标库)`
|
|
|
+ } else {
|
|
|
+ content += `(ETA预测指标)`
|
|
|
+ }
|
|
|
+
|
|
|
classifyType := 0
|
|
|
if source == 4 {
|
|
|
classifyType = 1
|
|
|
}
|
|
|
- err = data_manage_permission.SetPermissionByEdbClassifyIdList(classifyIdList, userList, classifyType)
|
|
|
- case 5: //图库
|
|
|
|
|
|
- //tmpList, tmpErr := data_manage.GetEdbInfoListGroupByUserId(dataId)
|
|
|
- //if tmpErr != nil {
|
|
|
- // err = tmpErr
|
|
|
- // return
|
|
|
- //}
|
|
|
- //if len(tmpList) > 0 {
|
|
|
- //}
|
|
|
+ {
|
|
|
+ // 获取已经设置加密的分类信息
|
|
|
+ classifyInfoList, tmpErr := data_manage.GetEdbClassifyByClassifyTypeAndIsJoinPermission(classifyType, 1)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range classifyInfoList {
|
|
|
+ secretClassifyInfoList = append(secretClassifyInfoList, data_manage_permission.ClassifyDataItem{
|
|
|
+ ClassifyId: v.ClassifyId,
|
|
|
+ ClassifyName: v.ClassifyName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
// 重新设置权限
|
|
|
- chartClassifySource := utils.CHART_SOURCE_DEFAULT
|
|
|
- err = data_manage_permission.SetPermissionByChartClassifyIdList(classifyIdList, userList, chartClassifySource)
|
|
|
+ err = data_manage_permission.SetPermissionByEdbClassifyIdList(classifyIdList, authUserList, classifyType)
|
|
|
+ case 5:
|
|
|
+ subSource = utils.CHART_SOURCE_DEFAULT
|
|
|
+ //图库
|
|
|
+ content += `(ETA图库)`
|
|
|
+ {
|
|
|
+ // 分类信息
|
|
|
+ classifyInfoList, tmpErr := data_manage.GetChartClassifyBySourceAndIsJoinPermission(subSource, 1)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range classifyInfoList {
|
|
|
+ secretClassifyInfoList = append(secretClassifyInfoList, data_manage_permission.ClassifyDataItem{
|
|
|
+ ClassifyId: v.ChartClassifyId,
|
|
|
+ ClassifyName: v.ChartClassifyName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重新设置权限
|
|
|
+ err = data_manage_permission.SetPermissionByChartClassifyIdList(classifyIdList, authUserList, subSource)
|
|
|
case 6:
|
|
|
// ETA表格
|
|
|
- err = data_manage_permission.SetPermissionByExcelClassifyIdList(classifyIdList, userList, subSource)
|
|
|
+ content += `(ETA表格)`
|
|
|
+ {
|
|
|
+ // 分类信息
|
|
|
+ classifyInfoList, tmpErr := excel.GetExcelClassifyBySourceAndIsJoinPermission(subSource, 1)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range classifyInfoList {
|
|
|
+ secretClassifyInfoList = append(secretClassifyInfoList, data_manage_permission.ClassifyDataItem{
|
|
|
+ ClassifyId: v.ExcelClassifyId,
|
|
|
+ ClassifyName: v.ExcelClassifyName,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ err = data_manage_permission.SetPermissionByExcelClassifyIdList(classifyIdList, authUserList, subSource)
|
|
|
default:
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var authRecordErr error
|
|
|
+ defer func() {
|
|
|
+ if authRecordErr != nil {
|
|
|
+ utils.FileLog.Error(fmt.Sprintf("记录未设置记录资产权限的记录失败:%s;source:%d;sub_source:%d;分类ID列表:%v", authRecordErr.Error(), source, subSource, classifyIdList))
|
|
|
+
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ content += "已关闭"
|
|
|
+
|
|
|
+ authClassifyIdMap := make(map[int]int)
|
|
|
+ for _, v := range classifyIdList {
|
|
|
+ authClassifyIdMap[v] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ noAuthClassifyMap := make(map[int]data_manage_permission.ClassifyDataItem)
|
|
|
+ for _, classifyInfo := range secretClassifyInfoList {
|
|
|
+ if _, ok := authClassifyIdMap[classifyInfo.ClassifyId]; !ok {
|
|
|
+ noAuthClassifyMap[classifyInfo.ClassifyId] = classifyInfo
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加未授权记录
|
|
|
+ authRecordErr = data_manage_permission.AddClassifyNoAuthRecordBySourceAndUserIdList(source, subSource, noAuthClassifyMap, authUserList, uniqueCode, content, opUserId)
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|