status
This commit is contained in:
parent
4317466db1
commit
79f0c312e1
@ -203,3 +203,31 @@ export const getSelfDirectory = async (req, res) => {
|
||||
}
|
||||
|
||||
};
|
||||
export const setStatus = async (req, res) => {
|
||||
try {
|
||||
const id = req.params.id;
|
||||
if (!id) return res.status(400).json({ message: 'id is required' });
|
||||
|
||||
const directory = await directoryModel.findById(req.params.id)
|
||||
|
||||
if (!directory)
|
||||
return res
|
||||
.status(404)
|
||||
.json({ message: 'Did not find directory by given id' });
|
||||
if (directory.status === "true") {
|
||||
directory.status = false
|
||||
}
|
||||
else {
|
||||
directory.status = true
|
||||
}
|
||||
|
||||
directory.save();
|
||||
// console.log(directory)
|
||||
res.status(200).json(directory);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
res.status(500).json({
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -5,10 +5,12 @@ import {
|
||||
updateDirectory,
|
||||
deleteOneDirectory,
|
||||
getOneDirectory,
|
||||
getSelfDirectory
|
||||
getSelfDirectory,
|
||||
setStatus
|
||||
|
||||
} from "../controllers/directoryController.js"
|
||||
const router = express.Router();
|
||||
import { isAuthenticatedUser } from "../middlewares/auth.js"
|
||||
import { isAuthenticatedUser, authorizeRoles } from "../middlewares/auth.js"
|
||||
|
||||
|
||||
import multer from 'multer'
|
||||
@ -29,7 +31,9 @@ router.route("/directory/getAll/").get(getAllDirectory)
|
||||
router.route("/directory/getOne/:id").get(getOneDirectory)
|
||||
router.route("/directory/update/:id").put(isAuthenticatedUser, updateDirectory);
|
||||
router.route("/directory/delete/:id").delete(isAuthenticatedUser, deleteOneDirectory);
|
||||
router.route("/directory/self/:id").get(isAuthenticatedUser, getSelfDirectory);
|
||||
//get Directory from user id
|
||||
router.route("/directory/self/:id").get(isAuthenticatedUser, getSelfDirectory);
|
||||
router.route("/directory/admin/setStatus/:id").get(isAuthenticatedUser, authorizeRoles('admin'), setStatus);
|
||||
|
||||
|
||||
export default router;
|
BIN
tmp/tmp-1-1659946125472
Normal file
BIN
tmp/tmp-1-1659946125472
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1659946158121
Normal file
BIN
tmp/tmp-2-1659946158121
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-3-1659946272271
Normal file
BIN
tmp/tmp-3-1659946272271
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-4-1659946422398
Normal file
BIN
tmp/tmp-4-1659946422398
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 MiB |
BIN
tmp/tmp-5-1659946527577
Normal file
BIN
tmp/tmp-5-1659946527577
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 MiB |
Loading…
Reference in New Issue
Block a user