Browse Source

feat:表格详情新增返回字体大小配置

Roc 11 months ago
parent
commit
6a428e22c8
3 changed files with 43 additions and 0 deletions
  1. 19 0
      controllers/excel_info.go
  2. 17 0
      models/business_conf.go
  3. 7 0
      models/response/excel_info.go

+ 19 - 0
controllers/excel_info.go

@@ -10,6 +10,7 @@ import (
 	"eta/eta_chart_lib/services/excel"
 	"eta/eta_chart_lib/utils"
 	"fmt"
+	"github.com/shopspring/decimal"
 	"time"
 )
 
@@ -22,6 +23,7 @@ type ExcelInfoController struct {
 // @Title 获取表格表详情
 // @Description 获取表格表详情接口
 // @Param   UniqueCode   query   string  true       "表格表唯一编码,如果是管理后台访问,传固定字符串:7c69b590249049942070ae9dcd5bf6dc"
+// @Param   FromScene   query   int  true       "场景来源,1:智能研报,2:研报列表;3:英文研报;4:中文PPT;5:英文PPT"
 // @Success 200 {object} response.ExcelTableDetailResp
 // @router /detail [get]
 func (this *ExcelInfoController) GetTableDetail() {
@@ -37,6 +39,7 @@ func (this *ExcelInfoController) GetTableDetail() {
 		br.ErrMsg = "参数错误,uniqueCode is empty"
 		return
 	}
+	fromScene, _ := this.GetInt("FromScene", 0)
 	key := utils.HZ_CHART_LIB_EXCEL_TABLE_DETAIL + ":" + uniqueCode
 	resp := new(response.ExcelTableDetailResp)
 	//判断是否有缓存
@@ -128,6 +131,21 @@ func (this *ExcelInfoController) GetTableDetail() {
 	}
 
 	tableData = excel.HandleTableCell(tableData)
+	config := response.ExcelTableDetailConfigResp{
+		FontSize: 9,
+	}
+
+	// 获取配置的字体大小
+	confName := models.FromSceneMap[fromScene]
+	if confName != `` {
+		busConf, err := models.GetBusinessConfByKey(confName)
+		if err == nil {
+			sizeDeci, err := decimal.NewFromString(busConf.ConfVal)
+			if err == nil {
+				config.FontSize = int(sizeDeci.IntPart())
+			}
+		}
+	}
 
 	resp.TableInfo = tableData
 	resp.Source = excelInfo.Source
@@ -135,6 +153,7 @@ func (this *ExcelInfoController) GetTableDetail() {
 	resp.ExcelName = excelInfo.ExcelName
 	resp.ExcelImage = excelInfo.ExcelImage
 	resp.UniqueCode = excelInfo.UniqueCode
+	resp.Config = config
 
 	if utils.Re == nil {
 		data, _ := json.Marshal(resp)

+ 17 - 0
models/business_conf.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"html"
 	"time"
@@ -12,6 +13,15 @@ const (
 	BusinessConfWatermarkChart   = "WatermarkChart"
 )
 
+// FromSceneMap 数据源名称与数据源ID的对应关系
+var FromSceneMap = map[int]string{
+	1: "SmartReportSheetSize",
+	2: "ReportSheetSize",
+	3: "EnReportSheetSize",
+	4: "CnPptSheetSize",
+	5: "EnPptSheetSize",
+}
+
 // BusinessConf 商户配置表
 type BusinessConf struct {
 	Id         int    `orm:"column(id);pk"`
@@ -44,3 +54,10 @@ func GetBusinessConf() (list map[string]string, err error) {
 	}
 	return
 }
+
+func GetBusinessConfByKey(key string) (item *BusinessConf, err error) {
+	o := orm.NewOrm()
+	sql := fmt.Sprintf(`SELECT * FROM business_conf WHERE conf_key = ? LIMIT 1`)
+	err = o.Raw(sql, key).QueryRow(&item)
+	return
+}

+ 7 - 0
models/response/excel_info.go

@@ -16,6 +16,13 @@ type ExcelTableDetailResp struct {
 	ExcelImage string `description:"表格截图"`
 	ExcelName  string `description:"表格名称"`
 	TableInfo  excel.TableData
+	Config     ExcelTableDetailConfigResp
+}
+
+// ExcelTableDetailConfigResp
+// @Description: Excel表格的配置信息
+type ExcelTableDetailConfigResp struct {
+	FontSize int
 }
 
 // TableCellResp 单元格