// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package job

import (
	"context"

	"haixun-backend/internal/svc"
	"haixun-backend/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CheckWorkerJobCancelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCheckWorkerJobCancelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckWorkerJobCancelLogic {
	return &CheckWorkerJobCancelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CheckWorkerJobCancelLogic) CheckWorkerJobCancel(req *types.WorkerJobReq) (resp *types.WorkerCancelCheckData, err error) {
	cancelled, err := l.svcCtx.Job.IsCancelRequested(l.ctx, req.ID)
	return &types.WorkerCancelCheckData{Cancelled: cancelled}, err
}
