Explorar o código

新增权益兼容

rdluck %!s(int64=4) %!d(string=hai) anos
pai
achega
62b18548b6
Modificáronse 5 ficheiros con 49 adicións e 6 borrados
  1. 9 1
      controllers/home.go
  2. 25 2
      controllers/report.go
  3. 1 0
      models/home.go
  4. 11 2
      models/report.go
  5. 3 1
      models/report_view_record.go

+ 9 - 1
controllers/home.go

@@ -33,6 +33,14 @@ func (this *HomeController) ListHome() {
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
+	for i := 0; i < len(list); i++ {
+		item := list[i]
+		if item.ClassifyName == "权益研报" {
+			list[i].TitleType = "权益"
+		} else {
+			list[i].TitleType = "FICC"
+		}
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取数据成功"
@@ -59,4 +67,4 @@ func (this *HomeController) ListBanner() {
 	br.Success = true
 	br.Msg = "获取数据成功"
 	br.Data = list
-}
+}

+ 25 - 2
controllers/report.go

@@ -89,7 +89,7 @@ func (this *ReportController) Detail() {
 			report.Content = report.ContentSub
 		}
 	}
-	if productId==1 {
+	if productId == 1 {
 		reportType := "rddp"
 		reportPermissionList, err := models.GetReportVarietyListByUserIdExt(user.UserId, reportType)
 		if err != nil {
@@ -138,6 +138,12 @@ func (this *ReportController) Detail() {
 		}
 	}
 
+	if report.ClassifyNameFirst == "权益研报" {
+		report.TitleType = "权益"
+	} else {
+		report.TitleType = "FICC"
+	}
+
 	resp := new(models.ReportDetailResp)
 	resp.Status = status
 	resp.Msg = msg
@@ -153,7 +159,13 @@ func (this *ReportController) Detail() {
 			go utils.SendEmail(utils.APPNAME+"失败提醒", "新增报告阅读记录失败:Err:"+err.Error(), utils.EmailSendToUsers)
 		}
 	}
-	recommendList, err := models.GetRecommendList(reportId)
+	reportType := 0
+	if report.ClassifyNameFirst == "权益研报" {
+		reportType = 1
+	} else {
+		reportType = 2
+	}
+	recommendList, err := models.GetRecommendList(reportId, reportType)
 	if err != nil {
 		br.Msg = "获取报告详情失败"
 		br.ErrMsg = "获取报告推荐列表信息失败,Err:" + err.Error()
@@ -173,6 +185,11 @@ func (this *ReportController) Detail() {
 		if count > 0 {
 			recommendList[i].HasPermission = 1
 		}
+		if item.ClassifyNameFirst == "权益研报" {
+			recommendList[i].TitleType = "权益"
+		} else {
+			recommendList[i].TitleType = "FICC"
+		}
 	}
 	resp.RecommendList = recommendList
 	br.Ret = 200
@@ -247,6 +264,12 @@ func (this *ReportController) ListReport() {
 		if count > 0 {
 			list[i].HasPermission = 1
 		}
+
+		if item.ClassifyNameFirst == "权益研报" {
+			list[i].TitleType = "权益"
+		} else {
+			list[i].TitleType = "FICC"
+		}
 	}
 
 	page := models.GetPaging(currentIndex, pageSize, total)

+ 1 - 0
models/home.go

@@ -10,6 +10,7 @@ type HomeList struct {
 	ClassifyId   int    `orm:"column(id)"`
 	ClassifyName string `description:"分类名称"`
 	Child        []*HomeClassifyItem
+	TitleType string `description:"标题类型,FICC或者权益"`
 }
 
 type HomeClassifyItem struct {

+ 11 - 2
models/report.go

@@ -55,6 +55,7 @@ type ReportList struct {
 	VideoPlaySeconds   string    `description:"音频播放时长"`
 	ContentSub         string    `description:"内容前两个章节"`
 	HasPermission      int       `description:"是否拥有报告权限,1:拥有,0:没有"`
+	TitleType          string    `description:"标题类型,FICC或者权益"`
 }
 
 type ReportListResp struct {
@@ -118,6 +119,7 @@ type ReportDetail struct {
 	IsShowNewLabel     int    `description:"是否显示新标签"`
 	IsCurrentDate      int    `description:"是否当前日期"`
 	ClassifyName       string `description:"分类名称"`
+	TitleType          string `description:"标题类型,FICC或者权益"`
 }
 
 func GetReportById(reportId int) (item *ReportDetail, err error) {
@@ -180,12 +182,19 @@ type RecommendReport struct {
 	ContentSub         string    `description:"内容前两个章节"`
 	ClassifyName       string    `description:"分类名称"`
 	HasPermission      int       `description:"报告权限:0:无权限,1:有权限"`
+	TitleType          string    `description:"标题类型,FICC或者权益"`
 }
 
-func GetRecommendList(reportId int) (items []*RecommendReport, err error) {
+func GetRecommendList(reportId, reportType int) (items []*RecommendReport, err error) {
 	o := orm.NewOrm()
 	o.Using("rddp")
-	sql := `SELECT * FROM report WHERE id<>? ORDER BY publish_time DESC LIMIT 3`
+	sql := `SELECT * FROM report WHERE id<>? `
+	if reportType == 1 {
+		sql += ` AND classify_name_first='权益研报' `
+	} else {
+		sql += ` AND classify_name_first<>'权益研报' `
+	}
+	sql += ` ORDER BY publish_time DESC LIMIT 3`
 	_, err = o.Raw(sql, reportId).QueryRows(&items)
 	return
 }

+ 3 - 1
models/report_view_record.go

@@ -18,4 +18,6 @@ func AddReportViewRecord(item *ReportViewRecord) (err error) {
 	o.Using("rddp")
 	_, err = o.Insert(item)
 	return
-}
+}
+
+//修改最新阅读时间