瀏覽代碼

研报增加品种名称

kobe6258 7 月之前
父節點
當前提交
9b5504ddbc
共有 2 個文件被更改,包括 53 次插入22 次删除
  1. 25 0
      controllers/message.go
  2. 28 22
      models/report.go

+ 25 - 0
controllers/message.go

@@ -100,6 +100,7 @@ func (this *MessageController) ReportList() {
 
 	startSize := utils.StartIndex(currentIndex, pageSize)
 	reportList, err := models.GetReportByCondition(condition, sortCondition, pars, startSize, pageSize)
+
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
@@ -110,6 +111,30 @@ func (this *MessageController) ReportList() {
 		reportView := report.ToView()
 		reportViewList = append(reportViewList, reportView)
 	}
+	for _, report := range reportViewList {
+		var classifyId int
+		classifyId, err = models.GetETAReportById(report.OrgId)
+		if err != nil {
+			br.Msg = "获取报告列表失败"
+			br.ErrMsg = "获取eta报告失败,Err:" + err.Error()
+			return
+		}
+		var list []int
+		list, err = models.GetByPermissionIdsByClassifyId(classifyId)
+		if err != nil {
+			br.Msg = "获取报告列表失败"
+			br.ErrMsg = "获取eta品种信息失败,Err:" + err.Error()
+			return
+		}
+		var names []string
+		names, err = models.GetPermissionNames(list)
+		if err != nil {
+			br.Msg = "获取报告列表失败"
+			br.ErrMsg = "获取eta品种信息失败,Err:" + err.Error()
+			return
+		}
+		report.PermissionNames = strings.Join(names, ",")
+	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(response.ReportListResp)
 	resp.List = reportViewList

+ 28 - 22
models/report.go

@@ -21,30 +21,31 @@ const (
 )
 
 type Report struct {
-	Id            int
-	OrgId         int
-	Source        ReportSource
-	Title         string
-	Abstract      string
-	Author        string
-	CoverSrc      string
-	Status        ReportStatus
-	SendStatus    SendStatus
-	PublishedTime string
-	CreatedTime   time.Time
-	UpdatedTime   time.Time
+	Id            int          `description:"id"`
+	OrgId         int          `description:"组织id"`
+	Source        ReportSource `description:"来源"`
+	Title         string       `description:"标题"`
+	Abstract      string       `description:"摘要"`
+	Author        string       `description:"作者"`
+	CoverSrc      int          `description:"封面"`
+	Status        ReportStatus `description:"状态"`
+	SendStatus    SendStatus   `description:"发送状态"`
+	PublishedTime string       `description:"发布时间"`
+	CreatedTime   time.Time    `description:"创建时间"`
+	UpdatedTime   time.Time    `description:"更新时间"`
 }
 
 type ReportView struct {
-	Id            int
-	OrgId         int
-	Source        ReportSource
-	Title         string
-	Abstract      string
-	Author        string
-	CoverSrc      string
-	SendStatus    SendStatus
-	PublishedTime string
+	Id              int
+	OrgId           int
+	Source          ReportSource
+	Title           string
+	Abstract        string
+	Author          string
+	CoverSrc        string
+	PermissionNames string
+	SendStatus      SendStatus
+	PublishedTime   string
 }
 
 func (r *Report) ToView() (item *ReportView) {
@@ -55,7 +56,6 @@ func (r *Report) ToView() (item *ReportView) {
 		Title:         r.Title,
 		Abstract:      r.Abstract,
 		Author:        r.Author,
-		CoverSrc:      r.CoverSrc,
 		SendStatus:    r.SendStatus,
 		PublishedTime: r.PublishedTime,
 	}
@@ -112,6 +112,12 @@ func GetETAReportIdsByCondition(condition string, pars []interface{}) (ids []int
 	_, err = o.Raw(sql, pars).QueryRows(&ids)
 	return
 }
+func GetETAReportById(id int) (classifyId int, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT COALESCE(NULLIF(classify_id_third,0),NULLIF(classify_id_second,0),classify_id_first) classify_id  FROM report WHERE id =?`
+	err = o.Raw(sql, id).QueryRow(&classifyId)
+	return
+}
 
 func GetETAReportIdByClassifyId(id int) (classifyId int, err error) {
 	o := orm.NewOrmUsingDB("rddp")