mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
remove id field in every form struct, fix cron & ddns db (#11)
This commit is contained in:
parent
3efbf9cce1
commit
a1bac6e525
@ -188,5 +188,6 @@ func batchDeleteCron(c *gin.Context) (any, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
singleton.OnDeleteCron(cr)
|
singleton.OnDeleteCron(cr)
|
||||||
|
singleton.UpdateCronList()
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,15 @@ type Cron struct {
|
|||||||
ServersRaw string `json:"-"`
|
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 {
|
func (c *Cron) AfterFind(tx *gorm.DB) error {
|
||||||
return utils.Json.Unmarshal([]byte(c.ServersRaw), &c.Servers)
|
return utils.Json.Unmarshal([]byte(c.ServersRaw), &c.Servers)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type CronForm struct {
|
type CronForm struct {
|
||||||
ID uint64 `json:"id,omitempty"`
|
|
||||||
TaskType uint8 `json:"task_type,omitempty" default:"0"` // 0:计划任务 1:触发任务
|
TaskType uint8 `json:"task_type,omitempty" default:"0"` // 0:计划任务 1:触发任务
|
||||||
Name string `json:"name,omitempty" minLength:"1"`
|
Name string `json:"name,omitempty" minLength:"1"`
|
||||||
Scheduler string `json:"scheduler,omitempty"`
|
Scheduler string `json:"scheduler,omitempty"`
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/naiba/nezha/pkg/utils"
|
"github.com/naiba/nezha/pkg/utils"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
@ -50,8 +48,5 @@ func (d *DDNSProfile) BeforeSave(tx *gorm.DB) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DDNSProfile) AfterFind(tx *gorm.DB) error {
|
func (d *DDNSProfile) AfterFind(tx *gorm.DB) error {
|
||||||
if d.DomainsRaw != "" {
|
return utils.Json.Unmarshal([]byte(d.DomainsRaw), &d.Domains)
|
||||||
d.Domains = strings.Split(d.DomainsRaw, ",")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user