Explorar el Código

添加图表默认主题

xyxie hace 9 meses
padre
commit
8165294c16

+ 15 - 0
models/data_manage/chart_theme/chart_theme_type.go

@@ -88,3 +88,18 @@ func GetChartThemeTypeByChartTypeAndSource(chartType, source int) (item *ChartTh
 
 	return
 }
+
+// GetChartThemeTypeByChartType
+// @Description: 通过图表类型获取类型
+// @author: Roc
+// @datetime 2023-12-14 09:53:58
+// @param chartThemeTypeId int
+// @return item *ChartThemeType
+// @return err error
+func GetChartThemeTypeByChartType(chartType int) (item *ChartThemeType, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := `SELECT * FROM chart_theme_type where chart_type = ?`
+	err = o.Raw(sql, chartType).QueryRow(&item)
+
+	return
+}

+ 20 - 2
services/data/chart_info_excel_balance.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"errors"
 	"eta/eta_api/models/data_manage"
+	"eta/eta_api/models/data_manage/chart_theme"
 	excelModel "eta/eta_api/models/data_manage/excel"
 	"eta/eta_api/models/data_manage/excel/request"
 	"eta/eta_api/models/system"
@@ -105,6 +106,14 @@ func addBalanceExcelChart(req request.AddBalanceTableChartReq, sysUserId int, sy
 	chartType := req.ChartType
 	extraConfig := req.ExtraConfig
 	// todo 查找默认主题设置
+	// 查找主题类型id
+	chartThemeType, err := chart_theme.GetChartThemeTypeByChartType(chartType)
+	if err != nil {
+		errMsg = "查找主题类型失败!"
+		err = fmt.Errorf("%s, %s", errMsg, err.Error())
+		return
+	}
+	chartThemeId := chartThemeType.DefaultChartThemeId
 	// 季节性图表额外配置信息
 	var seasonExtraConfig string
 
@@ -211,7 +220,7 @@ func addBalanceExcelChart(req request.AddBalanceTableChartReq, sysUserId int, sy
 	chartInfo.SeasonExtraConfig = seasonExtraConfig
 	//chartInfo.StartYear = req.StartYear
 	chartInfo.Source = utils.CHART_SOURCE_BALANCE_EXCEL
-	//	chartInfo.ChartThemeId = req.ChartThemeId
+	chartInfo.ChartThemeId = chartThemeId
 	chartInfo.SourcesFrom = req.SourcesFrom
 	/*	chartInfo.Instructions = req.Instructions
 		chartInfo.MarkersLines = req.MarkersLines
@@ -367,6 +376,15 @@ func editBalanceExcelChart(req request.AddBalanceTableChartReq) (chartInfo *data
 		return
 	}
 	// todo 查找默认主题设置
+	// todo 查找默认主题设置
+	// 查找主题类型id
+	chartThemeType, err := chart_theme.GetChartThemeTypeByChartType(chartType)
+	if err != nil {
+		errMsg = "查找主题类型失败!"
+		err = fmt.Errorf("%s, %s", errMsg, err.Error())
+		return
+	}
+	chartThemeId := chartThemeType.DefaultChartThemeId
 	// 季节性图表额外配置信息
 	var seasonExtraConfig string
 
@@ -470,7 +488,7 @@ func editBalanceExcelChart(req request.AddBalanceTableChartReq) (chartInfo *data
 	chartInfo.SeasonExtraConfig = seasonExtraConfig
 	//chartInfo.StartYear = req.StartYear
 	chartInfo.Source = utils.CHART_SOURCE_BALANCE_EXCEL
-	//	chartInfo.ChartThemeId = req.ChartThemeId
+	chartInfo.ChartThemeId = chartThemeId
 	chartInfo.SourcesFrom = req.SourcesFrom
 	/*	chartInfo.Instructions = req.Instructions
 		chartInfo.MarkersLines = req.MarkersLines