zwxi 11 miesięcy temu
rodzic
commit
e2e6b2a3a8
2 zmienionych plików z 49 dodań i 0 usunięć
  1. 20 0
      controllers/smart_report.go
  2. 29 0
      models/smart_report.go

+ 20 - 0
controllers/smart_report.go

@@ -49,7 +49,27 @@ func (this *SmartReportController) Detail() {
 		return
 	}
 	resp.Report = models.FormatSmartReport2Item(item)
+	if resp.Report.HeadResourceId > 0 {
+		headResource, err := models.GetResourceItemById(resp.Report.HeadResourceId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
+			return
+		}
+		resp.Report.HeadImg = headResource.ImgUrl
+		resp.Report.HeadStyle = headResource.Style
+	}
 
+	if resp.Report.EndResourceId > 0 {
+		endResource, err := models.GetResourceItemById(resp.Report.EndResourceId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
+			return
+		}
+		resp.Report.EndImg = endResource.ImgUrl
+		resp.Report.EndStyle = endResource.Style
+	}
 	// 免责声明
 	conf, e := models.GetBusinessConf()
 	if e != nil {

+ 29 - 0
models/smart_report.go

@@ -49,6 +49,11 @@ type SmartReport struct {
 	HeadImg             string    `description:"报告头图地址"`
 	EndImg              string    `description:"报告尾图地址"`
 	CanvasColor         string    `description:"画布颜色"`
+	NeedSplice          int     `description:"0-不需要 1-需要"`
+	HeadResourceId      int     `description:"版头资源ID"`
+	EndResourceId       int     `description:"版尾资源ID"`
+	HeadStyle           string  `description:"版头样式"`
+	EndStyle            string  `description:"版尾样式"`
 }
 
 func (m *SmartReport) TableName() string {
@@ -127,6 +132,11 @@ type SmartReportItem struct {
 	HeadImg            string  `description:"报告头图地址"`
 	EndImg             string  `description:"报告尾图地址"`
 	CanvasColor        string  `description:"画布颜色"`
+	NeedSplice          int     `description:"0-不需要 1-需要"`
+	HeadResourceId      int     `description:"版头资源ID"`
+	EndResourceId       int     `description:"版尾资源ID"`
+	HeadStyle           string  `description:"版头样式"`
+	EndStyle            string  `description:"版尾样式"`
 }
 
 // FormatSmartReport2Item 格式化智能研报数据格式
@@ -169,6 +179,9 @@ func FormatSmartReport2Item(origin *SmartReport) (item *SmartReportItem) {
 	item.CanvasColor = origin.CanvasColor
 	item.HeadImg = origin.HeadImg
 	item.EndImg = origin.EndImg
+	item.NeedSplice = origin.NeedSplice
+	item.HeadResourceId = origin.HeadResourceId
+	item.EndResourceId = origin.EndResourceId
 	return
 }
 
@@ -188,3 +201,19 @@ func UpdateSmartReportPv(reportId int) (err error) {
 	_, err = o.Raw(sql, reportId).Exec()
 	return
 }
+
+type SmartReportResource struct {
+	ResourceId int       `orm:"column(resource_id);pk" description:"智能研报资源ID"`
+	ImgUrl     string    // 图片链接
+	Style      string    // 版图样式
+	ImgName    string    // 图片名称
+	Type       int       // 类型 1-版头 2-版尾
+	CreateTime time.Time // 创建时间
+}
+
+func GetResourceItemById(id int) (item *SmartReportResource, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := fmt.Sprintf(`SELECT * FROM smart_report_resource WHERE resource_id = ? LIMIT 1`)
+	err = o.Raw(sql, id).QueryRow(&item)
+	return
+}