|
@@ -283,8 +283,9 @@ func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (r
|
|
|
go func(report *reportService.ReportDTO) {
|
|
|
defer wg.Done()
|
|
|
report.Login = isLogin
|
|
|
- report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
|
|
|
- permissions := getReportSecondPermissions(report.OrgId, report.Source)
|
|
|
+ report.Permissions, report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
|
|
|
+ var permissions []permissionService.PermissionDTO
|
|
|
+ permissions, report.SecondPermission = getReportSecondPermissions(report.OrgId, report.Source)
|
|
|
if len(permissions) == 0 {
|
|
|
return
|
|
|
}
|
|
@@ -302,7 +303,6 @@ func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (r
|
|
|
product, pdErr := productService.GetProductBySourceId(report.ReportID, productDao.Report)
|
|
|
if pdErr != nil {
|
|
|
if errors.Is(pdErr, gorm.ErrRecordNotFound) {
|
|
|
- permissions = reportService.GetReportSecondPermissionsById(report.OrgId, report.Source)
|
|
|
var permissionIds []int
|
|
|
if len(permissions) > 0 {
|
|
|
for _, permission := range permissions {
|
|
@@ -375,7 +375,7 @@ func GetReportPageByAnalyst(pageInfo page.PageInfo, analyst string, reportIds []
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
go func(report *reportService.ReportDTO) {
|
|
|
defer wg.Done()
|
|
|
- report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
|
|
|
+ report.Permissions, report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
|
|
|
}(&list[i])
|
|
|
}
|
|
|
wg.Wait()
|
|
@@ -481,10 +481,14 @@ func GetRandedReportByPublishTimeWeekly(limit int, week bool, isLogin bool, user
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func getReportPermissionNames(id int, source string) (labels []string) {
|
|
|
+func getReportPermissionNames(id int, source string) (permissionMap map[int]string, labels []string) {
|
|
|
permissions := reportService.GetReportPermissionsById(id, source)
|
|
|
- for _, permission := range permissions {
|
|
|
- labels = append(labels, permission.PermissionName)
|
|
|
+ permissionMap = make(map[int]string, len(permissions))
|
|
|
+ if len(permissions) > 0 {
|
|
|
+ for _, permission := range permissions {
|
|
|
+ labels = append(labels, permission.PermissionName)
|
|
|
+ permissionMap[permission.PermissionId] = permission.PermissionName
|
|
|
+ }
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -497,9 +501,15 @@ func getReportSecondPermissionsMap(id int, source string) (permissionMap map[int
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func getReportSecondPermissions(id int, source string) (permissionList []permissionService.PermissionDTO) {
|
|
|
- return reportService.GetReportSecondPermissionsById(id, source)
|
|
|
-
|
|
|
+func getReportSecondPermissions(id int, source string) (permissionList []permissionService.PermissionDTO, secondPermissionMap map[int]string) {
|
|
|
+ permissionList = reportService.GetReportSecondPermissionsById(id, source)
|
|
|
+ if len(permissionList) > 0 {
|
|
|
+ secondPermissionMap = make(map[int]string, len(permissionList))
|
|
|
+ for _, permission := range permissionList {
|
|
|
+ secondPermissionMap[permission.PermissionId] = permission.PermissionName
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
func getReportPermissionsMap(id int, source string) (permissionMap map[int]string) {
|
|
|
permissionMap = make(map[int]string)
|
|
@@ -514,11 +524,6 @@ func GetPermissionList() (root *permissionService.PermissionNode, err error) {
|
|
|
}
|
|
|
|
|
|
func convertToHotRankedReport(dto reportService.ReportDTO) (report HotRankedReport) {
|
|
|
- src, err := mediaService.GetImageSrc(dto.CoverSrc)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取封面图片失败:%v", err)
|
|
|
- src = ""
|
|
|
- }
|
|
|
report = HotRankedReport{
|
|
|
Id: dto.ReportID,
|
|
|
OrgId: dto.OrgId,
|
|
@@ -528,7 +533,7 @@ func convertToHotRankedReport(dto reportService.ReportDTO) (report HotRankedRepo
|
|
|
SecondPermissions: dto.SecondPermission,
|
|
|
Permissions: dto.Permissions,
|
|
|
PermissionNames: dto.PermissionNames,
|
|
|
- CoverUrl: src,
|
|
|
+ CoverUrl: dto.CoverUrl,
|
|
|
IsSubscribe: dto.IsSubscribe,
|
|
|
IsFree: dto.IsFree,
|
|
|
Price: dto.Price,
|