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

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

module.exports = router;
