haixunMaster/haixun-backend/internal/logic/job/create_job_schedule_logic.go

36 lines
961 B
Go
Raw Permalink Normal View History

2026-06-23 09:54:27 +00:00
package job
import (
"context"
domusecase "haixun-backend/internal/model/job/domain/usecase"
"haixun-backend/internal/svc"
"haixun-backend/internal/types"
)
type CreateJobScheduleLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateJobScheduleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateJobScheduleLogic {
return &CreateJobScheduleLogic{ctx: ctx, svcCtx: svcCtx}
}
func (l *CreateJobScheduleLogic) CreateJobSchedule(req *types.CreateJobScheduleReq) (*types.JobScheduleData, error) {
schedule, err := l.svcCtx.Job.CreateSchedule(l.ctx, domusecase.CreateScheduleRequest{
TemplateType: req.TemplateType,
Scope: req.Scope,
ScopeID: req.ScopeID,
Cron: req.Cron,
Timezone: req.Timezone,
PayloadTemplate: req.PayloadTemplate,
Enabled: req.Enabled,
})
if err != nil {
return nil, err
}
data := toJobScheduleData(schedule)
return &data, nil
}