|
@@ -18,7 +18,7 @@ import (
|
|
|
"strconv"
|
|
|
)
|
|
|
|
|
|
-type EnglishReportController struct {}
|
|
|
+type EnglishReportController struct{}
|
|
|
|
|
|
func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
req := new(english_report.ReportListReq)
|
|
@@ -43,11 +43,11 @@ func (er *EnglishReportController) List(c *gin.Context) {
|
|
|
var tmpList []*english_report.Report
|
|
|
list := make([]*english_report.ReportListItem, 0)
|
|
|
|
|
|
- if req.ClassifyIdFirst >0 {
|
|
|
+ if req.ClassifyIdFirst > 0 {
|
|
|
condition += " and classify_id_first = ?"
|
|
|
pars = append(pars, req.ClassifyIdFirst)
|
|
|
}
|
|
|
- if req.ClassifyIdSecond >0 {
|
|
|
+ if req.ClassifyIdSecond > 0 {
|
|
|
condition += " and classify_id_second = ?"
|
|
|
pars = append(pars, req.ClassifyIdSecond)
|
|
|
}
|
|
@@ -146,7 +146,7 @@ func (er *EnglishReportController) Classify(c *gin.Context) {
|
|
|
}
|
|
|
if child, ok := parentMap[v.Id]; ok {
|
|
|
tmp.Child = child
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
continue
|
|
|
}
|
|
|
list = append(list, tmp)
|
|
@@ -180,7 +180,7 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
reportList := make([]*english_report.SearchEnglishReportItem, 0)
|
|
|
searchResp, total, err := elasticService.SearchESEnglishReport(req.KeyWord, from, req.PageSize)
|
|
|
if err != nil {
|
|
|
- resp.FailMsg("报告搜索失败", "报告搜索失败,Err:" + err.Error(), c)
|
|
|
+ resp.FailMsg("报告搜索失败", "报告搜索失败,Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
var tempList []*english_report.ElasticEnglishReportDetail
|
|
@@ -194,7 +194,7 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
reportItem := new(english_report.ElasticEnglishReportDetail)
|
|
|
tmpErr = json.Unmarshal(itemJson, &reportItem)
|
|
|
if tmpErr != nil {
|
|
|
- resp.FailMsg("报告搜索失败 解析出错", "报告搜索失败,Err:" + tmpErr.Error(), c)
|
|
|
+ resp.FailMsg("报告搜索失败 解析出错", "报告搜索失败,Err:"+tmpErr.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
if len(v.Highlight["Title"]) > 0 {
|
|
@@ -213,7 +213,7 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
videoIds := make([]uint, 0)
|
|
|
videoMap := make(map[uint]*english_video.EnglishVideo)
|
|
|
videoItem := new(english_video.EnglishVideo)
|
|
|
- if len(tempList)> 0 {
|
|
|
+ if len(tempList) > 0 {
|
|
|
for _, reportItem := range tempList {
|
|
|
if reportItem.VideoId > 0 {
|
|
|
videoIds = append(videoIds, reportItem.VideoId)
|
|
@@ -223,14 +223,14 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
if len(videoIds) > 0 {
|
|
|
videoList, e := videoItem.GetVideosByIds(videoIds)
|
|
|
if e != nil {
|
|
|
- resp.FailMsg("查询线上路演列表出错", "查询线上路演列表出错,Err:" + e.Error(), c)
|
|
|
+ resp.FailMsg("查询线上路演列表出错", "查询线上路演列表出错,Err:"+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
for _, v := range videoList {
|
|
|
videoMap[v.Id] = v
|
|
|
}
|
|
|
}
|
|
|
- if len(tempList)> 0 {
|
|
|
+ if len(tempList) > 0 {
|
|
|
for _, reportItem := range tempList {
|
|
|
temp := new(english_report.SearchEnglishReportItem)
|
|
|
temp.Title = reportItem.Title
|
|
@@ -246,7 +246,7 @@ func (er *EnglishReportController) FilterByEs(c *gin.Context) {
|
|
|
temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
|
|
|
temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
|
|
|
temp.Stage, _ = strconv.Atoi(reportItem.StageStr)
|
|
|
- }else if reportItem.VideoId > 0 {
|
|
|
+ } else if reportItem.VideoId > 0 {
|
|
|
if videoTemp, ok := videoMap[reportItem.VideoId]; ok {
|
|
|
temp.ReportType = 1
|
|
|
temp.Id = videoTemp.Id
|
|
@@ -285,20 +285,31 @@ func (er *EnglishReportController) Detail(c *gin.Context) {
|
|
|
reportItem := new(english_report.Report)
|
|
|
reportItem, err = reportItem.GetEnglishReportByCode(req.ReportCode)
|
|
|
if err != nil {
|
|
|
- resp.FailMsg("该报告已删除", "报告查询失败,Err:" + err.Error(), c)
|
|
|
+ resp.FailMsg("该报告已删除", "报告查询失败,Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ // 报告权限校验
|
|
|
+ authOk, e := english_report_service.CheckUserReportAuthByCompanyAndClassify(int(userinfo.CompanyId), reportItem.ClassifyIdSecond)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailMsg("获取失败", "报告权限校验失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ content, subContent := ``, ``
|
|
|
+ if authOk {
|
|
|
+ subContent = html.UnescapeString(reportItem.ContentSub)
|
|
|
+ content = html.UnescapeString(reportItem.Content)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 记录PV
|
|
|
err = reportItem.UpdatePvByReportCode(req.ReportCode)
|
|
|
if err != nil {
|
|
|
- resp.FailMsg("更新失败", "更新失败,Err:" + err.Error(), c)
|
|
|
+ resp.FailMsg("更新失败", "更新失败,Err:"+err.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- reportItem.ContentSub = html.UnescapeString(reportItem.ContentSub)
|
|
|
- reportItem.Content = html.UnescapeString(reportItem.Content)
|
|
|
-
|
|
|
- shareEmailId := userinfo.Id
|
|
|
|
|
|
// 记录邮箱
|
|
|
+ shareEmailId := userinfo.Id
|
|
|
if shareEmailId > 0 {
|
|
|
go english_report_service.DealEmail(reportItem, req.ReportCode, int(shareEmailId))
|
|
|
}
|
|
@@ -313,8 +324,8 @@ func (er *EnglishReportController) Detail(c *gin.Context) {
|
|
|
Abstract: reportItem.Abstract,
|
|
|
Author: reportItem.Author,
|
|
|
Overview: reportItem.Overview,
|
|
|
- Content: reportItem.Content,
|
|
|
- ContentSub: reportItem.ContentSub,
|
|
|
+ Content: content,
|
|
|
+ ContentSub: subContent,
|
|
|
Frequency: reportItem.Frequency,
|
|
|
PublishTime: utils.TimeTransferString(utils.FormatDateTime, reportItem.PublishTime),
|
|
|
Stage: reportItem.Stage,
|
|
@@ -329,5 +340,6 @@ func (er *EnglishReportController) Detail(c *gin.Context) {
|
|
|
}
|
|
|
baseData := new(english_report.ReportDetailResp)
|
|
|
baseData.Report = reportDetail
|
|
|
+ baseData.AuthOk = authOk
|
|
|
resp.OkData("查询成功", baseData, c)
|
|
|
}
|