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

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

module.exports = router;
