|
@@ -4,7 +4,6 @@ import (
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
- "github.com/PuerkitoBio/goquery"
|
|
|
report_chapter_type_cache "hongze/hongze_yb/cache/report_chapter_type"
|
|
|
"hongze/hongze_yb/global"
|
|
|
"hongze/hongze_yb/models/response"
|
|
@@ -419,7 +418,7 @@ func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail respons
|
|
|
reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
|
|
|
reportItem.Stage = reportInfo.Stage
|
|
|
reportItem.Abstract = reportInfo.Abstract
|
|
|
- //reportItem.ContentSub = html.UnescapeString(reportInfo.ContentSub)
|
|
|
+ reportItem.ContentSub = html.UnescapeString(reportInfo.ContentSub)
|
|
|
reportItem.Frequency = reportInfo.Frequency
|
|
|
reportItem.VideoName = reportInfo.VideoName
|
|
|
if reportInfo.VideoName == "" && reportInfo.VideoUrl != "" {
|
|
@@ -448,14 +447,6 @@ func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail respons
|
|
|
task.Task(AddViewRecord, userinfo, reportInfo.Id, reportInfo.ClassifyNameFirst, 0)
|
|
|
reportItem.Content = html.UnescapeString(reportInfo.Content)
|
|
|
reportItem.VideoUrl = reportInfo.VideoUrl
|
|
|
- } else {
|
|
|
- contents := html.UnescapeString(reportInfo.Content)
|
|
|
- contentSub, tmpErr := SlicingReportContentSub(contents)
|
|
|
- if tmpErr != nil {
|
|
|
- err = errors.New("报告分段有误")
|
|
|
- return
|
|
|
- }
|
|
|
- reportItem.ContentSub = contentSub
|
|
|
}
|
|
|
//新增用户访问日志
|
|
|
task.Task(AddUserAccessRecord, userinfo, reportInfo.Id, reportInfo.ClassifyNameFirst, 0, authOk)
|
|
@@ -1109,28 +1100,3 @@ func addAliasToKeyword(keyword string) string {
|
|
|
keyword = strings.Join(keywordArr, ",")
|
|
|
return keyword
|
|
|
}
|
|
|
-
|
|
|
-func SlicingReportContentSub(content string) (contentSub string, err error) {
|
|
|
- content = html.UnescapeString(content)
|
|
|
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
|
|
|
- if err != nil {
|
|
|
- fmt.Println("create doc err:", err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- n := 0
|
|
|
- doc.Find("p").Each(func(i int, s *goquery.Selection) {
|
|
|
- if n >= 10 {
|
|
|
- return
|
|
|
- }
|
|
|
- n++
|
|
|
- phtml, err := s.Html()
|
|
|
- if err != nil {
|
|
|
- fmt.Println("get html err", err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if s.Text() != "" || strings.Contains(phtml, "src") {
|
|
|
- contentSub = contentSub + "<p>" + phtml + "</p>"
|
|
|
- }
|
|
|
- })
|
|
|
- return
|
|
|
-}
|