chore: add shafafiat page
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,20 @@
|
||||
const Shafafiat = require("../models/shafafiat");
|
||||
const Category = require("../models/Category");
|
||||
|
||||
module.exports.getAll = [
|
||||
async (req, res) => {
|
||||
try {
|
||||
const shafafiat = await Shafafiat.find({});
|
||||
const shafafCategory = await Category.findOne({ title: "شفافیت" });
|
||||
if (!shafafCategory)
|
||||
return res.status(404).json({
|
||||
message: "شفافیت یافت نشد",
|
||||
});
|
||||
|
||||
const shafafItems = await Category.find({
|
||||
parent: shafafCategory._id,
|
||||
});
|
||||
|
||||
return res.json({
|
||||
data: shafafiat,
|
||||
data: shafafItems,
|
||||
});
|
||||
} catch (error) {
|
||||
return res500(res, error.message);
|
||||
|
||||
Reference in New Issue
Block a user