zwxi 11 月之前
父節點
當前提交
484448638e
共有 3 個文件被更改,包括 46 次插入11 次删除
  1. 25 1
      controllers/smart_report/smart_report.go
  2. 14 10
      models/smart_report/smart_report.go
  3. 7 0
      models/smart_report/smart_resource.go

+ 25 - 1
controllers/smart_report/smart_report.go

@@ -108,6 +108,8 @@ func (this *SmartReportController) Add() {
 	item.HeadImg = req.HeadImg
 	item.EndImg = req.EndImg
 	item.CanvasColor = req.CanvasColor
+	item.HeadResourceId = req.HeadResourceId
+	item.EndResourceId = req.EndResourceId
 
 	// 继承报告
 	if req.AddType == 2 {
@@ -244,7 +246,7 @@ func (this *SmartReportController) Edit() {
 		contentModify = true
 	}
 	cols := []string{"ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond", "Title", "Abstract", "Author",
-		"Frequency", "Content", "ContentSub", "ContentStruct", "ModifyTime", "HeadImg", "EndImg", "CanvasColor"}
+		"Frequency", "Content", "ContentSub", "ContentStruct", "ModifyTime", "HeadImg", "EndImg", "CanvasColor","HeadResourceId", "EndResourceId"}
 	item.ClassifyIdFirst = req.ClassifyIdFirst
 	item.ClassifyNameFirst = req.ClassifyNameFirst
 	item.ClassifyIdSecond = req.ClassifyIdSecond
@@ -260,6 +262,8 @@ func (this *SmartReportController) Edit() {
 	item.HeadImg = req.HeadImg
 	item.EndImg = req.EndImg
 	item.CanvasColor = req.CanvasColor
+	item.HeadResourceId = req.HeadResourceId
+	item.EndResourceId = req.EndResourceId
 	if contentModify {
 		item.LastModifyAdminId = sysUser.AdminId
 		item.LastModifyAdminName = sysUser.RealName
@@ -384,7 +388,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 = "获取成功"

+ 14 - 10
models/smart_report/smart_report.go

@@ -220,10 +220,10 @@ type SmartReportItem struct {
 	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:"版尾样式"`
+	HeadResourceId      int     `description:"版头资源ID"`
+	EndResourceId       int     `description:"版尾资源ID"`
+	HeadStyle           string  `description:"版头样式"`
+	EndStyle            string  `description:"版尾样式"`
 }
 
 // FormatSmartReport2Item 格式化智能研报数据格式
@@ -291,17 +291,21 @@ type SmartReportAddReq struct {
 	HeadImg            string `description:"报告头图地址"`
 	EndImg             string `description:"报告尾图地址"`
 	CanvasColor        string `description:"画布颜色"`
+	HeadResourceId     int    `description:"版头资源ID"`
+	EndResourceId      int    `description:"版尾资源ID"`
 }
 
 // SmartReportEditReq 编辑智能研报请求体
 type SmartReportEditReq struct {
 	SmartReportAddReq
-	SmartReportId int    `description:"智能研报ID"`
-	Content       string `description:"内容"`
-	ContentStruct string `description:"内容结构"`
-	HeadImg       string `description:"报告头图地址"`
-	EndImg        string `description:"报告尾图地址"`
-	CanvasColor   string `description:"画布颜色"`
+	SmartReportId  int    `description:"智能研报ID"`
+	Content        string `description:"内容"`
+	ContentStruct  string `description:"内容结构"`
+	HeadImg        string `description:"报告头图地址"`
+	EndImg         string `description:"报告尾图地址"`
+	CanvasColor    string `description:"画布颜色"`
+	HeadResourceId int    `description:"版头资源ID"`
+	EndResourceId  int    `description:"版尾资源ID"`
 }
 
 // SmartReportRemoveReq 删除智能研报请求体

+ 7 - 0
models/smart_report/smart_resource.go

@@ -109,3 +109,10 @@ type SmartReportResourceAddReq struct {
 	ImgName string `description:"图片名称"`
 	Style   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
+}