Browse Source

fix:阅读记录和pdf报告的三级分类

zqbao 8 months ago
parent
commit
21fcc8d43d

+ 2 - 1
controllers/my_report.go

@@ -194,7 +194,8 @@ func (this *MyReportController) PdfCollect() {
 		br.ErrMsg = "获取研报详情失败,Err:" + err.Error()
 		return
 	}
-	chartPermissionResp, err := services.GetChartPermissionListByClassifyId(reportPdf.ClassifyIdSecond, 0)
+	reportClassifyId := services.GetReportPdfClassify(reportPdf)
+	chartPermissionResp, err := services.GetChartPermissionListByClassifyId(reportClassifyId, 0)
 	if err != nil {
 		br.Msg = "收藏失败"
 		br.ErrMsg = "获取研报详情失败,Err:" + err.Error()

+ 30 - 3
controllers/report.go

@@ -343,8 +343,9 @@ func (this *ReportController) PdfDetail() {
 		br.ErrMsg = "研报不存在或已删除,系统异常,Err:" + err.Error()
 		return
 	}
+	reportClassifyId := services.GetReportPdfClassify(reportPdf)
 
-	permissionResp, err := services.GetChartPermissionListByClassifyId(reportPdf.ClassifyIdSecond, 0)
+	permissionResp, err := services.GetChartPermissionListByClassifyId(reportClassifyId, 0)
 	if err != nil {
 		br.Msg = "研报不存在或已删除"
 		br.ErrMsg = "获取权限失败,系统异常,Err:" + err.Error()
@@ -482,7 +483,17 @@ func (this *ReportController) DailyList() {
 	}
 	var classifyIds []int
 	for _, v := range reportPdfList {
-		classifyIds = append(classifyIds, v.ClassifyIdSecond)
+		var reportClassifyId int
+		if v.ClassifyIdFirst != 0 {
+			reportClassifyId = v.ClassifyIdFirst
+		}
+		if v.ClassifyIdSecond != 0 {
+			reportClassifyId = v.ClassifyIdSecond
+		}
+		if v.ClassifyIdThird != 0 {
+			reportClassifyId = v.ClassifyIdThird
+		}
+		classifyIds = append(classifyIds, reportClassifyId)
 	}
 
 	if len(classifyIds) > 0 {
@@ -508,6 +519,8 @@ func (this *ReportController) DailyList() {
 				ClassifyNameFirst:  v.ClassifyNameFirst,
 				ClassifyIdSecond:   v.ClassifyIdSecond,
 				ClassifyNameSecond: v.ClassifyNameSecond,
+				ClassifyIdThird:    v.ClassifyIdThird,
+				ClassifyNameThird:  v.ClassifyNameThird,
 				PermissionNames:    classifyPermissionMap[v.ClassifyIdSecond],
 				PdfUrl:             v.PdfUrl,
 				Title:              v.Title,
@@ -569,7 +582,17 @@ func (this *ReportController) RecentList() {
 	}
 	var classifyIds []int
 	for _, v := range reportPdfList {
-		classifyIds = append(classifyIds, v.ClassifyIdSecond)
+		var reportClassifyId int
+		if v.ClassifyIdFirst != 0 {
+			reportClassifyId = v.ClassifyIdFirst
+		}
+		if v.ClassifyIdSecond != 0 {
+			reportClassifyId = v.ClassifyIdSecond
+		}
+		if v.ClassifyIdThird != 0 {
+			reportClassifyId = v.ClassifyIdThird
+		}
+		classifyIds = append(classifyIds, reportClassifyId)
 	}
 	classifyResp, err := services.GetFirstChartPermission(classifyIds)
 	if err != nil {
@@ -593,6 +616,8 @@ func (this *ReportController) RecentList() {
 			ClassifyNameFirst:  v.ClassifyNameFirst,
 			ClassifyIdSecond:   v.ClassifyIdSecond,
 			ClassifyNameSecond: v.ClassifyNameSecond,
+			ClassifyIdThird:    v.ClassifyIdThird,
+			ClassifyNameThird:  v.ClassifyNameThird,
 			PermissionNames:    classifyPermissionMap[v.ClassifyIdSecond],
 			PdfUrl:             v.PdfUrl,
 			Title:              v.Title,
@@ -665,6 +690,8 @@ func (this *ReportController) Search() {
 			ClassifyNameFirst:   v.ClassifyNameFirst,
 			ClassifyIdSecond:    v.ClassifyIdSecond,
 			ClassifyNameSecond:  v.ClassifyNameSecond,
+			ClassifyIdThird:     v.ClassifyIdThird,
+			ClassifyNameThird:   v.ClassifyNameThird,
 			ReportChapterTypeId: v.ReportChapterTypeId,
 			PublishTime:         v.PublishTime.Format(utils.FormatDate),
 			Title:               v.Title,

+ 4 - 1
controllers/user.go

@@ -333,6 +333,8 @@ func (this *UserAuthController) AddReportRecord() {
 			ClassifyName1:       reportDetail.ClassifyNameFirst,
 			ClassifyId2:         reportDetail.ClassifyIdSecond,
 			ClassifyName2:       reportDetail.ClassifyNameSecond,
+			ClassifyId3:         reportDetail.ClassifyIdThird,
+			ClassifyName3:       reportDetail.ClassifyNameThird,
 			Timestamp:           int(curTime.Unix()),
 			CreateTime:          curTime,
 			CreateDate:          curTime.Format(utils.FormatDate),
@@ -441,7 +443,8 @@ func (this *UserAuthController) AddReportPdfRecord() {
 		br.ErrMsg = "获取研报错误,Err:" + err.Error()
 		return
 	}
-	reportPermissionResp, err := services.GetChartPermissionListByClassifyId(reportPdf.ClassifyIdSecond, 0)
+	reportClassifyId := services.GetReportPdfClassify(reportPdf)
+	reportPermissionResp, err := services.GetChartPermissionListByClassifyId(reportClassifyId, 0)
 	if err != nil {
 		br.Msg = "添加阅读记录失败"
 		br.ErrMsg = "获取研报品种错误,Err:" + err.Error()

+ 4 - 0
models/report.go

@@ -12,6 +12,8 @@ type ReportView struct {
 	ClassifyNameFirst  string               `description:"一级分类名称"`
 	ClassifyIdSecond   int                  `description:"二级分类id"`
 	ClassifyNameSecond string               `description:"二级分类名称"`
+	ClassifyIdThird    int                  `description:"三级分类id"`
+	ClassifyNameThird  string               `description:"三级分类名称"`
 	PermissionNames    []string             `description:"二级分类名称"`
 	Title              string               `description:"标题"`
 	Abstract           string               `description:"摘要"`
@@ -50,6 +52,8 @@ type ReportDetail struct {
 	ClassifyNameFirst  string              `description:"一级分类名称"`
 	ClassifyIdSecond   int                 `description:"二级分类id"`
 	ClassifyNameSecond string              `description:"二级分类名称"`
+	ClassifyIdThird    int                 `description:"三级分类id"`
+	ClassifyNameThird  string              `description:"三级分类名称"`
 	Title              string              `description:"标题"`
 	Abstract           string              `description:"摘要"`
 	Author             string              `description:"作者"`

+ 4 - 0
models/response/report.go

@@ -32,6 +32,8 @@ type ReportCollectListItem struct {
 	ClassifyNameFirst   string    `description:"一级分类名称"`
 	ClassifyIdSecond    int       `description:"二级分类id"`
 	ClassifyNameSecond  string    `description:"二级分类名称"`
+	ClassifyIdThird     int       `description:"三级分类id"`
+	ClassifyNameThird   string    `description:"三级分类名称"`
 	ReportChapterTypeId int       `decription:"报告章节类型id"`
 	PublishTime         time.Time `description:"发布时间"`
 	Title               string    `description:"标题"`
@@ -50,6 +52,8 @@ type ReportSearchListView struct {
 	ClassifyNameFirst   string `description:"一级分类名称"`
 	ClassifyIdSecond    int    `description:"二级分类id"`
 	ClassifyNameSecond  string `description:"二级分类名称"`
+	ClassifyIdThird     int    `description:"三级分类id"`
+	ClassifyNameThird   string `description:"三级分类名称"`
 	ReportChapterTypeId int    `decription:"报告章节类型id"`
 	PublishTime         string `description:"发布时间"`
 	Title               string `description:"标题"`

+ 2 - 0
models/user_read_record.go

@@ -19,6 +19,8 @@ type UserReadRecord struct {
 	ClassifyName1       string    `description:"一级分类名称"`
 	ClassifyId2         int       `description:"二级分类id"`
 	ClassifyName2       string    `description:"二级分类名称"`
+	ClassifyId3         int       `description:"三级分类id"`
+	ClassifyName3       string    `description:"三级分类名称"`
 	Timestamp           int       `description:"阅读开始时间戳"`
 	EndTimestamp        int       `description:"阅读结束时间戳"`
 	CreateTime          time.Time `description:"创建时间"`

+ 1 - 1
services/chart_permission.go

@@ -94,7 +94,7 @@ func GetReportChartPermissionList(reportId int) (resp *models.ChartPermissionRes
 	return
 }
 
-// GetChartPermissionListByClassifyId 根据分类id获取权限列表
+// GetChartPermissionListByClassifyId 根据分类id获取权限列表 scope 0:二级品种权限,1:一级品种权限,2:所有权限
 func GetChartPermissionListByClassifyId(classifyId, scope int) (resp *models.ChartPermissionResp[[]*models.ChartPermission], err error) {
 	url := utils.ETA_MINI_BRIDGE_URL + "/chart_permission/classify/detail"
 	url += fmt.Sprintf("?ClassifyId=%d&Scope=%d", classifyId, scope)

+ 16 - 0
services/report.go

@@ -2,12 +2,28 @@ package services
 
 import (
 	"encoding/json"
+	"eta/eta_mini_api/models"
 	"eta/eta_mini_api/utils"
 	"fmt"
 
 	resp2 "eta/eta_mini_api/models/response"
 )
 
+// GetReportPdfClassify 获取pdf研报的最小分类
+func GetReportPdfClassify(report *models.ReportPdfView) int {
+	var res int
+	if report.ClassifyIdFirst != 0 {
+		res = report.ClassifyIdFirst
+	}
+	if report.ClassifyIdSecond != 0 {
+		res = report.ClassifyIdSecond
+	}
+	if report.ClassifyIdThird != 0 {
+		res = report.ClassifyIdThird
+	}
+	return res
+}
+
 func GetReportList(chartPermissionId, level, rangeType, classifyId, currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportList], err error) {
 	url := utils.ETA_MINI_BRIDGE_URL + "/report/list?"
 	url += fmt.Sprintf("RangeType=%d&ChartPermissionId=%d&Level=%d&PageSize=%d&CurrentIndex=%d&ClassifyId=%d", rangeType, chartPermissionId, level, pageSize, currentIndex, classifyId)