/**
 * @openapi
 * /api/guardian_students:
 *   get:
 *     tags: [GuardianStudents]
 *     summary: List guardian↔student links (filter by studentId or guardianId)
 *     description: Requires READ_GUARDIAN_STUDENTS.
 *     responses:
 *       200: { description: List payload. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 *   post:
 *     tags: [GuardianStudents]
 *     summary: Link a guardian to a student (idempotent)
 *     description: Requires CREATE_GUARDIAN_STUDENTS.
 *     responses:
 *       200: { description: Linked. }
 *       400: { $ref: '#/components/responses/ValidationError' }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 * /api/guardian_students/{id}:
 *   delete:
 *     tags: [GuardianStudents]
 *     summary: Remove a guardian↔student link
 *     description: Requires DELETE_GUARDIAN_STUDENTS.
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema: { type: string, format: uuid }
 *     responses:
 *       200: { description: Removed. }
 *       403: { $ref: '#/components/responses/ForbiddenError' }
 */
import express from 'express';
import { wrapAsync } from '@/api/http/request';
import permissions from '@/middlewares/check-permissions';
import * as guardianStudents from '@/api/controllers/guardian_students.controller';

const router = express.Router();

router.get(
  '/',
  permissions.checkPermissions('READ_GUARDIAN_STUDENTS'),
  wrapAsync(guardianStudents.list),
);
router.post(
  '/',
  permissions.checkPermissions('CREATE_GUARDIAN_STUDENTS'),
  wrapAsync(guardianStudents.link),
);
router.delete(
  '/:id',
  permissions.checkPermissions('DELETE_GUARDIAN_STUDENTS'),
  wrapAsync(guardianStudents.unlink),
);

export default router;
