mirror of
https://github.com/xinliangnote/go-gin-api.git
synced 2024-04-21 12:31:46 +00:00
22 lines
545 B
Go
22 lines
545 B
Go
package cron
|
|
|
|
import (
|
|
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
|
|
"github.com/xinliangnote/go-gin-api/internal/repository/mysql"
|
|
"github.com/xinliangnote/go-gin-api/internal/repository/mysql/cron_task"
|
|
)
|
|
|
|
func (s *service) Execute(ctx core.Context, id int32) (err error) {
|
|
qb := cron_task.NewQueryBuilder()
|
|
qb.WhereId(mysql.EqualPredicate, id)
|
|
info, err := qb.QueryOne(s.db.GetDbR().WithContext(ctx.RequestContext()))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
info.Spec = "手动执行"
|
|
go s.cronServer.AddJob(info)()
|
|
|
|
return nil
|
|
}
|