Daniel 2025-08-22 21:00:43 +08:00
parent eea13b713d
commit ee95f9bf6f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 61 additions and 46 deletions

View file

@ -350,6 +350,58 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
}
}
}
case av.KeyTypeCreated: // 渲染创建时间
ial := map[string]string{}
block := item.GetBlockValue()
if nil != block {
ial = ials[block.Block.ID]
}
if nil == ial {
ial = map[string]string{}
}
id := itemID
if "" != ial["id"] {
id = ial["id"]
}
createdStr := id[:len("20060102150405")]
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
if nil == parseErr {
value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
value.Created.IsNotEmpty = true
} else {
value.Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
}
case av.KeyTypeUpdated: // 渲染更新时间
ial := map[string]string{}
block := item.GetBlockValue()
if nil != block {
ial = ials[block.Block.ID]
}
if nil == ial {
ial = map[string]string{}
}
updatedStr := ial["updated"]
if "" == updatedStr && nil != block {
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
value.Updated.IsNotEmpty = true
} else {
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
if nil == parseErr {
value.Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
value.Updated.IsNotEmpty = true
} else {
value.Updated = av.NewFormattedValueUpdated(time.Now().UnixMilli(), 0, av.UpdatedFormatNone)
}
}
}
}
}
for _, item := range collection.GetItems() {
for _, value := range item.GetValues() {
itemID := item.GetID()
switch value.Type {
case av.KeyTypeRollup: // 渲染汇总
rollupKey, _ := attrView.GetKey(value.KeyID)
if nil == rollupKey || nil == rollupKey.Rollup {
@ -421,49 +473,6 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
}
}
}
case av.KeyTypeCreated: // 渲染创建时间
ial := map[string]string{}
block := item.GetBlockValue()
if nil != block {
ial = ials[block.Block.ID]
}
if nil == ial {
ial = map[string]string{}
}
id := itemID
if "" != ial["id"] {
id = ial["id"]
}
createdStr := id[:len("20060102150405")]
created, parseErr := time.ParseInLocation("20060102150405", createdStr, time.Local)
if nil == parseErr {
value.Created = av.NewFormattedValueCreated(created.UnixMilli(), 0, av.CreatedFormatNone)
value.Created.IsNotEmpty = true
} else {
value.Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone)
}
case av.KeyTypeUpdated: // 渲染更新时间
ial := map[string]string{}
block := item.GetBlockValue()
if nil != block {
ial = ials[block.Block.ID]
}
if nil == ial {
ial = map[string]string{}
}
updatedStr := ial["updated"]
if "" == updatedStr && nil != block {
value.Updated = av.NewFormattedValueUpdated(block.Block.Updated, 0, av.UpdatedFormatNone)
value.Updated.IsNotEmpty = true
} else {
updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local)
if nil == parseErr {
value.Updated = av.NewFormattedValueUpdated(updated.UnixMilli(), 0, av.UpdatedFormatNone)
value.Updated.IsNotEmpty = true
} else {
value.Updated = av.NewFormattedValueUpdated(time.Now().UnixMilli(), 0, av.UpdatedFormatNone)
}
}
}
}
}