|
@@ -1914,11 +1914,35 @@ func GetMoveEdbChartList(source, userId int, keyword, classify string, startSize
|
|
|
|
|
|
// MoveEdbChart 转移指标/图表创建人
|
|
|
// @param source 来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库
|
|
|
-func MoveEdbChart(source, userId int, dataId []string) (err error, errMsg string) {
|
|
|
- adminInfo, err := system.GetSysAdminById(userId)
|
|
|
+func MoveEdbChart(source, oldUserId, newUserId int, isSelectAll bool, dataId []string, keyword, classify string) (err error, errMsg string) {
|
|
|
+ adminInfo, err := system.GetSysAdminById(newUserId)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ // 如果勾选全部数据,那么
|
|
|
+ if isSelectAll {
|
|
|
+ // 找出不要的指标ID列表
|
|
|
+ dataIdMap := make(map[string]string, 0)
|
|
|
+ for _, v := range dataId {
|
|
|
+ dataIdMap[v] = v
|
|
|
+ }
|
|
|
+
|
|
|
+ // 需要转义的指标/图表ID列表
|
|
|
+ dataId = make([]string, 0)
|
|
|
+ // 获取所有指标/图表
|
|
|
+ list, _, tmpErr := GetMoveEdbChartList(source, oldUserId, keyword, classify, 0, 100000)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range list {
|
|
|
+ if _, ok := dataIdMap[v.DataId]; !ok {
|
|
|
+ dataId = append(dataId, v.DataId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
switch source {
|
|
|
case 1: //手工数据指标
|
|
|
tmpList, tmpErr := models.GetEdbinfoListByCodeListGroupByUserId(dataId)
|
|
@@ -1929,14 +1953,14 @@ func MoveEdbChart(source, userId int, dataId []string) (err error, errMsg string
|
|
|
|
|
|
if len(tmpList) > 0 {
|
|
|
for _, v := range tmpList {
|
|
|
- if v.UserId == userId {
|
|
|
+ if v.UserId == newUserId {
|
|
|
errMsg = "新创建人不可和原创建人一致"
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
// 修改创建人
|
|
|
- err = models.ModifyEdbinfoUserIdByCodeList(dataId, userId)
|
|
|
+ err = models.ModifyEdbinfoUserIdByCodeList(dataId, newUserId)
|
|
|
}
|
|
|
|
|
|
case 2: //钢联化工数据库
|
|
@@ -1947,7 +1971,7 @@ func MoveEdbChart(source, userId int, dataId []string) (err error, errMsg string
|
|
|
}
|
|
|
if len(tmpList) > 0 {
|
|
|
for _, v := range tmpList {
|
|
|
- if v.SysUserId == userId {
|
|
|
+ if v.SysUserId == newUserId {
|
|
|
errMsg = "新创建人不可和原创建人一致"
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
@@ -1964,7 +1988,7 @@ func MoveEdbChart(source, userId int, dataId []string) (err error, errMsg string
|
|
|
}
|
|
|
if len(tmpList) > 0 {
|
|
|
for _, v := range tmpList {
|
|
|
- if v.SysUserId == userId {
|
|
|
+ if v.SysUserId == newUserId {
|
|
|
errMsg = "新创建人不可和原创建人一致"
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
@@ -1990,7 +2014,7 @@ func MoveEdbChart(source, userId int, dataId []string) (err error, errMsg string
|
|
|
}
|
|
|
if len(tmpList) > 0 {
|
|
|
for _, v := range tmpList {
|
|
|
- if v.SysUserId == userId {
|
|
|
+ if v.SysUserId == newUserId {
|
|
|
errMsg = "新创建人不可和原创建人一致"
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
@@ -3257,3 +3281,51 @@ func EdbInfoSmmApiAdd(item *data_manage.EdbInfo) (edbInfo *data_manage.EdbInfo,
|
|
|
AddOrEditEdbInfoToEs(int(edbInfoId))
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// MoveAllEdbChart 通过原创建人转移指标/图表创建人
|
|
|
+// @param source 来源 :1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库
|
|
|
+func MoveAllEdbChart(source, oldUserId, userId int) (err error, errMsg string) {
|
|
|
+ adminInfo, err := system.GetSysAdminById(userId)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ switch source {
|
|
|
+ case 1: //手工数据指标
|
|
|
+ // 修改创建人
|
|
|
+ err = models.ModifyEdbinfoUserIdByOldUserId(oldUserId, userId)
|
|
|
+
|
|
|
+ case 2: //钢联化工数据库
|
|
|
+ // 修改创建人
|
|
|
+ err = data_manage.ModifyMysteelChemicalIndexUserIdByOldUserId(oldUserId, adminInfo.AdminId, adminInfo.RealName)
|
|
|
+ case 3: //ETA指标库
|
|
|
+ // 修改创建人
|
|
|
+ err = data_manage.ModifyEdbInfoUserIdByOldUserId(oldUserId, 0, adminInfo.AdminId, adminInfo.RealName)
|
|
|
+ // 移除当前用户的不可操作权限
|
|
|
+ //{
|
|
|
+ // obj := data_manage.EdbInfoNoPermissionAdmin{}
|
|
|
+ // for _, v := range dataId {
|
|
|
+ // edbInfoId, _ := strconv.Atoi(v)
|
|
|
+ // go obj.DeleteByEdbInfoIdAndAdminId(edbInfoId, adminInfo.AdminId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ case 4: //ETA预测指标
|
|
|
+ // 修改创建人
|
|
|
+ err = data_manage.ModifyEdbInfoUserIdByOldUserId(oldUserId, 1, adminInfo.AdminId, adminInfo.RealName)
|
|
|
+ // 移除当前用户的不可操作权限
|
|
|
+ //{
|
|
|
+ // obj := data_manage.EdbInfoNoPermissionAdmin{}
|
|
|
+ // for _, v := range dataId {
|
|
|
+ // edbInfoId, _ := strconv.Atoi(v)
|
|
|
+ // go obj.DeleteByEdbInfoIdAndAdminId(edbInfoId, adminInfo.AdminId)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ case 5: //图库
|
|
|
+ // 修改创建人
|
|
|
+ err = data_manage.ModifyChartInfoUserIdByOldUserId(oldUserId, adminInfo.AdminId, adminInfo.RealName)
|
|
|
+ default:
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|