|
@@ -173,11 +173,11 @@ func (this *ReportController) ListReport() {
|
|
|
if listLen > 0 {
|
|
|
pvMap := make(map[int]int)
|
|
|
uvMap := make(map[int]int)
|
|
|
- reportIdArr := make([]string, 0)
|
|
|
+ reportIdArr := make([]int, 0)
|
|
|
syncReportIdArr := make([]string, 0) // 同步过来的报告IDs
|
|
|
oldAndNewReportIdMap := make(map[int]int) // 旧报告和新报告的id对应关系
|
|
|
for i := 0; i < listLen; i++ {
|
|
|
- reportIdArr = append(reportIdArr, strconv.Itoa(list[i].Id))
|
|
|
+ reportIdArr = append(reportIdArr, list[i].Id)
|
|
|
if list[i].OldReportId > 0 && list[i].ReportLayout == 1 {
|
|
|
syncReportIdArr = append(syncReportIdArr, strconv.Itoa(list[i].OldReportId))
|
|
|
oldAndNewReportIdMap[list[i].OldReportId] = list[i].Id
|
|
@@ -249,6 +249,50 @@ func (this *ReportController) ListReport() {
|
|
|
list[i].Pv = pvMap[list[i].Id]
|
|
|
list[i].Uv = uvMap[list[i].Id]
|
|
|
}
|
|
|
+
|
|
|
+ // 多人协作的协作报告,需要判断是否可编辑
|
|
|
+ {
|
|
|
+ grantObj := report.ReportGrant{}
|
|
|
+ grantList, err := grantObj.GetGrantListByIdList(reportIdArr)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = "获取报告授权失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //grantMap := make(map[报告id]map[用户id]bool)
|
|
|
+ grantMap := make(map[int]map[int]bool)
|
|
|
+ for _, v := range grantList {
|
|
|
+ grantUserMap, ok := grantMap[v.ReportId]
|
|
|
+ if !ok {
|
|
|
+ grantUserMap = make(map[int]bool)
|
|
|
+ }
|
|
|
+ grantUserMap[v.AdminId] = true
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, item := range list {
|
|
|
+ if item.AdminId == this.SysUser.AdminId {
|
|
|
+ list[i].HasAuth = true
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找授权
|
|
|
+ var hasAuth bool
|
|
|
+ grantUserMap, ok := grantMap[item.Id]
|
|
|
+
|
|
|
+ // 如果报告根本没有授权用户,说明没有授权当前用户
|
|
|
+ if !ok {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ _, ok = grantUserMap[this.SysUser.AdminId]
|
|
|
+ list[i].HasAuth = hasAuth
|
|
|
+ // 如果报告关联用户找到,说明有授权当前用户
|
|
|
+ if ok {
|
|
|
+ list[i].HasAuth = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
for _, item := range list {
|