const express = require('express');
const router = express.Router();
const coursController = require('../controllers/coursController');

/**
 * @swagger
 * /cours:
 *   get:
 *     summary: Get all cours
 *     tags: [Cours]
 *     responses:
 *       200:
 *         description: List of cours
 */
router.get('/', coursController.getAllCours);

/**
 * @swagger
 * /cours/{id}:
 *   get:
 *     summary: Get a cours by ID
 *     tags: [Cours]
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema: { type: integer }
 *     responses:
 *       200:
 *         description: Cours found
 */
router.get('/:id', coursController.getCoursById);

/**
 * @swagger
 * /cours:
 *   post:
 *     summary: Add new cours
 *     tags: [Cours]
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name: { type: string }
 *               description: { type: string }
 *     responses:
 *       201:
 *         description: Cours added
 */
router.post('/', coursController.createCours);

/**
 * @swagger
 * /cours/{id}:
 *   put:
 *     summary: Update a cours
 *     tags: [Cours]
 *     parameters:
 *       - in: path
 *         name: id
 *         schema: { type: integer }
 *         required: true
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name: { type: string }
 *               description: { type: string }
 *     responses:
 *       200:
 *         description: Cours updated
 */
router.put('/:id', coursController.updateCours);

/**
 * @swagger
 * /cours/{id}:
 *   delete:
 *     summary: Delete a cours
 *     tags: [Cours]
 *     parameters:
 *       - in: path
 *         name: id
 *         schema: { type: integer }
 *         required: true
 *     responses:
 *       204:
 *         description: Deleted
 */
router.delete('/:id', coursController.deleteCours);

module.exports = router;
