Explorar el Código

最新资讯,更多推荐

ziwen hace 2 años
padre
commit
62b51ba015
Se han modificado 2 ficheros con 15 adiciones y 8 borrados
  1. 5 4
      controller/pc/pc.go
  2. 10 4
      models/response/pc/report.go

+ 5 - 4
controller/pc/pc.go

@@ -18,12 +18,13 @@ import (
 
 // LatestNews 研报首页最新资讯
 func LatestNews(c *gin.Context) {
-	banner, err := banner.GetHomeBannerList()
+	recommendList, err := pcModels.GetLatestReportList()
 	if err != nil {
-		response.Fail(err.Error(), c)
+		response.Fail("获取报告详情失败"+err.Error(), c)
 		return
 	}
-	response.OkData("查询成功", banner, c)
+
+	response.OkData("查询成功", recommendList, c)
 	return
 }
 
@@ -154,7 +155,7 @@ func Recommend(c *gin.Context) {
 	} else {
 		reportType = 2
 	}
-	recommendList, err := pcModels.GetRecommendList(reportId, reportType)
+	recommendList, err := pcModels.GetRecommendList(reportId, reportType, reportInfo.ClassifyIdSecond)
 	if err != nil {
 		response.Fail("获取报告详情失败"+err.Error(), c)
 		return

+ 10 - 4
models/response/pc/report.go

@@ -6,7 +6,7 @@ import (
 	"time"
 )
 
-type RecommendReport struct {
+type Report struct {
 	Id                 int       `description:"报告Id"`
 	AddType            int       `description:"新增方式:1:新增报告,2:继承报告"`
 	ClassifyIdFirst    int       `description:"一级分类id"`
@@ -34,9 +34,15 @@ type RecommendReport struct {
 	TitleType          string    `description:"标题类型,FICC或者权益"`
 }
 
-func GetRecommendList(reportId, reportType int) (items []*RecommendReport, err error) {
-	sql := `SELECT * FROM report WHERE state=2 AND id<> %v`
-	sql = fmt.Sprintf(sql, reportId)
+func GetLatestReportList() (items []*Report, err error) {
+	sql := `SELECT * FROM report WHERE state=2 ORDER BY publish_time DESC LIMIT 3 `
+	err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error
+	return
+}
+
+func GetRecommendList(reportId, reportType, secondId int) (items []*Report, err error) {
+	sql := `SELECT * FROM report WHERE state=2 AND id<> %v AND classify_id_second=%v `
+	sql = fmt.Sprintf(sql, reportId, secondId)
 	if reportType == 1 {
 		sql += ` AND classify_name_first='权益研报' `
 	} else {