import { cancelSystemJob, listSystemJobs, runSystemJob } from '../services/systemJobService.js';

export function index(req, res) {
  res.json(listSystemJobs());
}

export async function runNow(req, res) {
  const result = await runSystemJob(req.params.jobId, req.user.id);
  if (!result.ok) return res.status(409).json(result);
  res.json(result);
}

export function cancel(req, res) {
  const result = cancelSystemJob(req.params.jobId, req.user.id, req.body?.reason || '');
  if (!result.ok) return res.status(409).json(result);
  res.json(result);
}

