From 185e5da57a54c6b889e2a0df73b314bb64ede77a Mon Sep 17 00:00:00 2001 From: JNG <365252428@qq.com> Date: Mon, 5 Jan 2026 15:16:37 +0800 Subject: [PATCH] Update bundle_order_records.go --- internal/model/bundle_order_records.go | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/internal/model/bundle_order_records.go b/internal/model/bundle_order_records.go index 4f18418..62976bb 100644 --- a/internal/model/bundle_order_records.go +++ b/internal/model/bundle_order_records.go @@ -1,7 +1,9 @@ package model import ( + "database/sql/driver" "encoding/json" + "errors" "gorm.io/gorm" ) @@ -42,7 +44,7 @@ type BundleOrderRecords struct { Language string `gorm:"column:language;comment:语言" json:"language"` BundleOrderValueAdd []BundleOrderValueAdd `gorm:"foreignKey:OrderUUID;references:UUID" json:"bundleOrderValueAdd"` ReSignature int `json:"reSignature" gorm:"column:re_signature;default:2;type:int;comment:是否重新签 1:是 2:否"` - PlatformIds []uint32 `gorm:"column:platform_ids;type:json;NOT NULL;comment:发布平台ID集合 TIKTOK= 1, YOUTUBE = 2, INS = 3 , DM = 4, BL = 5;" json:"platformIDs"` + PlatformIds PlatformIDs `gorm:"column:platform_ids;type:json;NOT NULL;comment:发布平台ID集合 TIKTOK= 1, YOUTUBE = 2, INS = 3 , DM = 4, BL = 5;" json:"platformIDs"` } type BundleOrderValueAdd struct { gorm.Model @@ -74,6 +76,30 @@ type BundleOrderValueAdd struct { QuotaValue int32 `json:"quotaValue" gorm:"column:quota_value;type:int;comment:额度值"` IsExpired bool `json:"isExpired" gorm:"column:is_expired;default:false;comment:是否过期作废 false:不作废 true:作废"` } +type PlatformIDs []uint32 + +// 实现 Scanner 接口 +func (p *PlatformIDs) Scan(value interface{}) error { + if value == nil { + *p = []uint32{} + return nil + } + + bytes, ok := value.([]byte) + if !ok { + return errors.New("type assertion to []byte failed") + } + + return json.Unmarshal(bytes, p) +} + +// 实现 Valuer 接口 +func (p PlatformIDs) Value() (driver.Value, error) { + if len(p) == 0 { + return "[]", nil + } + return json.Marshal(p) +} // 财务确认状态 const (