From 9db65d2bb4937a1bdc6bfdb683479f33c2e37f3a Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期六, 15 六月 2024 10:20:32 +0800 Subject: [PATCH] fix --- models/attribute.go | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/models/attribute.go b/models/attribute.go index 19fc906..f3b0d13 100644 --- a/models/attribute.go +++ b/models/attribute.go @@ -57,6 +57,17 @@ return nil } +func (slf *Attribute) BeforeUpdate(tx *gorm.DB) (err error) { + if len(slf.SelectValues) != 0 { + bts, err := json.Marshal(slf.SelectValues) + if err != nil { + return err + } + slf.SelectValue = string(bts) + } + return nil +} + func (slf *Attribute) AfterFind(tx *gorm.DB) (err error) { if slf.SelectValue != "" { var list []string -- Gitblit v1.8.0