mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
⚡️ pprof 性能调优 / 计划任务支持秒级
This commit is contained in:
@@ -267,19 +267,22 @@ func (ma *memberAPI) addOrEditCron(c *gin.Context) {
|
||||
cr.Cover = cf.Cover
|
||||
err = json.Unmarshal([]byte(cf.ServersRaw), &cr.Servers)
|
||||
}
|
||||
if err == nil {
|
||||
_, err = cron.ParseStandard(cr.Scheduler)
|
||||
}
|
||||
tx := dao.DB.Begin()
|
||||
if err == nil {
|
||||
if cf.ID == 0 {
|
||||
err = dao.DB.Create(&cr).Error
|
||||
err = tx.Create(&cr).Error
|
||||
} else {
|
||||
err = dao.DB.Save(&cr).Error
|
||||
err = tx.Save(&cr).Error
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
cr.CronID, err = dao.Cron.AddFunc(cr.Scheduler, dao.CronTrigger(cr))
|
||||
}
|
||||
if err == nil {
|
||||
err = tx.Commit().Error
|
||||
} else {
|
||||
tx.Rollback()
|
||||
}
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, model.Response{
|
||||
Code: http.StatusBadRequest,
|
||||
|
||||
Reference in New Issue
Block a user