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


router.post(
  "/designation-permission/upsert",
  authenticate,
  authorize(["admin", "superadmin"]),
  (req, res) => {
    /*
      #swagger.tags = ['Designation Permission']
      #swagger.summary = 'Create or Update permissions for a designation'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    permissionController.upsertDesignationPermission(req, res);
  }
);


router.get("/role/:role",
  authenticate,
  authorize(["admin", "superadmin"]),
  (req, res) => {
    /*
      #swagger.tags = ['Designation Permission']
      #swagger.summary = 'Get permissions by designationId'
      #swagger.security = [{ "bearerAuth": [] }]
    */
    permissionController.getPermissionByRole(req, res);
  }
);


module.exports = router;