zwxi 10 月之前
父節點
當前提交
3bda212840
共有 3 個文件被更改,包括 41 次插入0 次删除
  1. 20 0
      controllers/smart_report/smart_report.go
  2. 13 0
      models/smart_report/smart_report.go
  3. 8 0
      models/smart_report/smart_resource.go

+ 20 - 0
controllers/smart_report/smart_report.go

@@ -384,7 +384,27 @@ func (this *SmartReportController) Detail() {
 		return
 	}
 	resp := smart_report.FormatSmartReport2Item(item)
+	if resp.HeadResourceId > 0 {
+		headResource, err := smart_report.GetResourceItemById(resp.HeadResourceId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
+			return
+		}
+		resp.HeadImg = headResource.ImgUrl
+		resp.HeadStyle = headResource.Style
+	}
 
+	if resp.EndResourceId > 0 {
+		endResource, err := smart_report.GetResourceItemById(resp.EndResourceId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "获取资源库版头失败, Err: " + e.Error()
+			return
+		}
+		resp.EndImg = endResource.ImgUrl
+		resp.EndStyle = endResource.Style
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 13 - 0
models/smart_report/smart_report.go

@@ -58,6 +58,11 @@ type SmartReport struct {
 	CanvasColor         string    `description:"画布颜色"`
 	ApproveTime         time.Time `description:"审批时间"`
 	ApproveId           int       `description:"审批ID"`
+	NeedSplice          int     `description:"0-不需要 1-需要"`
+	HeadResourceId      int     `description:"版头资源ID"`
+	EndResourceId       int     `description:"版尾资源ID"`
+	HeadStyle           string  `description:"版头样式"`
+	EndStyle            string  `description:"版尾样式"`
 }
 
 func (m *SmartReport) TableName() string {
@@ -216,6 +221,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 格式化智能研报数据格式
@@ -263,6 +273,9 @@ func FormatSmartReport2Item(origin *SmartReport) (item *SmartReportItem) {
 	item.EndImg = origin.EndImg
 	item.CanvasColor = origin.CanvasColor
 	item.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, origin.ApproveTime)
+	item.NeedSplice = origin.NeedSplice
+	item.HeadResourceId = origin.HeadResourceId
+	item.EndResourceId = origin.EndResourceId
 	return
 }
 

+ 8 - 0
models/smart_report/smart_resource.go

@@ -12,6 +12,7 @@ type SmartReportResource struct {
 	ResourceId int       `orm:"column(resource_id);pk" description:"智能研报资源ID"`
 	ImgUrl     string    // 图片链接
 	ImgName    string    // 图片名称
+	Style      string    // 版图样式
 	Type       int       // 类型 1-版头 2-版尾
 	CreateTime time.Time // 创建时间
 }
@@ -105,3 +106,10 @@ type SmartReportResourceAddReq struct {
 	ImgUrl  string `description:"图片链接"`
 	ImgName string `description:"图片名称"`
 }
+
+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
+}