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

router.post("/create", authorize(), (req, res, next) => assetCategoryService.create(req.body).then((r) => res.json(r)).catch(next));
router.post("/", authorize(), (req, res, next) => assetCategoryService.getAll(req.body).then((r) => res.json(r)).catch(next));
router.post("/option", authorize(), (req, res, next) => assetCategoryService.option(req.body).then((r) => res.json(r)).catch(next));
router.get("/count", authorize(), (req, res, next) => assetCategoryService.count(req.query).then((r) => res.json(r)).catch(next));
router.put("/:id", authorize(), (req, res, next) => assetCategoryService.update(req.params.id, req.body).then((r) => res.json(r)).catch(next));
router.put("/enabled/:id", authorize(), (req, res, next) => assetCategoryService.enabled(req.params.id, req.body).then((r) => res.json(r)).catch(next));
router.delete("/:id", authorize(), (req, res, next) => assetCategoryService.delete(req.params.id).then((r) => res.json(r)).catch(next));

module.exports = router;
