From 8db022ec8a76e9932c93b1b777f1c11bdbf199cb Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 5 Oct 2023 22:22:54 +0800 Subject: [PATCH] :art: Database template col type --- kernel/model/attribute_view.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 23a6f67e7c3..0d8a4505802 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -50,13 +50,18 @@ func renderTemplateCol(blockID, tplContent string, rowValues []*av.KeyValues) st buf := &bytes.Buffer{} ial := GetBlockAttrs(blockID) - dataModel := map[string]string{} // 复制一份 IAL 以避免修改原始数据 + dataModel := map[string]interface{}{} // 复制一份 IAL 以避免修改原始数据 for k, v := range ial { dataModel[strings.ReplaceAll(k, "custom-", "custom_")] = v } for _, rowValue := range rowValues { if 0 < len(rowValue.Values) { - dataModel[rowValue.Key.Name] = rowValue.Values[0].String() + v := rowValue.Values[0] + if av.KeyTypeNumber == v.Type { + dataModel[rowValue.Key.Name] = v.Number.Content + } else { + dataModel[rowValue.Key.Name] = v.String() + } } } if err := tpl.Execute(buf, dataModel); nil != err {