|
@@ -255,12 +255,35 @@ func (bk *BookMarkController) SearchBookMark(sourceType string, key string) {
|
|
|
pageRes.Total = bk.PageInfo.Total
|
|
|
pageRes.TotalPage = page.TotalPages(pageRes.Total, pageRes.PageSize)
|
|
|
var bookMarkList []userService.BookMarkInterface
|
|
|
- bookMarkList, err = user.SearchBookMark(key, sourceType, sourceIds, bk.PageInfo, userInfo.Id)
|
|
|
- if err != nil {
|
|
|
- err = exception.New(exception.BookMarkListFailed)
|
|
|
+ switch sourceType {
|
|
|
+ case Report:
|
|
|
+ reportList, reportErr := report.SearchReportBookMark(key, sourceIds, bk.PageInfo, true, userInfo.Id)
|
|
|
+ if reportErr != nil {
|
|
|
+ logger.Error("搜索研报列表失败%v", err)
|
|
|
+ err = exception.NewWithException(exception.GetBookMarkListFailed, reportErr.Error())
|
|
|
+ bk.FailedResult("分页搜索收藏列表失败", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, reportInfo := range reportList {
|
|
|
+ bookMarkList = append(bookMarkList, ConvertToBookMarkReport(reportInfo))
|
|
|
+ }
|
|
|
+ case Chart:
|
|
|
+ chartList, chartErr := chartService.SearchChartList(key, sourceIds, bk.PageInfo)
|
|
|
+ if chartErr != nil {
|
|
|
+ logger.Error("搜索研报列表失败%v", err)
|
|
|
+ err = exception.NewWithException(exception.GetBookMarkListFailed, chartErr.Error())
|
|
|
+ bk.FailedResult("分页搜索收藏列表失败", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, chart := range chartList {
|
|
|
+ bookMarkList = append(bookMarkList, ConvertToBookMarkChart(chart))
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ err = exception.NewWithException(exception.GetBookMarkListFailed, "不支持的收藏类型")
|
|
|
bk.FailedResult("分页搜索收藏列表失败", result)
|
|
|
return
|
|
|
}
|
|
|
+ //bookMarkList, err = user.SearchBookMark(key, sourceType, sourceIds, bk.PageInfo, userInfo.Id)
|
|
|
bookMarks := new(page.PageResult)
|
|
|
bookMarks.Data = bookMarkList
|
|
|
bookMarks.Page = pageRes
|
|
@@ -268,6 +291,49 @@ func (bk *BookMarkController) SearchBookMark(sourceType string, key string) {
|
|
|
return
|
|
|
})
|
|
|
}
|
|
|
+func ConvertToBookMarkChart(chart chartService.ChartInfo) userService.BookMarkChart {
|
|
|
+ return userService.BookMarkChart{
|
|
|
+ ChartName: chart.ChartName,
|
|
|
+ ChartImage: chart.ChartImage,
|
|
|
+ UniqueCode: chart.UniqueCode,
|
|
|
+ ChartInfoId: chart.ChartInfoId,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func ConvertToBookMarkReport(report reportDomian.ReportDTO) userService.BookMarkReport {
|
|
|
+ return userService.BookMarkReport{
|
|
|
+ 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,
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// BookMarkList 获取收藏列表
|
|
|
// @Description 获取收藏列表
|
|
@@ -371,7 +437,7 @@ func getReportList(info page.PageInfo, templateUserId int, sourceIds []int) (lis
|
|
|
for index, sourceId := range sourceIds {
|
|
|
for _, reportDTO := range reports {
|
|
|
if reportDTO.ReportID == sourceId {
|
|
|
- reportInfo := userService.ConvertToBookMarkReport(reportDTO)
|
|
|
+ reportInfo := ConvertToBookMarkReport(reportDTO)
|
|
|
list[index] = reportInfo
|
|
|
}
|
|
|
}
|
|
@@ -397,7 +463,7 @@ func getChartList(info page.PageInfo, templateUserId int) (list []userService.Bo
|
|
|
defer wg.Done()
|
|
|
var data chartService.ChartInfo
|
|
|
data, err = chartService.GetChartById(id)
|
|
|
- chartInfo := userService.ConvertToBookMarkChart(data)
|
|
|
+ chartInfo := ConvertToBookMarkChart(data)
|
|
|
if err != nil {
|
|
|
logger.Error("获取数据失败: %v", err)
|
|
|
}
|