This commit is contained in:
Daniel 2025-06-12 10:30:43 +08:00
parent 4a2c6ac5a0
commit eee166e901
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 31 additions and 36 deletions

View file

@ -18,6 +18,7 @@ package sql
import (
"bytes"
"fmt"
"strings"
"text/template"
"time"
@ -389,6 +390,30 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, ials map[s
}
}
func fillAttributeViewTemplateValue(value *av.Value, item av.Item, attrView *av.AttributeView, ials map[string]map[string]string, items map[string][]*av.KeyValues) (err error) {
itemID := item.GetID()
switch value.Type {
case av.KeyTypeTemplate: // 渲染模板字段
keyValues := items[itemID]
ial := ials[itemID]
if nil == ial {
ial = map[string]string{}
}
content, renderErr := RenderTemplateField(ial, keyValues, value.Template.Content)
value.Template.Content = content
if nil != renderErr {
key, _ := attrView.GetKey(value.KeyID)
keyName := ""
if nil != key {
keyName = key.Name
}
err = fmt.Errorf("database [%s] template field [%s] rendering failed: %s", getAttrViewName(attrView), keyName, renderErr)
}
}
return
}
func fillAttributeViewNilValue(value *av.Value, typ av.KeyType) {
value.Type = typ
switch typ {