Browse Source

add:表格增加水印

zqbao 4 months ago
parent
commit
6cd28b9607
3 changed files with 34 additions and 2 deletions
  1. 10 0
      controllers/excel_info.go
  2. 22 1
      models/business_conf.go
  3. 2 1
      models/response/excel_info.go

+ 10 - 0
controllers/excel_info.go

@@ -187,6 +187,16 @@ func (this *ExcelInfoController) GetTableDetail() {
 	config := response.ExcelTableDetailConfigResp{
 		FontSize: 9,
 	}
+	waterMarkConf, err := models.GetBusinessConfByKeys([]string{"WatermarkTable", "CompanyWatermark"})
+	if err != nil {
+		br.Msg = "获取水印失败"
+		br.ErrMsg = "获取水印失败,Err:" + err.Error()
+		return
+	}
+	if waterMarkConf["WatermarkTable"] == "true" && waterMarkConf["CompanyWatermark"] != "" {
+		config.Watermark = waterMarkConf["CompanyWatermark"]
+
+	}
 
 	// 获取配置的字体大小
 	confName := models.FromSceneMap[fromScene]

+ 22 - 1
models/business_conf.go

@@ -3,9 +3,10 @@ package models
 import (
 	"eta/eta_chart_lib/utils"
 	"fmt"
-	"github.com/beego/beego/v2/client/orm"
 	"html"
 	"time"
+
+	"github.com/beego/beego/v2/client/orm"
 )
 
 const (
@@ -63,6 +64,26 @@ func GetBusinessConfByKey(key string) (item *BusinessConf, err error) {
 	return
 }
 
+func GetBusinessConfByKeys(key []string) (list map[string]string, err error) {
+	list = make(map[string]string)
+	if len(key) == 0 {
+		return
+	}
+	var items []*BusinessConf
+	o := orm.NewOrm()
+	sql := fmt.Sprintf(`SELECT * FROM business_conf WHERE conf_key IN (%s) `, utils.GetOrmInReplace(len(key)))
+	_, err = o.Raw(sql, key).QueryRows(&items)
+
+	for _, v := range items {
+		if v.ValType == 4 {
+			list[v.ConfKey] = html.UnescapeString(v.ConfVal)
+			continue
+		}
+		list[v.ConfKey] = v.ConfVal
+	}
+	return
+}
+
 // InitUseMongoConf
 // @Description:
 // @author: Roc

+ 2 - 1
models/response/excel_info.go

@@ -25,7 +25,8 @@ type ExcelTableDetailResp struct {
 // ExcelTableDetailConfigResp
 // @Description: Excel表格的配置信息
 type ExcelTableDetailConfigResp struct {
-	FontSize int
+	FontSize  int
+	Watermark string
 }
 
 // TableCellResp 单元格