|
@@ -1,6 +1,7 @@
|
|
|
package user
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"errors"
|
|
|
"eta/eta_mini_ht_api/common/component/cache"
|
|
|
logger "eta/eta_mini_ht_api/common/component/log"
|
|
@@ -228,11 +229,39 @@ type BookMarkChart struct {
|
|
|
UniqueCode string `json:"uniqueCode"`
|
|
|
ChartInfoId int `json:"chartInfoId"`
|
|
|
}
|
|
|
+
|
|
|
type BookMarkReport struct {
|
|
|
- ChartName string `json:"chartName"`
|
|
|
- ChartImage string `json:"chartImage"`
|
|
|
- UniqueCode string `json:"uniqueCode"`
|
|
|
- ChartInfoId int `json:"chartInfoId"`
|
|
|
+ Type string `json:"type"`
|
|
|
+ ReportID int `json:"reportId"`
|
|
|
+ OrgId int `json:"orgId"`
|
|
|
+ Title string `json:"title"`
|
|
|
+ Author string `json:"author"`
|
|
|
+ AuthorInfo []reportDomian.Anthor `json:"authorInfo"`
|
|
|
+ Source string `json:"source"`
|
|
|
+ Abstract string `json:"abstract"`
|
|
|
+ PublishedTime string `json:"publishedTime"`
|
|
|
+ RiskLevel string `json:"riskLevel"`
|
|
|
+ PlateName string `json:"-"`
|
|
|
+ ClassifyId int `json:"-"`
|
|
|
+ SecondPermission map[int]string `json:"-"`
|
|
|
+ Permissions map[int]string `json:"-"`
|
|
|
+ PermissionNames interface {
|
|
|
+ } `json:"permissionNames"`
|
|
|
+ Highlight []string `json:"highlight"`
|
|
|
+ Detail json.RawMessage `json:"detail"`
|
|
|
+ PdfUrl string `json:"pdfUrl"`
|
|
|
+ CoverSrc int `json:"coverSrc"`
|
|
|
+ CoverUrl string `json:"coverUrl"`
|
|
|
+ Login bool `json:"login"`
|
|
|
+ RiskLevelStatus string `json:"riskLevelStatus"`
|
|
|
+ IsFree bool `json:"isFree"`
|
|
|
+ IsSubscribe bool `json:"isSubscribe"`
|
|
|
+ SubscribeStatus string `json:"subscribeStatus"`
|
|
|
+ Price string `json:"price"`
|
|
|
+ ProductId int `json:"productId"`
|
|
|
+ IsPackage bool `json:"isPackage"`
|
|
|
+ Score float64 `json:"score"`
|
|
|
+ Show bool `json:"-"`
|
|
|
}
|
|
|
|
|
|
// BookMarkList 获取收藏列表
|
|
@@ -332,32 +361,15 @@ func getReportList(info page.PageInfo, templateUserId int, sourceIds []int) (lis
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- // 创建一个切片来存储结果,长度与 sourceIds 相同
|
|
|
- list = make([]BookMarkReport, len(sourceIds))
|
|
|
- // 使用 WaitGroup 来等待所有 goroutine 完成
|
|
|
- var wg sync.WaitGroup
|
|
|
- wg.Add(len(sourceIds))
|
|
|
- // 使用 Mutex 来保护对 list 的写操作
|
|
|
- var mu sync.Mutex
|
|
|
// 并发获取数据
|
|
|
for index, sourceId := range sourceIds {
|
|
|
- go func(index int, id int) {
|
|
|
- defer wg.Done()
|
|
|
- var data chartService.ChartInfo
|
|
|
- data, err = chartService.GetChartById(id)
|
|
|
- reportInfo := convertToBookMarkChart(data)
|
|
|
- if err != nil {
|
|
|
- logger.Error("获取数据失败: %v", err)
|
|
|
+ for _, reportDTO := range reports {
|
|
|
+ if reportDTO.ReportID == sourceId {
|
|
|
+ reportInfo := convertToBookMarkReport(reportDTO)
|
|
|
+ list[index] = reportInfo
|
|
|
}
|
|
|
- // 使用 Mutex 保护对 list 的写操作
|
|
|
- mu.Lock()
|
|
|
- list[index] = reportInfo
|
|
|
- mu.Unlock()
|
|
|
- }(index, sourceId)
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
- // 等待所有 goroutine 完成
|
|
|
- wg.Wait()
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -404,11 +416,37 @@ func convertToBookMarkChart(chart chartService.ChartInfo) BookMarkChart {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func convertToBookMarkReport(chart chartService.ChartInfo) BookMarkReport {
|
|
|
+func convertToBookMarkReport(report reportDomian.ReportDTO) BookMarkReport {
|
|
|
return BookMarkReport{
|
|
|
- ChartName: chart.ChartName,
|
|
|
- ChartImage: chart.ChartImage,
|
|
|
- UniqueCode: chart.UniqueCode,
|
|
|
- ChartInfoId: chart.ChartInfoId,
|
|
|
+ Abstract: report.Abstract,
|
|
|
+ Author: report.Author,
|
|
|
+ AuthorInfo: report.AuthorInfo,
|
|
|
+ ClassifyId: report.ClassifyId,
|
|
|
+ CoverSrc: report.CoverSrc,
|
|
|
+ CoverUrl: report.CoverUrl,
|
|
|
+ Detail: report.Detail,
|
|
|
+ Highlight: report.Highlight,
|
|
|
+ IsFree: report.IsFree,
|
|
|
+ IsPackage: report.IsPackage,
|
|
|
+ IsSubscribe: report.IsSubscribe,
|
|
|
+ Login: report.Login,
|
|
|
+ OrgId: report.OrgId,
|
|
|
+ PdfUrl: report.PdfUrl,
|
|
|
+ PermissionNames: report.PermissionNames,
|
|
|
+ Permissions: report.Permissions,
|
|
|
+ PlateName: report.PlateName,
|
|
|
+ Price: report.Price,
|
|
|
+ ProductId: report.ProductId,
|
|
|
+ PublishedTime: report.PublishedTime,
|
|
|
+ ReportID: report.ReportID,
|
|
|
+ RiskLevel: report.RiskLevel,
|
|
|
+ RiskLevelStatus: report.RiskLevelStatus,
|
|
|
+ Score: report.Score,
|
|
|
+ SecondPermission: report.SecondPermission,
|
|
|
+ Show: report.Show,
|
|
|
+ Source: report.Source,
|
|
|
+ SubscribeStatus: report.SubscribeStatus,
|
|
|
+ Title: report.Title,
|
|
|
+ Type: report.Type,
|
|
|
}
|
|
|
}
|