修复在线修改定时任务多次执行时事务超时问题

This commit is contained in:
孟帅 2023-02-09 15:42:30 +08:00
parent 7153327b13
commit 7cf1b8ce8e
4 changed files with 17 additions and 7 deletions

View File

@ -139,7 +139,6 @@ func RefreshStatus(sysCron *entity.SysCron) (err error) {
if sysCron == nil { if sysCron == nil {
return return
} }
g.DumpWithType(sysCron)
if sysCron.Status == consts.StatusEnabled { if sysCron.Status == consts.StatusEnabled {
return Start(sysCron) return Start(sysCron)

View File

@ -18,11 +18,11 @@ import (
// AccessLog 访问日志 // AccessLog 访问日志
func (s *sHook) AccessLog(r *ghttp.Request) { func (s *sHook) AccessLog(r *ghttp.Request) {
var ( if r.IsFileRequest() {
ctx = r.Context() return
) }
// 没有上下文的请求不记录doc、favicon.ico等非功能类业务 var ctx = r.Context()
modelCtx := contexts.Get(ctx) modelCtx := contexts.Get(ctx)
if modelCtx == nil { if modelCtx == nil {
return return

View File

@ -60,6 +60,10 @@ func allow(memberId int64) bool {
// LastActive 更新用户最后活跃 // LastActive 更新用户最后活跃
func (s *sHook) LastActive(r *ghttp.Request) { func (s *sHook) LastActive(r *ghttp.Request) {
if r.IsFileRequest() {
return
}
var ( var (
ctx = r.Context() ctx = r.Context()
memberId = contexts.GetUserId(ctx) memberId = contexts.GetUserId(ctx)

View File

@ -19,6 +19,7 @@ import (
"hotgo/internal/model/input/form" "hotgo/internal/model/input/form"
"hotgo/internal/model/input/sysin" "hotgo/internal/model/input/sysin"
"hotgo/internal/service" "hotgo/internal/service"
"hotgo/utility/simple"
"hotgo/utility/validate" "hotgo/utility/validate"
"strings" "strings"
) )
@ -90,7 +91,10 @@ func (s *sSysCron) Edit(ctx context.Context, in sysin.CronEditInp) (err error) {
return err return err
} }
return crons.RefreshStatus(&in.SysCron) simple.SafeGo(ctx, func(ctx context.Context) {
crons.RefreshStatus(&in.SysCron)
})
return
}) })
return return
} }
@ -136,7 +140,10 @@ func (s *sSysCron) Status(ctx context.Context, in sysin.CronStatusInp) (err erro
} }
models.Status = in.Status models.Status = in.Status
return crons.RefreshStatus(models) simple.SafeGo(ctx, func(ctx context.Context) {
crons.RefreshStatus(models)
})
return
}) })
return return
} }