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

  /**
   * @swagger
   * tags:
   *   name: Departments
   *   description: Department management APIs
   */

  // CREATE department (admin only)
  router.post("/create", authenticate, authorize("admin"), (req, res) => {
    /* 
      #swagger.tags = ['Departments']
      #swagger.summary = 'Create a new department'
      #swagger.security = [{ "bearerAuth": [] }]
      #swagger.parameters['body'] = {
        in: 'body',
        description: 'Department details including orgId',
        required: true,
        schema: { deptName: "IT Department", orgId: "64f5a2d8c9e4b3a1f0a12345" }
      }
    */
    deptController.createDept(req, res);
  });

  // GET all departments (admin + manager allowed)
  router.get("/get/all", authenticate, (req, res) => {
    /* 
      #swagger.tags = ['Departments']
      #swagger.summary = 'Get all departments'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    deptController.getDepts(req, res);
  });

  // GET department by ID (all logged in users)
  router.get("/get/:id", authenticate, (req, res) => {
    /* 
      #swagger.tags = ['Departments']
      #swagger.summary = 'Get a department by ID'
      #swagger.security = [{ "bearerAuth": [] }]
      #swagger.parameters['id'] = { description: 'Department ID', required: true }
    */
    deptController.getDeptById(req, res);
  });

  // UPDATE department (admin only)
  router.put("/update/:id", authenticate, authorize("admin"), (req, res) => {
    /* 
      #swagger.tags = ['Departments']
      #swagger.summary = 'Update a department by ID'
      #swagger.security = [{ "bearerAuth": [] }]
      #swagger.parameters['id'] = { description: 'Department ID', required: true }
      #swagger.parameters['body'] = {
        in: 'body',
        description: 'Update data (deptName, status)',
        required: true,
        schema: { 
          deptName: "HR Department",
          status: true 
        }
      }
    */
    deptController.updateDept(req, res);
  });


  // DELETE department (admin only)
  router.delete("/delete/:id", authenticate, authorize("admin"), (req, res) => {
    /* 
      #swagger.tags = ['Departments']
      #swagger.summary = 'Delete a department by ID'
      #swagger.security = [{ "bearerAuth": [] }]
      #swagger.parameters['id'] = { description: 'Department ID', required: true }
    */
    deptController.deleteDept(req, res);
  });

  module.exports = router;
