Browse Source

Merge branch 'feature/eta1.8.5_excel_balance' into debug

xyxie 10 months ago
parent
commit
18bf6097c7

+ 83 - 13
controllers/data_manage/excel/balance_table.go

@@ -128,18 +128,37 @@ func (c *ExcelInfoController) Rename() {
 		return
 	}
 
-	// todo 操作权限校验, 增加协作人判断
+	// 操作权限校验, 增加协作人判断
 	{
+		checkExcelInfo := excelInfo
+		if excelInfo.Source == utils.BALANCE_TABLE {
+			checkExcelInfoId := excelInfo.ExcelInfoId
+			if excelInfo.BalanceType == 1 {
+				checkExcelInfoId = excelInfo.RelExcelInfoId
+			} else {
+				if excelInfo.ParentId > 0 {
+					checkExcelInfoId = excelInfo.ParentId
+				}
+			}
+			if checkExcelInfoId != excelInfo.ExcelInfoId {
+				checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
+				if err != nil {
+					br.Msg = "获取平衡表格信息失败"
+					br.ErrMsg = "获取平衡表格信息失败,Err:" + err.Error()
+					return
+				}
+			}
+		}
 		// 数据权限
-		haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(excelInfo.ExcelInfoId, excelInfo.ExcelClassifyId, excelInfo.IsJoinPermission, c.SysUser.AdminId)
-		if err != nil {
-			br.Msg = "获取ETA表格失败"
-			br.ErrMsg = "获取ETA表格权限失败,Err:" + err.Error()
+		haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
+		if e != nil {
+			br.Msg = "获取ETA表格权限失败"
+			br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
 			return
 		}
-		button := excelService.GetExcelInfoOpButton(sysUser, excelInfo.SysUserId, excelInfo.Source, haveOperaAuth)
+
+		button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
 		if !button.OpButton {
-			br.Msg = "无操作权限"
 			br.Msg = "无操作权限"
 			br.IsSendEmail = false
 			return
@@ -219,7 +238,7 @@ func (c *ExcelInfoController) SaveExcelWorker() {
 		br.ErrMsg = "您没有权限操作!"
 		return
 	}
-	// todo 操作权限校验, 增加协作人判断
+	// 操作权限校验, 增加协作人判断
 	{
 		// 数据权限
 		haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(excelInfo.ExcelInfoId, excelInfo.ExcelClassifyId, excelInfo.IsJoinPermission, c.SysUser.AdminId)
@@ -230,7 +249,6 @@ func (c *ExcelInfoController) SaveExcelWorker() {
 		}
 		button := excelService.GetExcelInfoOpButton(sysUser, excelInfo.SysUserId, excelInfo.Source, haveOperaAuth)
 		if !button.OpButton {
-			br.Msg = "无操作权限"
 			br.Msg = "无操作权限"
 			br.IsSendEmail = false
 			return
@@ -320,8 +338,8 @@ func (c *ExcelInfoController) GetWorker() {
 		br.ErrMsg = "获取表格协作人失败,Err:" + err.Error()
 		return
 	}
-	data := &response.BalanceTableWorkerResp{List: list}
-	br.Data = data
+	ret := &response.BalanceTableWorkerResp{List: list}
+	br.Data = ret
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
@@ -656,7 +674,7 @@ func (c *ExcelInfoController) DeleteBalanceChart() {
 			return
 		}
 
-		// todo 查询权限
+		// todo 查询图表权限
 		/*chartClassifyItem, err := data_manage.GetChartClassifyById(chartInfo.ChartClassifyId)
 		if err != nil {
 			br.Msg = "获取失败"
@@ -795,7 +813,6 @@ func (c *ExcelInfoController) BalanceSeasonChartLegendPreview() {
 	dataList := make([]*data_manage.EdbDataList, 0)
 
 	for i, v := range req.DateArr {
-		// todo 处理DataTimestamp
 		dataTime, e := time.ParseInLocation(utils.FormatDate, v, time.Local)
 		if e != nil {
 			br.Msg = "日期格式错误"
@@ -885,6 +902,22 @@ func (c *ExcelInfoController) AddStaticExcel() {
 		br.Msg = "获取ETA表格失败"
 		return
 	}
+	// 操作权限校验, 增加协作人判断
+	{
+		// 数据权限
+		haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(oldExcelInfo.ExcelInfoId, oldExcelInfo.ExcelClassifyId, oldExcelInfo.IsJoinPermission, c.SysUser.AdminId)
+		if err != nil {
+			br.Msg = "获取ETA表格失败"
+			br.ErrMsg = "获取ETA表格权限失败,Err:" + err.Error()
+			return
+		}
+		button := excelService.GetExcelInfoOpButton(sysUser, oldExcelInfo.SysUserId, oldExcelInfo.Source, haveOperaAuth)
+		if !button.OpButton {
+			br.Msg = "无操作权限"
+			br.IsSendEmail = false
+			return
+		}
+	}
 	// 查询出每个子表的内容,并将内容转为静态版本
 	//查询动态表所有的子表,并复制为静态表
 	condition := " AND parent_id = ? AND balance_type = 0 "
@@ -1059,6 +1092,43 @@ func (c *ExcelInfoController) ModifyBalanceExcelVersion() {
 		br.Msg = "请选择静态表"
 		return
 	}
+
+	// 操作权限校验, 增加协作人判断
+	{
+		checkExcelInfo := excelInfo
+		if excelInfo.Source == utils.BALANCE_TABLE {
+			checkExcelInfoId := excelInfo.ExcelInfoId
+			if excelInfo.BalanceType == 1 {
+				checkExcelInfoId = excelInfo.RelExcelInfoId
+			} else {
+				if excelInfo.ParentId > 0 {
+					checkExcelInfoId = excelInfo.ParentId
+				}
+			}
+			if checkExcelInfoId != excelInfo.ExcelInfoId {
+				checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
+				if err != nil {
+					br.Msg = "获取平衡表格信息失败"
+					br.ErrMsg = "获取平衡表格信息失败,Err:" + err.Error()
+					return
+				}
+			}
+		}
+		// 数据权限
+		haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
+		if e != nil {
+			br.Msg = "获取ETA表格权限失败"
+			br.ErrMsg = "获取表格权限信息失败,Err" + e.Error()
+			return
+		}
+
+		button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
+		if !button.OpButton {
+			br.Msg = "无操作权限"
+			br.IsSendEmail = false
+			return
+		}
+	}
 	// 检验分类下是否存在该版本号
 	{
 		var condition string

+ 31 - 6
controllers/data_manage/excel/excel_info.go

@@ -496,7 +496,7 @@ func (c *ExcelInfoController) List() {
 				}
 
 				// excel表格按钮权限
-				list[k].Button = excel2.GetBalanceExcelInfoOpButton(sysUser.AdminId, v.SysUserId, v.HaveOperaAuth, v.ExcelInfoId, v.SysUserId)
+				list[k].Button = excel2.GetBalanceExcelInfoOpButton(sysUser.AdminId, v.SysUserId, v.HaveOperaAuth, v.ExcelInfoId)
 			}
 		}
 
@@ -655,8 +655,29 @@ func (c *ExcelInfoController) Edit() {
 		return
 	}
 
-	// todo 标记编辑状态
-	markRet, err := services.UpdateExcelEditMark(req.ExcelInfoId, sysUser.AdminId, 1, sysUser.RealName)
+	checkExcelInfoId := excelInfo.ExcelInfoId
+	checkExcelInfo := excelInfo
+	if excelInfo.Source == utils.BALANCE_TABLE {
+		checkExcelInfoId = excelInfo.ExcelInfoId
+		if excelInfo.BalanceType == 1 {
+			checkExcelInfoId = excelInfo.RelExcelInfoId
+		} else {
+			if excelInfo.ParentId > 0 {
+				checkExcelInfoId = excelInfo.ParentId
+			}
+		}
+		if checkExcelInfoId != excelInfo.ExcelInfoId {
+			checkExcelInfo, err = excel3.GetExcelInfoById(checkExcelInfoId)
+			if err != nil {
+				br.Msg = "获取平衡表格信息失败"
+				br.ErrMsg = "获取平衡表格信息失败,Err:" + err.Error()
+				return
+			}
+		}
+	}
+
+	// 标记编辑状态
+	markRet, err := services.UpdateExcelEditMark(checkExcelInfoId, sysUser.AdminId, 1, sysUser.RealName)
 	if err != nil {
 		br.Msg = "查询标记状态失败"
 		br.ErrMsg = "查询标记状态失败,Err:" + err.Error()
@@ -729,15 +750,19 @@ func (c *ExcelInfoController) Edit() {
 	// 操作权限校验
 	{
 		// 数据权限
-		haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(excelInfo.ExcelInfoId, excelInfo.ExcelClassifyId, excelInfo.IsJoinPermission, c.SysUser.AdminId)
+		haveOperaAuth, err := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, c.SysUser.AdminId)
 		if err != nil {
 			br.Msg = "获取ETA表格失败"
 			br.ErrMsg = "获取ETA表格权限失败,Err:" + err.Error()
 			return
 		}
-		button := excel2.GetExcelInfoOpButton(sysUser, excelInfo.SysUserId, excelInfo.Source, haveOperaAuth)
+		var button excel3.ExcelInfoDetailButton
+		if checkExcelInfo.Source == utils.BALANCE_TABLE {
+			button = excel2.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
+		} else {
+			button = excel2.GetExcelInfoOpButton(sysUser, excelInfo.SysUserId, excelInfo.Source, haveOperaAuth)
+		}
 		if !button.OpButton {
-			br.Msg = "无操作权限"
 			br.Msg = "无操作权限"
 			br.IsSendEmail = false
 			return

+ 73 - 22
services/data/chart_info_excel_balance.go

@@ -9,6 +9,7 @@ import (
 	"eta/eta_api/models/data_manage/excel/request"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services/data/data_manage_permission"
+	excelService "eta/eta_api/services/data/excel"
 	"eta/eta_api/utils"
 	"fmt"
 	"math"
@@ -32,6 +33,42 @@ func AddBalanceExcelChart(req request.AddBalanceTableChartReq, sysUser *system.A
 		err = fmt.Errorf("EXCEL类型错误!")
 		return
 	}
+
+	// 操作权限校验, 增加协作人判断
+	{
+		checkExcelInfo := excelInfo
+		checkExcelInfoId := excelInfo.ExcelInfoId
+		if excelInfo.BalanceType == 1 {
+			checkExcelInfoId = excelInfo.RelExcelInfoId
+		} else {
+			if excelInfo.ParentId > 0 {
+				checkExcelInfoId = excelInfo.ParentId
+			}
+		}
+		if checkExcelInfoId != excelInfo.ExcelInfoId {
+			checkExcelInfo, err = excelModel.GetExcelInfoById(checkExcelInfoId)
+			if err != nil {
+				errMsg = "获取平衡表格信息失败"
+				err = fmt.Errorf("获取平衡表格信息失败,Err:" + err.Error())
+				return
+			}
+		}
+		// 数据权限
+		haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, sysUser.AdminId)
+		if e != nil {
+			errMsg = "获取ETA表格权限失败"
+			err = fmt.Errorf("获取表格权限信息失败,Err" + e.Error())
+			return
+		}
+
+		button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
+		if !button.OpButton {
+			errMsg = "无操作权限"
+			isSendEmail = false
+			return
+		}
+	}
+
 	if len(req.ChartEdbInfoList) == 0 {
 		errMsg = "图表数据不能为空!"
 		err = fmt.Errorf("图表数据不能为空!%s", err.Error())
@@ -106,7 +143,7 @@ func addBalanceExcelChart(req request.AddBalanceTableChartReq, sysUserId int, sy
 	}
 	chartType := req.ChartType
 	extraConfig := req.ExtraConfig
-	// todo 查找默认主题设置
+	// 查找默认主题设置
 	// 查找主题类型id
 	chartThemeType, err := chart_theme.GetChartThemeTypeByChartType(chartType)
 	if err != nil {
@@ -262,6 +299,40 @@ func EditBalanceExcelChart(req request.AddBalanceTableChartReq, sysUser *system.
 		err = fmt.Errorf("图表数据不能为空!%s", err.Error())
 		return
 	}
+	// 操作权限校验, 增加协作人判断
+	{
+		checkExcelInfo := excelInfo
+		checkExcelInfoId := excelInfo.ExcelInfoId
+		if excelInfo.BalanceType == 1 {
+			checkExcelInfoId = excelInfo.RelExcelInfoId
+		} else {
+			if excelInfo.ParentId > 0 {
+				checkExcelInfoId = excelInfo.ParentId
+			}
+		}
+		if checkExcelInfoId != excelInfo.ExcelInfoId {
+			checkExcelInfo, err = excelModel.GetExcelInfoById(checkExcelInfoId)
+			if err != nil {
+				errMsg = "获取平衡表格信息失败"
+				err = fmt.Errorf("获取平衡表格信息失败,Err:" + err.Error())
+				return
+			}
+		}
+		// 数据权限
+		haveOperaAuth, e := data_manage_permission.CheckExcelPermissionByExcelInfoId(checkExcelInfo.ExcelInfoId, checkExcelInfo.ExcelClassifyId, checkExcelInfo.IsJoinPermission, sysUser.AdminId)
+		if e != nil {
+			errMsg = "获取ETA表格权限失败"
+			err = fmt.Errorf("获取表格权限信息失败,Err" + e.Error())
+			return
+		}
+
+		button := excelService.GetBalanceExcelInfoOpButton(sysUser.AdminId, checkExcelInfo.SysUserId, haveOperaAuth, checkExcelInfo.ExcelInfoId)
+		if !button.OpButton {
+			errMsg = "无操作权限"
+			isSendEmail = false
+			return
+		}
+	}
 
 	//查询已有的mapping
 	mapping, err := excelModel.GetExcelChartEdbMappingByChartInfoId(req.ChartInfoId)
@@ -511,7 +582,6 @@ func editBalanceExcelChart(req request.AddBalanceTableChartReq) (chartInfo *data
 }
 
 func GetBalanceExcelChartDetail(chartInfo *data_manage.ChartInfoView, mappingListTmp []*excelModel.ExcelChartEdb, sysUser *system.Admin, dataListMap map[int][]*data_manage.EdbDataList) (resp *data_manage.ChartInfoDetailResp, err error, errMsg string) {
-	// todo 图表权限处理
 	// 图表数据权限
 	{
 		// 已授权分类id
@@ -1028,7 +1098,7 @@ func CheckBalanceChartCacheAndPermission(chartInfo *data_manage.ChartInfoView, i
 						}
 					}
 					if checkExcelInfoId != excelInfo.ExcelInfoId {
-						checkExcelInfo, err = excelModel.GetExcelInfoById(excelInfo.ExcelInfoId)
+						checkExcelInfo, err = excelModel.GetExcelInfoById(checkExcelInfoId)
 						if err != nil {
 							errMsg = "获取平衡表格信息失败"
 							err = errors.New("获取平衡表格信息失败,Err:" + err.Error())
@@ -1196,25 +1266,6 @@ func AddBalanceStaticExcel(oldExcelInfo *excelModel.ExcelInfo, versionName strin
 	isSendEmail = true
 
 	versionName = utils.TrimLRStr(versionName)
-	// todo 操作权限校验
-	{
-		// 数据权限
-		/*haveOperaAuth, tmpErr := data_manage_permission.CheckExcelPermissionByExcelInfoId(oldExcelInfo.ExcelInfoId, oldExcelInfo.ExcelClassifyId, oldExcelInfo.IsJoinPermission, sysUser.AdminId)
-		if err != nil {
-			errMsg = "获取ETA表格权限失败"
-			err = errors.New("获取ETA表格权限失败,Err:" + tmpErr.Error())
-			return
-		}
-
-		button := GetExcelInfoOpButton(sysUser, oldExcelInfo.SysUserId, oldExcelInfo.Source, haveOperaAuth)
-		if !button.CopyButton {
-			errMsg = "无操作权限"
-			err = errors.New(errMsg)
-			isSendEmail = false
-			return
-		}*/
-	}
-
 	// 检验分类下是否存在该表格名称
 	{
 		var condition string

+ 4 - 5
services/data/excel/excel_info.go

@@ -62,7 +62,7 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 			}
 		}
 		if checkExcelInfoId != excelInfo.ExcelInfoId {
-			checkExcelInfo, err = excel.GetExcelInfoById(excelInfo.ExcelInfoId)
+			checkExcelInfo, err = excel.GetExcelInfoById(checkExcelInfoId)
 			if err != nil {
 				errMsg = "获取平衡表格信息失败"
 				err = errors.New("获取平衡表格信息失败,Err:" + err.Error())
@@ -174,7 +174,7 @@ func formatExcelInfo2Detail(excelInfo *excel.ExcelInfo, sysUserId int, lang stri
 		excelDetail.TableData = result
 	}
 	if excelDetail.Source == utils.BALANCE_TABLE {
-		excelDetail.Button = GetBalanceExcelInfoOpButton(sysUserId, excelDetail.SysUserId, excelDetail.HaveOperaAuth, checkExcelInfo.ExcelInfoId, checkExcelInfo.SysUserId)
+		excelDetail.Button = GetBalanceExcelInfoOpButton(sysUserId, checkExcelInfo.SysUserId, excelDetail.HaveOperaAuth, checkExcelInfo.ExcelInfoId)
 	}
 	return
 }
@@ -210,7 +210,7 @@ func GetExcelInfoOpButton(sysUser *system.Admin, belongUserId, source int, haveO
 }
 
 // GetBalanceExcelInfoOpButton 获取ETA平衡表格的操作权限
-func GetBalanceExcelInfoOpButton(sysUserId, belongUserId int, haveOperaAuth bool, parentExcelInfoId, parentSysUserId int) (button excel.ExcelInfoDetailButton) {
+func GetBalanceExcelInfoOpButton(sysUserId, parentSysUserId int, haveOperaAuth bool, parentExcelInfoId int) (button excel.ExcelInfoDetailButton) {
 	// 如果没有数据权限,那么直接返回
 	if !haveOperaAuth {
 		return
@@ -220,8 +220,7 @@ func GetBalanceExcelInfoOpButton(sysUserId, belongUserId int, haveOperaAuth bool
 	button.CopyButton = true
 	button.DownloadButton = true
 
-	belongUserId = parentSysUserId
-	if sysUserId == belongUserId {
+	if sysUserId == parentSysUserId {
 		button.OpButton = true
 		button.RefreshEdbButton = true
 		button.OpWorkerButton = true

+ 1 - 1
services/data/excel/excel_op.go

@@ -54,7 +54,7 @@ func Delete(excelInfo *excelModel.ExcelInfo, sysUser *system.Admin) (err error,
 			return
 		}
 	} else if excelInfo.Source == utils.BALANCE_TABLE {
-		// todo 如果父级删除是否删除子表和静态表,同时删除图表和图表数据
+		// 如果父级删除是否删除子表和静态表,同时删除图表和图表数据
 		excelIds := make([]int, 0)
 		//查询动态表所有的子表,并复制为静态表
 		condition := " AND source=?"