const express = require("express");
const router = express.Router();
const authorize = require("../../../../../middlewares/authorize-sapps");
const departmentService = require("./department.service");

router.post("/get-departments", authorize(), getDepartments);
router.post("/get-option-departments", authorize(), getOptionDepartments);
router.post("/import-all", authorize(), importAll);

module.exports = router;

function getDepartments(req, res, next) {
	departmentService
		.getDepartments(req.body)
		.then((result) => res.json(result))
		.catch(next);
}

function getOptionDepartments(req, res, next) {
	departmentService
		.getOptionDepartments(req.body)
		.then((result) => res.json(result))
		.catch(next);
}

function importAll(req, res, next) {
	departmentService
		.importAll(req.body)
		.then((result) => res.json(result))
		.catch(next);
}
