瀏覽代碼

fix:搜索修复日期

zqbao 9 月之前
父節點
當前提交
ae3b6742ad
共有 2 個文件被更改,包括 52 次插入2 次删除
  1. 32 2
      controllers/report.go
  2. 20 0
      models/response/report.go

+ 32 - 2
controllers/report.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"eta/eta_mini_api/models"
+	"eta/eta_mini_api/models/response"
 	"eta/eta_mini_api/services"
 	"eta/eta_mini_api/utils"
 )
@@ -165,8 +166,37 @@ func (this *ReportController) Search() {
 		br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
 		return
 	}
-
-	br.Data = reports.Data
+	if reports.Ret != 200 {
+		br.Msg = reports.Msg
+		br.ErrMsg = reports.ErrMsg
+		return
+	}
+	resp := new(response.ReportSearchViewResp)
+	list := make([]*response.ReportSearchListView, 0)
+	for _, v := range reports.Data.List {
+		tmpReport := &response.ReportSearchListView{
+			ReportId:            v.ReportId,
+			ReportChapterId:     v.ReportChapterId,
+			ClassifyIdFirst:     v.ClassifyIdFirst,
+			ClassifyNameFirst:   v.ClassifyNameFirst,
+			ClassifyIdSecond:    v.ClassifyIdSecond,
+			ClassifyNameSecond:  v.ClassifyNameSecond,
+			ReportChapterTypeId: v.ReportChapterTypeId,
+			PublishTime:         v.PublishTime.Format(utils.FormatDate),
+			Title:               v.Title,
+			ContentSub:          v.ContentSub,
+			Abstract:            v.Abstract,
+			Stage:               v.Stage,
+			Author:              v.Author,
+		}
+		if v.PublishTime.IsZero() {
+			tmpReport.PublishTime = ""
+		}
+		list = append(list, tmpReport)
+	}
+	resp.List = list
+	resp.Paging = reports.Data.Paging
+	br.Data = resp
 	br.Msg = "查询成功"
 	br.Ret = 200
 	br.Success = true

+ 20 - 0
models/response/report.go

@@ -40,7 +40,27 @@ type ReportCollectListItem struct {
 	Author              string    `description:"作者"`
 }
 
+type ReportSearchListView struct {
+	ReportId            int    `description:"报告Id"`
+	ReportChapterId     int    `description:"报告章节Id"`
+	ClassifyIdFirst     int    `description:"一级分类id"`
+	ClassifyNameFirst   string `description:"一级分类名称"`
+	ClassifyIdSecond    int    `description:"二级分类id"`
+	ClassifyNameSecond  string `description:"二级分类名称"`
+	ReportChapterTypeId int    `decription:"报告章节类型id"`
+	PublishTime         string `description:"发布时间"`
+	Title               string `description:"标题"`
+	ContentSub          string `description:"内容前两个章节"`
+	Abstract            string `description:"摘要"`
+	Stage               string `description:"期数"`
+	Author              string `description:"作者"`
+}
+
 type ReportSearchResp struct {
 	Paging *paging.PagingItem
 	List   []*ReportCollectListItem
 }
+type ReportSearchViewResp struct {
+	Paging *paging.PagingItem
+	List   []*ReportSearchListView
+}