Browse Source

Merge branch 'bzq/dev' of eta_mini/eta_mini_bridge into debug

鲍自强 7 months ago
parent
commit
d51a1a4c7f
3 changed files with 53 additions and 4 deletions
  1. 17 2
      controllers/report.go
  2. 35 1
      models/report.go
  3. 1 1
      models/response/report.go

+ 17 - 2
controllers/report.go

@@ -760,7 +760,7 @@ func (this *ReportNoAuthController) List() {
 	rangeType, _ := this.GetInt("RangeType")
 	classifyId, _ := this.GetInt("ClassifyId")
 
-	if chartPermissionId <= 0 {
+	if chartPermissionId < 0 {
 		br.Msg = "品种参数错误"
 		return
 	}
@@ -808,7 +808,7 @@ func (this *ReportNoAuthController) List() {
 		}
 	}
 	var total int
-	var reportList []*models.ReportPushStatus
+	var reportList []*models.ReportPushView
 	classifyFirstIds := make([]int, 0)
 	classifySecondIds := make([]int, 0)
 	classifyThirdIds := make([]int, 0)
@@ -934,6 +934,21 @@ func (this *ReportNoAuthController) List() {
 			return
 		}
 		reportList = tmpReportList
+	case 0:
+		tmptotal, err := models.GetPushReportCount()
+		if err != nil {
+			br.Msg = "获取数据失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		total = tmptotal
+		tmpReportList, err := models.GetPushReportListByPage(startSize, pageSize)
+		if err != nil {
+			br.Msg = "获取报告列表失败"
+			br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
+			return
+		}
+		reportList = tmpReportList
 	default:
 		br.Msg = "层级参数错误"
 		return

+ 35 - 1
models/report.go

@@ -60,6 +60,26 @@ type ReportPushStatus struct {
 	PushTime           time.Time `description:"推送时间"`
 }
 
+type ReportPushView struct {
+	ReportPushStatusId int    `orm:"pk"`
+	ReportId           int    `description:"报告id"`
+	Title              string `description:"报告标题"`
+	Abstract           string `description:"报告摘要"`
+	ClassifyIdFirst    int    `description:"一级分类id"`
+	ClassifyNameFirst  string `description:"一级分类名称"`
+	ClassifyIdSecond   int    `description:"二级分类id"`
+	ClassifyNameSecond string `description:"二级分类名称"`
+	ClassifyIdThird    int    `description:"二级分类id"`
+	ClassifyNameThird  string `description:"二级分类名称"`
+	Author             string `description:"报告作者"`
+	State              int    `description:"报告状态:0-未推送,1-已推送"`
+	PushTime           string `description:"推送时间"`
+	PublishTime        string `description:"报告发布时间"`
+	ReportType         int    `description:"报告类型:1-eta报告"`
+	CreateTime         string `description:"创建时间"`
+	ModifyTime         string `description:"修改时间"`
+}
+
 // GetReportDailyListCount 获得今日报告数量
 func GetReportDailyListCount() (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
@@ -155,7 +175,7 @@ func GetPushReportCountByClassifyIds(classifyFirstIds, classifySecondIds, classi
 	return
 }
 
-func GetPushReportListByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds []int, condition string, startSize, pageSize int) (items []*ReportPushStatus, err error) {
+func GetPushReportListByClassifyIds(classifyFirstIds, classifySecondIds, classifyThirdIds []int, condition string, startSize, pageSize int) (items []*ReportPushView, err error) {
 	if len(classifyFirstIds) == 0 && len(classifySecondIds) == 0 && len(classifyThirdIds) == 0 {
 		return
 	}
@@ -180,6 +200,20 @@ func GetPushReportListByClassifyIds(classifyFirstIds, classifySecondIds, classif
 	return
 }
 
+func GetPushReportCount() (count int, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT COUNT(*) AS count FROM report_push_status WHERE state=1 AND report_type=1 `
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
+func GetPushReportListByPage(startSize, pageSize int) (items []*ReportPushView, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM report_push_status WHERE state=1 AND report_type=1 ORDER BY publish_time DESC LIMIT ?,? `
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 func GetReportByClassifyIds(classifyIds []int, condition string) (count int, err error) {
 	if len(classifyIds) == 0 {
 		return

+ 1 - 1
models/response/report.go

@@ -12,7 +12,7 @@ type ReportListResp struct {
 }
 
 type ReportPushListResp struct {
-	List   []*models.ReportPushStatus
+	List   []*models.ReportPushView
 	Paging *paging.PagingItem
 }