const express = require("express");
const router = express.Router();
const specializationController = require("../controllers/admin/specializationController");
const authenticate = require("../middlewares/authenticate");
const authorize = require("../middlewares/authorize");

/**
 * @swagger
 * tags:
 *   name: Specializations
 *   description: Doctor specialization management APIs
 */

// CREATE specialization (admin only)
router.post("/create", authenticate, authorize("admin"), (req, res) => {
  /* 
    #swagger.tags = ['Specializations']
    #swagger.summary = 'Create a new specialization'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['body'] = {
      in: 'body',
      description: 'Specialization details including orgId',
      required: true,
      schema: { name: "Cardiology", orgId: "64f5a2d8c9e4b3a1f0a12345" }
    }
  */
  specializationController.createSpecialization(req, res);
});

// GET all specializations (admin + manager allowed)
router.get("/get/all", authenticate, authorize(["admin", "manager", "doctor"]), (req, res) => {
  /* 
    #swagger.tags = ['Specializations']
    #swagger.summary = 'Get all specializations'
    #swagger.security = [{ "bearerAuth": [] }]
  */
  specializationController.getSpecializations(req, res);  
});

// GET specialization by ID (all logged in users)
router.get("/get/:id", authenticate, (req, res) => {
  /* 
    #swagger.tags = ['Specializations']
    #swagger.summary = 'Get specialization by ID'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { description: 'Specialization ID', required: true }
  */
  specializationController.getSpecializationById(req, res);
});

// UPDATE specialization (admin only)
router.put("/update/:id", authenticate, authorize("admin"), (req, res) => {
  /* 
    #swagger.tags = ['Specializations']
    #swagger.summary = 'Update specialization by ID'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { description: 'Specialization ID', required: true }
    #swagger.parameters['body'] = {
      in: 'body',
      description: 'Update data (name, status)',
      required: true,
      schema: { 
        name: "Neurology",
        status: true 
      }
    }
  */
  specializationController.updateSpecialization(req, res);
});

// DELETE specialization (admin only)
router.delete("/delete/:id", authenticate, authorize("admin"), (req, res) => {
  /* 
    #swagger.tags = ['Specializations']
    #swagger.summary = 'Delete specialization by ID'
    #swagger.security = [{ "bearerAuth": [] }]
    #swagger.parameters['id'] = { description: 'Specialization ID', required: true }
  */
  specializationController.deleteSpecialization(req, res);
});

module.exports = router;
