🔧 **fix(model, controller): robust serialization for ChannelInfo & correct Vertex-AI key storage**

Summary
1. **model/channel.go**
   • Replaced the pointer-only `Value()` with a value-receiver implementation
   • GORM can now marshal both `ChannelInfo` and `*ChannelInfo`, eliminating
     `unsupported type model.ChannelInfo` runtime error.

2. **controller/channel.go**
   • Refactored `getVertexArrayKeys()` – every element is now
     - passed through `json.Marshal` when not already a string
     - trimmed & validated before insertion
   • Guarantees each service-account key is persisted as a **pure JSON string**
     instead of the previous `map[...]` dump.

Result
• Channel creation / update succeeds without SQL driver errors.
• Vertex-AI batch & multi-key uploads are stored in canonical JSON, ready for
  downstream SDKs to consume.
This commit is contained in:
t0ng7u
2025-07-07 01:31:41 +08:00
parent 870cdd5a56
commit f1856fe4d2
2 changed files with 14 additions and 4 deletions

View File

@@ -53,8 +53,8 @@ type ChannelInfo struct {
}
// Value implements driver.Valuer interface
func (c *ChannelInfo) Value() (driver.Value, error) {
return common.EncodeJson(c)
func (c ChannelInfo) Value() (driver.Value, error) {
return common.EncodeJson(&c)
}
// Scan implements sql.Scanner interface