Browse Source

fix:添加pdf收藏参数

zqbao 8 months ago
parent
commit
d88768da11
2 changed files with 14 additions and 0 deletions
  1. 13 0
      controllers/report.go
  2. 1 0
      models/report_pdf.go

+ 13 - 0
controllers/report.go

@@ -335,6 +335,19 @@ func (this *ReportController) PdfDetail() {
 	} else {
 		reportPdf.IsPublic = IsPublic
 	}
+
+	count, err := models.GetMyReportCountByUserIdAndReportId(user.UserId, reportPdf.ReportPdfId, utils.ReportTypePdf)
+	if err != nil {
+		br.Msg = "获取研报详情失败"
+		br.ErrMsg = "获取用户收藏记录失败,Err:" + err.Error()
+		return
+	}
+	if count > 0 {
+		reportPdf.IsCollect = true
+	} else {
+		reportPdf.IsCollect = false
+	}
+
 	resp.Report = reportPdf
 	resp.Status = utils.ReportPermissionStatusHas
 

+ 1 - 0
models/report_pdf.go

@@ -45,6 +45,7 @@ type ReportPdfView struct {
 	SysRealName        string    `description:"创建人姓名"`
 	State              int       `description:"状态:1-已发布;2-未发布"`
 	IsPublic           bool      `description:"是否公开"`
+	IsCollect          bool      `description:"是否收藏"`
 }
 
 func GetReportPdfListByCondition(condition string, pars []interface{}, startSize, pageSize int) (reportPdfs []*ReportPdf, err error) {