import type { Request, Response } from 'express';
import { paramStr } from '@/api/http/request';
import AudioFilesService from '@/services/audio_files';

export async function list(req: Request, res: Response): Promise<void> {
  const payload = await AudioFilesService.list(req.query, req.currentUser);
  res.status(200).send(payload);
}

export async function create(req: Request, res: Response): Promise<void> {
  const payload = await AudioFilesService.create(req.body.data, req.currentUser);
  res.status(200).send(payload);
}

export async function update(req: Request, res: Response): Promise<void> {
  const payload = await AudioFilesService.update(
    paramStr(req.params.id),
    req.body.data,
    req.currentUser,
  );
  res.status(200).send(payload);
}

export async function remove(req: Request, res: Response): Promise<void> {
  await AudioFilesService.remove(paramStr(req.params.id), req.currentUser);
  res.status(200).send(true);
}
