|
@@ -364,66 +364,67 @@ func SearchReportList(key string, Ids []int, pageInfo page.PageInfo, isLogin boo
|
|
|
offset := page.StartIndex(pageInfo.Current, pageInfo.PageSize)
|
|
|
var reports []reportService.ReportDTO
|
|
|
reports, err = reportService.SearchReportList(key, Ids, offset, pageInfo.PageSize, pageInfo.LatestId)
|
|
|
- var wg sync.WaitGroup
|
|
|
- wg.Add(len(reports))
|
|
|
- for i := 0; i < len(reports); i++ {
|
|
|
- go func(report *reportService.ReportDTO) {
|
|
|
- defer wg.Done()
|
|
|
- report.Login = isLogin
|
|
|
- report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
|
|
|
- permissions := getReportSecondPermissions(report.OrgId, report.Source)
|
|
|
- if len(permissions) == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
- riskNum := getHighestRiskLevel(permissions)
|
|
|
- report.RiskLevel = strings.Join([]string{"R", strconv.Itoa(riskNum)}, "")
|
|
|
- var src string
|
|
|
- src, err = mediaService.GetImageSrc(report.CoverSrc)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取图片地址失败:%v", err)
|
|
|
- src = ""
|
|
|
- } else {
|
|
|
- report.CoverUrl = src
|
|
|
- }
|
|
|
- //下查询产品信息
|
|
|
- product, pdErr := productService.GetProductBySourceId(report.ReportID, productDao.Report)
|
|
|
- if pdErr != nil {
|
|
|
- if errors.Is(pdErr, gorm.ErrRecordNotFound) {
|
|
|
- report.Price = defaultProductPrice
|
|
|
- report.IsFree = true
|
|
|
- report.IsSubscribe = false
|
|
|
- } else {
|
|
|
- report.Price = defaultProductPrice
|
|
|
- report.IsFree = false
|
|
|
- report.IsSubscribe = false
|
|
|
- }
|
|
|
- } else {
|
|
|
- report.Price = product.Price.String()
|
|
|
- report.IsFree = false
|
|
|
- if isLogin {
|
|
|
- subscribe, subscribeErr := userService.GetUserSubscribe(product.Id, userId)
|
|
|
- if subscribeErr != nil {
|
|
|
- report.IsSubscribe = false
|
|
|
- } else {
|
|
|
- report.IsSubscribe = subscribe.Status == userDao.SubscribeValid
|
|
|
- }
|
|
|
- }
|
|
|
- pdRiskNum, parseErr := parseRiskLevel(product.RiskLevel)
|
|
|
- if parseErr != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- rpRiskNum, parseErr := parseRiskLevel(report.RiskLevel)
|
|
|
- if parseErr != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- if rpRiskNum <= pdRiskNum {
|
|
|
- report.RiskLevel = product.RiskLevel
|
|
|
- }
|
|
|
- }
|
|
|
- list = append(list, *report)
|
|
|
- }(&reports[i])
|
|
|
- }
|
|
|
- wg.Wait()
|
|
|
+ list, err = dealReportInfo(reports, isLogin, userId)
|
|
|
+ //var wg sync.WaitGroup
|
|
|
+ //wg.Add(len(reports))
|
|
|
+ //for i := 0; i < len(reports); i++ {
|
|
|
+ // go func(report *reportService.ReportDTO) {
|
|
|
+ // defer wg.Done()
|
|
|
+ // report.Login = isLogin
|
|
|
+ // report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
|
|
|
+ // permissions := getReportSecondPermissions(report.OrgId, report.Source)
|
|
|
+ // if len(permissions) == 0 {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // riskNum := getHighestRiskLevel(permissions)
|
|
|
+ // report.RiskLevel = strings.Join([]string{"R", strconv.Itoa(riskNum)}, "")
|
|
|
+ // var src string
|
|
|
+ // src, err = mediaService.GetImageSrc(report.CoverSrc)
|
|
|
+ // if err != nil {
|
|
|
+ // logger.Error("获取图片地址失败:%v", err)
|
|
|
+ // src = ""
|
|
|
+ // } else {
|
|
|
+ // report.CoverUrl = src
|
|
|
+ // }
|
|
|
+ // //下查询产品信息
|
|
|
+ // product, pdErr := productService.GetProductBySourceId(report.ReportID, productDao.Report)
|
|
|
+ // if pdErr != nil {
|
|
|
+ // if errors.Is(pdErr, gorm.ErrRecordNotFound) {
|
|
|
+ // report.Price = defaultProductPrice
|
|
|
+ // report.IsFree = true
|
|
|
+ // report.IsSubscribe = false
|
|
|
+ // } else {
|
|
|
+ // report.Price = defaultProductPrice
|
|
|
+ // report.IsFree = false
|
|
|
+ // report.IsSubscribe = false
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // report.Price = product.Price.String()
|
|
|
+ // report.IsFree = false
|
|
|
+ // if isLogin {
|
|
|
+ // subscribe, subscribeErr := userService.GetUserSubscribe(product.Id, userId)
|
|
|
+ // if subscribeErr != nil {
|
|
|
+ // report.IsSubscribe = false
|
|
|
+ // } else {
|
|
|
+ // report.IsSubscribe = subscribe.Status == userDao.SubscribeValid
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // pdRiskNum, parseErr := parseRiskLevel(product.RiskLevel)
|
|
|
+ // if parseErr != nil {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // rpRiskNum, parseErr := parseRiskLevel(report.RiskLevel)
|
|
|
+ // if parseErr != nil {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // if rpRiskNum <= pdRiskNum {
|
|
|
+ // report.RiskLevel = product.RiskLevel
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // list = append(list, *report)
|
|
|
+ // }(&reports[i])
|
|
|
+ //}
|
|
|
+ //wg.Wait()
|
|
|
if err != nil {
|
|
|
err = exception.New(exception.SearchReportPageFailed)
|
|
|
}
|
|
@@ -473,7 +474,7 @@ func RangeSearchByAnalyst(analystName string, userId int) (total int64, latestId
|
|
|
func RangeSearch(isLogin bool, userId int) (total int64, latestId int64, orgIds map[string][]int) {
|
|
|
return getCount(nil, isLogin, userId)
|
|
|
}
|
|
|
-func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (err error) {
|
|
|
+func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (resultList []reportService.ReportDTO, err error) {
|
|
|
var wg sync.WaitGroup
|
|
|
wg.Add(len(list))
|
|
|
for i := 0; i < len(list); i++ {
|
|
@@ -533,6 +534,7 @@ func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (e
|
|
|
}(&list[i])
|
|
|
}
|
|
|
wg.Wait()
|
|
|
+ resultList = list
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -540,7 +542,7 @@ func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (e
|
|
|
func GetReportPage(pageInfo page.PageInfo, orgIds map[string][]int, searchAll bool, isLogin bool, userId int) (reports []reportService.ReportDTO, err error) {
|
|
|
var list []reportService.ReportDTO
|
|
|
list, err = reportService.GetReportPageByOrgIds(pageInfo, orgIds, searchAll)
|
|
|
- err = dealReportInfo(list, isLogin, userId)
|
|
|
+ reports, err = dealReportInfo(list, isLogin, userId)
|
|
|
////并发获取研报的标签
|
|
|
//var wg sync.WaitGroup
|
|
|
//wg.Add(len(list))
|