remove id field in every form struct, fix cron & ddns db (#11)

This commit is contained in:
UUBulb
2024-11-19 23:34:56 +08:00
committed by GitHub
parent 3efbf9cce1
commit a1bac6e525
4 changed files with 11 additions and 7 deletions

View File

@@ -33,6 +33,15 @@ type Cron struct {
ServersRaw string `json:"-"`
}
func (c *Cron) BeforeSave(tx *gorm.DB) error {
if data, err := utils.Json.Marshal(c.Servers); err != nil {
return err
} else {
c.ServersRaw = string(data)
}
return nil
}
func (c *Cron) AfterFind(tx *gorm.DB) error {
return utils.Json.Unmarshal([]byte(c.ServersRaw), &c.Servers)
}