|
@@ -263,69 +263,6 @@ func getHTReportDetail(report *reportService.ReportDTO) (url string, err error)
|
|
|
}
|
|
|
func GetTotalPageCountByPermissionIds(permissionIds []int, isLogin bool, userId int) (total int64, latestId int64, ids map[string][]int) {
|
|
|
return getCount(permissionIds, isLogin, userId)
|
|
|
- //var err error
|
|
|
- ////登录了需要校验风险等级,如果风险等级没做或者过期直接返回空,做了就筛选风险等级
|
|
|
- //if isLogin {
|
|
|
- // userProfile, userErr := user.GetUserProfile(userId)
|
|
|
- // if userErr != nil {
|
|
|
- // if errors.Is(userErr, gorm.ErrRecordNotFound) {
|
|
|
- // err = exception.New(exception.TemplateUserNotFound)
|
|
|
- // } else {
|
|
|
- // err = exception.New(exception.TemplateUserFoundFailed)
|
|
|
- // }
|
|
|
- // logger.Error("分页查询报告列表失败:%v", err)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // //获取产品风险等级
|
|
|
- // if userProfile.RiskLevel == user.RiskUnTest {
|
|
|
- // logger.Error("客户未做风险等级测评,mobile:%d", userProfile.Mobile)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // if userProfile.RiskLevelStatus == user.RiskExpired {
|
|
|
- // logger.Error("客户风险等级已过期,mobile:%d", userProfile.Mobile)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // mapping, mappingErr := permissionService.GetRiskMappingByCustomerRiskLevel(userProfile.RiskLevel)
|
|
|
- // if mappingErr != nil {
|
|
|
- // logger.Error("查询产品风险等级映射失败:%v", mappingErr)
|
|
|
- // return
|
|
|
- // }
|
|
|
- // var permissionList []permissionService.PermissionDTO
|
|
|
- // if len(permissionIds) == 0 {
|
|
|
- // //获取所有设置风险等级的品种
|
|
|
- // permissionList, err = permissionService.GetPermissionListWithRisk()
|
|
|
- // } else {
|
|
|
- // //更具id过滤设置了风险等级的品种
|
|
|
- // permissionList, err = permissionService.GetPermissionListByIds(permissionIds)
|
|
|
- // }
|
|
|
- // permissionList = filterPermissionsByRisk(permissionList, mapping.ProductRiskLevel)
|
|
|
- // if len(permissionList) == 0 {
|
|
|
- // return
|
|
|
- // }
|
|
|
- // var filterPermissionIds []int
|
|
|
- // for _, permission := range permissionList {
|
|
|
- // filterPermissionIds = append(filterPermissionIds, permission.PermissionId)
|
|
|
- // }
|
|
|
- // return reportService.GetTotalPageCountByPermissionIds(filterPermissionIds, mapping.ProductRiskLevel)
|
|
|
- //} else { //没有登录的时候展示所有设置了风险等级的品种报告,筛选的时候过滤传入ID中没有设置风险等级的品种
|
|
|
- // var permissionList []permissionService.PermissionDTO
|
|
|
- // if len(permissionIds) == 0 {
|
|
|
- // //获取所有设置风险等级的品种
|
|
|
- // permissionList, err = permissionService.GetPermissionListWithRisk()
|
|
|
- // } else {
|
|
|
- // //更具id过滤设置了风险等级的品种
|
|
|
- // permissionList, err = permissionService.GetPermissionListByIds(permissionIds)
|
|
|
- // }
|
|
|
- // if err != nil {
|
|
|
- // logger.Error("根据ID查询品种列表失败:%v", err)
|
|
|
- // }
|
|
|
- // var filterPermissionIds []int
|
|
|
- // for _, permission := range permissionList {
|
|
|
- // filterPermissionIds = append(filterPermissionIds, permission.PermissionId)
|
|
|
- // }
|
|
|
- // //查询品种
|
|
|
- // return reportService.GetTotalPageCountByPermissionIds(filterPermissionIds, "")
|
|
|
- //}
|
|
|
}
|
|
|
func filterPermissionsByRisk(permissionList []permissionService.PermissionDTO, riskLevel string) (resultList []permissionService.PermissionDTO) {
|
|
|
if riskLevel != "" {
|
|
@@ -369,66 +306,6 @@ func SearchReportList(key string, Ids []int, pageInfo page.PageInfo, isLogin boo
|
|
|
var reports []reportService.ReportDTO
|
|
|
reports, err = reportService.SearchReportList(key, Ids, offset, pageInfo.PageSize, pageInfo.LatestId)
|
|
|
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)
|
|
|
}
|
|
@@ -436,47 +313,18 @@ func SearchReportList(key string, Ids []int, pageInfo page.PageInfo, isLogin boo
|
|
|
}
|
|
|
func RangeSearchByAnalyst(analystName string, userId int) (total int64, latestId int64, ids []int) {
|
|
|
return getCountByAnalyst(nil, true, userId, analystName)
|
|
|
- ////登录了需要校验风险等级,如果风险等级没做或者过期直接返回空,做了就筛选风险等级
|
|
|
- //userProfile, userErr := user.GetUserProfile(userId)
|
|
|
- //if userErr != nil {
|
|
|
- // if errors.Is(userErr, gorm.ErrRecordNotFound) {
|
|
|
- // err = exception.New(exception.TemplateUserNotFound)
|
|
|
- // } else {
|
|
|
- // err = exception.New(exception.TemplateUserFoundFailed)
|
|
|
- // }
|
|
|
- // logger.Error("分页查询报告列表失败:%v", err)
|
|
|
- // return
|
|
|
- //}
|
|
|
- ////获取产品风险等级
|
|
|
- //if userProfile.RiskLevel == user.RiskUnTest {
|
|
|
- // logger.Error("客户未做风险等级测评,mobile:%v", userProfile.Mobile)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //if userProfile.RiskLevelStatus == user.RiskExpired {
|
|
|
- // logger.Error("客户风险等级已过期,mobile:%v", userProfile.Mobile)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //mapping, mappingErr := permissionService.GetRiskMappingByCustomerRiskLevel(userProfile.RiskLevel)
|
|
|
- //if mappingErr != nil {
|
|
|
- // logger.Error("查询产品风险等级映射失败:%v", mappingErr)
|
|
|
- // return
|
|
|
- //}
|
|
|
- //var permissionList []permissionService.PermissionDTO
|
|
|
- ////获取所有设置风险等级的品种
|
|
|
- //permissionList, err = permissionService.GetPermissionListWithRisk()
|
|
|
- //permissionList = filterPermissionsByRisk(permissionList, mapping.ProductRiskLevel)
|
|
|
- //if len(permissionList) == 0 {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //var filterPermissionIds []int
|
|
|
- //for _, permission := range permissionList {
|
|
|
- // filterPermissionIds = append(filterPermissionIds, permission.PermissionId)
|
|
|
- //}
|
|
|
-
|
|
|
- //return reportService.GetTotalPageCountByAnalyst(analystName, filterPermissionIds)
|
|
|
}
|
|
|
-func RangeSearch(isLogin bool, userId int) (total int64, latestId int64, orgIds map[string][]int) {
|
|
|
- return getCount(nil, isLogin, userId)
|
|
|
+func RangeSearch(key string, isLogin bool, userId int) (total int64, latestId int64, reportIds []int, err error) {
|
|
|
+ var orgIds map[string][]int
|
|
|
+ _, latestId, orgIds = getCount(nil, isLogin, userId)
|
|
|
+ reportIds, err = GetReportByIdListByOrgIds(orgIds)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取报告ID列表失败:%v", err)
|
|
|
+ err = exception.NewWithException(exception.GetReportSearchRangeFailed, err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ total = reportService.SearchMaxReportIdWithRange(key, reportIds)
|
|
|
+ return
|
|
|
}
|
|
|
func dealReportInfo(list []reportService.ReportDTO, isLogin bool, userId int) (resultList []reportService.ReportDTO, err error) {
|
|
|
var wg sync.WaitGroup
|
|
@@ -547,76 +395,12 @@ func GetReportPage(pageInfo page.PageInfo, orgIds map[string][]int, searchAll bo
|
|
|
var list []reportService.ReportDTO
|
|
|
list, err = reportService.GetReportPageByOrgIds(pageInfo, orgIds, searchAll)
|
|
|
reports, err = dealReportInfo(list, isLogin, userId)
|
|
|
- ////并发获取研报的标签
|
|
|
- //var wg sync.WaitGroup
|
|
|
- //wg.Add(len(list))
|
|
|
- //for i := 0; i < len(list); 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
|
|
|
- // }
|
|
|
- // }
|
|
|
- // reports = append(reports, *report)
|
|
|
- // }(&list[i])
|
|
|
- //}
|
|
|
- //wg.Wait()
|
|
|
+
|
|
|
if err != nil {
|
|
|
err = exception.New(exception.QueryReportPageFailed)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
-// func GetTotalPageCountByAnalyst(analyst string) (total int64, latestId int64) {
|
|
|
-// return reportService.GetTotalPageCountByAnalyst(analyst)
|
|
|
-// }
|
|
|
func GetReportPageByAnalyst(pageInfo page.PageInfo, analyst string, reportIds []int) (list []reportService.ReportDTO, err error) {
|
|
|
list, err = reportService.GetReportPageByAnalyst(pageInfo, analyst, reportIds)
|
|
|
//并发获取研报的标签
|