6906 lines
230 KiB
JavaScript
6906 lines
230 KiB
JavaScript
const { Router } = require("express");
|
|
const router = Router();
|
|
const { hasPermission, hasSubPermission } = require("../authentication");
|
|
/////////////////////////////////////////////////////////// controllers
|
|
const categoryController = require("../controllers/categoryController");
|
|
const userController = require("../controllers/userController");
|
|
const newsController = require("../controllers/newsController");
|
|
const newsFileController = require("../controllers/newsFileController");
|
|
const dynamicController = require("../controllers/dynamicController");
|
|
const pdfController = require("../controllers/pdfController");
|
|
const adminLogController = require("../controllers/adminLogController");
|
|
|
|
const contentController = require("../controllers/contentController");
|
|
const pollController = require("../controllers/pollController");
|
|
const yearBannerController = require("../controllers/yearBannerController");
|
|
const counterDayController = require("../controllers/counterDayController");
|
|
const galleryController = require("../controllers/galleryController");
|
|
const permissionsController = require("../controllers/permissionsController");
|
|
const portalController = require("../controllers/portalController");
|
|
const commentController = require("../controllers/commentController");
|
|
const linksController = require("../controllers/linksController");
|
|
const sliderController = require("../controllers/sliderController");
|
|
const homeController = require("../controllers/homeController");
|
|
const occasionController = require("../controllers/occasionController");
|
|
const electionController = require("../controllers/electionController");
|
|
const dataBackupController = require("../controllers/dataBackupController");
|
|
const meetingController = require("../controllers/meetingController");
|
|
|
|
////////////////////////////////////////////////////admin login log
|
|
router.get("/logs", adminLogController.getAdminLoginLogs);
|
|
|
|
//////////////////////////////////////////////////// Permission
|
|
/**
|
|
* @swagger
|
|
* /admin/permissions:
|
|
* get:
|
|
* summary: Get all permissions
|
|
* description: Retrieves all available permissions.
|
|
* tags:
|
|
* - Admin
|
|
* responses:
|
|
* '200':
|
|
* description: Permissions retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Permission name.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.get("/permissions", permissionsController.getAll);
|
|
// Portals
|
|
/**
|
|
* @swagger
|
|
* /admin/portals:
|
|
* get:
|
|
* summary: Get portals based on user's permissions
|
|
* description: Retrieves portals based on the user's permissions.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Portals retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* value:
|
|
* type: string
|
|
* description: Portal value.
|
|
* label:
|
|
* type: string
|
|
* description: Portal label.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.get("/portals", portalController.getAll);
|
|
|
|
router.post("/setScope/:id", permissionsController.SetPermission);
|
|
/////////////// home controller
|
|
/**
|
|
* @swagger
|
|
* /admin/homePageSettings:
|
|
* get:
|
|
* summary: Get home page settings
|
|
* description: Retrieves home page settings based on the user's permissions and portal.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal for which the home page settings are requested. Defaults to 'ostandari'.
|
|
* responses:
|
|
* '200':
|
|
* description: Home page settings retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* s2:
|
|
* type: string
|
|
* description: Setting value for section 2.
|
|
* s3:
|
|
* type: string
|
|
* description: Setting value for section 3.
|
|
* s4:
|
|
* type: string
|
|
* description: Setting value for section 4.
|
|
* s5:
|
|
* type: array
|
|
* description: Setting value for section 5.
|
|
* items:
|
|
* type: string
|
|
* s6:
|
|
* type: string
|
|
* description: Setting value for section 6.
|
|
* s2Side:
|
|
* type: string
|
|
* description: Setting value for section 2 side.
|
|
* s3Side:
|
|
* type: string
|
|
* description: Setting value for section 3 side.
|
|
* s4Side:
|
|
* type: string
|
|
* description: Setting value for section 4 side.
|
|
* s5Side:
|
|
* type: string
|
|
* description: Setting value for section 5 side.
|
|
* s6Side:
|
|
* type: string
|
|
* description: Setting value for section 6 side.
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to access the requested data.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the user does not have permission to access the requested data.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.get("/homePageSettings", homeController.getHomePage);
|
|
// Home Page Setting
|
|
/**
|
|
* @swagger
|
|
* /admin/homePageSettings:
|
|
* post:
|
|
* summary: Update home page settings
|
|
* description: Updates home page settings based on the user's permissions and portal.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal for which the home page settings are to be updated. Defaults to 'ostandari'.
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* s2:
|
|
* type: string
|
|
* description: Setting value for section 2.
|
|
* s3:
|
|
* type: string
|
|
* description: Setting value for section 3.
|
|
* s4:
|
|
* type: string
|
|
* description: Setting value for section 4.
|
|
* s5:
|
|
* type: array
|
|
* description: Setting value for section 5.
|
|
* items:
|
|
* type: string
|
|
* s6:
|
|
* type: string
|
|
* description: Setting value for section 6.
|
|
* s2Side:
|
|
* type: string
|
|
* description: Setting value for section 2 side.
|
|
* s3Side:
|
|
* type: string
|
|
* description: Setting value for section 3 side.
|
|
* s4Side:
|
|
* type: string
|
|
* description: Setting value for section 4 side.
|
|
* s5Side:
|
|
* type: string
|
|
* description: Setting value for section 5 side.
|
|
* s6Side:
|
|
* type: string
|
|
* description: Setting value for section 6 side.
|
|
* responses:
|
|
* '200':
|
|
* description: Home page settings updated successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message indicating that the home page settings were updated successfully.
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to update the home page settings for the requested portal.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the user does not have permission to update the home page settings.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.post("/homePageSettings", homeController.updateHomePage);
|
|
// Change Show InHome
|
|
/**
|
|
* @swagger
|
|
* /admin/changeShowInHome:
|
|
* put:
|
|
* summary: Change show in home setting
|
|
* description: Changes the show in home setting for a specific item (e.g., news, newsFile, gallery) based on its ID and model name.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* id:
|
|
* type: string
|
|
* description: The ID of the item to update.
|
|
* modelName:
|
|
* type: string
|
|
* enum: [news, newsFile, gallery]
|
|
* description: The model name of the item (e.g., news, newsFile, gallery).
|
|
* responses:
|
|
* '200':
|
|
* description: Show in home setting changed successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* id:
|
|
* type: string
|
|
* description: The ID of the item that was updated.
|
|
* modelName:
|
|
* type: string
|
|
* description: The model name of the item that was updated.
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: The updated show in home setting.
|
|
* '404':
|
|
* description: Not found. Indicates that the item with the specified ID was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating that the item with the specified ID was not found.
|
|
* '422':
|
|
* description: Unprocessable entity. Indicates that the request body contains validation errors.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Object containing validation errors.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.put("/changeShowInHome", homeController.changeShowInHome);
|
|
// Get all Show In Home
|
|
/**
|
|
* @swagger
|
|
* /admin/getAllShowInHomeFalse:
|
|
* get:
|
|
* summary: Get items with showInHome set to false
|
|
* description: Retrieves all items (e.g., news, news files, gallery items) with the showInHome setting set to false for a specific portal.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal name to filter the items. Defaults to 'ostandari' if not provided.
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with items having showInHome set to false.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* news:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/News'
|
|
* description: Array of news items with showInHome set to false.
|
|
* newsFile:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* description: Array of news files with showInHome set to false.
|
|
* media:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* description: Array of gallery items with showInHome set to false.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.get("/getAllShowInHome", homeController.getAllShowInHomeFalse);
|
|
|
|
//////////////// category policy
|
|
// router.use('/category', );
|
|
|
|
//////////////// category
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/category:
|
|
* post:
|
|
* summary: Add a new category
|
|
* description: Add a new category with various properties such as title, parent, navigation index, priority, and more.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewCategory'
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the newly added category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to add the category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the reason for the forbidden access.
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that there are validation errors in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Object containing validation errors.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.post(
|
|
"/category",
|
|
hasPermission("categories"),
|
|
categoryController.addCategory
|
|
);
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/category/{id}:
|
|
* put:
|
|
* summary: Update a category
|
|
* description: Update an existing category with new data.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* description: ID of the category to update
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/UpdateCategory'
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the updated category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to update the category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the reason for the forbidden access.
|
|
* '404':
|
|
* description: Not Found. Indicates that the category with the specified ID was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating that the category was not found.
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that there are validation errors in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Object containing validation errors.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.put(
|
|
"/category/:id",
|
|
hasPermission("categories"),
|
|
categoryController.updateCategory
|
|
);
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/category/{id}:
|
|
* delete:
|
|
* summary: Delete a category
|
|
* description: Delete an existing category by ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* description: ID of the category to delete
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the deleted category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to delete the category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the reason for the forbidden access.
|
|
* '404':
|
|
* description: Not Found. Indicates that the category with the specified ID was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating that the category was not found.
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that there are validation errors in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Object containing validation errors.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.delete(
|
|
"/category/:id",
|
|
hasPermission("categories"),
|
|
categoryController.deletOneCategory
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/category/permissions:
|
|
* get:
|
|
* summary: Get categories for permissions
|
|
* description: Retrieve categories for setting permissions, optionally filtered by type.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: query
|
|
* name: type
|
|
* description: Type of the categories to filter (optional)
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the categories for permissions.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.get("/category/permissions", categoryController.permissions);
|
|
/**
|
|
* @swagger
|
|
* /admin/category/getParent:
|
|
* get:
|
|
* summary: Get parent categories
|
|
* description: Retrieve parent categories, optionally filtered by type.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: query
|
|
* name: type
|
|
* description: Type of the categories to filter (optional)
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the parent categories.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.get("/category/getParent", categoryController.getParent);
|
|
/**
|
|
* @swagger
|
|
* /admin/category:
|
|
* get:
|
|
* summary: Get all categories
|
|
* description: Retrieve all categories, optionally filtered by user permissions and portal.
|
|
* tags:
|
|
* - Admin
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the list of categories.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
|
|
router.get("/category", hasPermission("categories"), categoryController.getAll);
|
|
// router.get('/category/getIndex' , hasPermission('categories') , categoryController.getNavIndex);
|
|
/**
|
|
* @swagger
|
|
* /admin/category/{id}:
|
|
* get:
|
|
* summary: Get one category by ID
|
|
* description: Retrieve a category by its ID, ensuring the user has access to the category based on their permissions.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The ID of the category to retrieve.
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the category data.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have access to the requested category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the user does not have permission to access the category.
|
|
* '404':
|
|
* description: Not Found. Indicates that the category was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the category was not found.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.get(
|
|
"/category/:id",
|
|
hasPermission("categories"),
|
|
categoryController.getOneCategory
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/category/search:
|
|
* post:
|
|
* summary: Search categories
|
|
* description: Search for categories by title using a search term. The search is case-insensitive.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: The search term to look for in category titles.
|
|
* responses:
|
|
* '200':
|
|
* description: Successful response with the list of matching categories.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Category'
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.post(
|
|
"/category/search",
|
|
hasPermission("categories"),
|
|
categoryController.search
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/category/termsFile/{categoryId}:
|
|
* post:
|
|
* summary: Add terms file to a category
|
|
* description: Add a PDF terms file to a specified category by providing the title and file.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: categoryId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The ID of the category to which the terms file will be added.
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* termsTitle:
|
|
* type: string
|
|
* description: The title of the terms file.
|
|
* file:
|
|
* type: string
|
|
* format: binary
|
|
* description: The PDF file to be uploaded.
|
|
* responses:
|
|
* '200':
|
|
* description: Terms file successfully added to the category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* '422':
|
|
* description: Validation error. Indicates that the input data is invalid or the file is missing/invalid format.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* properties:
|
|
* file:
|
|
* type: object
|
|
* properties:
|
|
* msg:
|
|
* type: string
|
|
* description: Error message indicating the validation issue.
|
|
* '404':
|
|
* description: Category not found. Indicates that the specified category ID does not exist.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the category was not found.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.post(
|
|
"/category/termsFile/:categoryId",
|
|
hasPermission("categories"),
|
|
categoryController.addTermsFileToCategory
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/category/termsFile/{fileId}:
|
|
* delete:
|
|
* summary: Remove terms file from a category
|
|
* description: Delete a terms file from a specified category by providing the file ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: fileId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The ID of the terms file to be removed.
|
|
* responses:
|
|
* '200':
|
|
* description: Terms file successfully removed from the category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* '404':
|
|
* description: Terms file or category not found. Indicates that the specified file ID or category does not exist.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the terms file or category was not found.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.delete(
|
|
"/category/termsFile/:fileId",
|
|
hasPermission("categories"),
|
|
categoryController.removeTermsFileFromCategory
|
|
);
|
|
// router.delete('/category' , categoryController.deleteAllCategory);
|
|
|
|
//////////////// users policy
|
|
// router.use('/user', hasPermission('users'));
|
|
|
|
/////////////// users
|
|
/**
|
|
* @swagger
|
|
* /admin/user/registerAdmin:
|
|
* post:
|
|
* summary: Register a new admin
|
|
* description: Register a new admin user with the provided details.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* required:
|
|
* - firstName
|
|
* - lastName
|
|
* - username
|
|
* - password
|
|
* - permissions
|
|
* - portals
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* description: First name of the admin
|
|
* lastName:
|
|
* type: string
|
|
* description: Last name of the admin
|
|
* username:
|
|
* type: string
|
|
* description: Username of the admin
|
|
* password:
|
|
* type: string
|
|
* description: Password for the admin account
|
|
* email:
|
|
* type: string
|
|
* description: Email address of the admin
|
|
* mobileNumber:
|
|
* type: string
|
|
* description: Mobile number of the admin
|
|
* permissions:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: List of permissions for the admin
|
|
* specialPermissions:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: List of special permissions for the admin
|
|
* portals:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: List of portals the admin has access to
|
|
* registration_done:
|
|
* type: boolean
|
|
* description: Whether the registration process is completed
|
|
* profilePic:
|
|
* type: string
|
|
* format: binary
|
|
* description: Profile picture of the admin
|
|
* responses:
|
|
* '201':
|
|
* description: Admin successfully registered.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* '422':
|
|
* description: Validation error. Indicates that one or more of the provided fields are invalid.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Detailed validation errors.
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the internal server error.
|
|
*/
|
|
router.post(
|
|
"/user/registerAdmin",
|
|
hasPermission("users"),
|
|
userController.registerAdmin
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/user/changeStatus/{id}:
|
|
* put:
|
|
* summary: Change the status of a user
|
|
* description: Toggle the registration status of a user.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the user to change the status for
|
|
* responses:
|
|
* '200':
|
|
* description: User status successfully changed.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "عملیات با موفقیت انجام شد" }
|
|
* '404':
|
|
* description: User not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "کاربر مورد نظر پیدا نشد" }
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
*/
|
|
router.put(
|
|
"/user/changeStatus/:id",
|
|
hasPermission("users"),
|
|
userController.changeUserStatus
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/user/changePass/{id}:
|
|
* put:
|
|
* summary: Change the password of a user
|
|
* description: Allows an admin to change the password of a user.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the user whose password is to be changed
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* password:
|
|
* type: string
|
|
* example: new_password
|
|
* description: The new password for the user
|
|
* password_confirmation:
|
|
* type: string
|
|
* example: new_password
|
|
* description: Confirmation of the new password
|
|
* responses:
|
|
* '200':
|
|
* description: User password successfully changed.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "عملیات با موفقیت انجام شد" }
|
|
* '403':
|
|
* description: Forbidden. Indicates the current user is not allowed to change this user's password.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "شما نمی توانید رمز عبور این کاربر را تغییر دهید" }
|
|
* '404':
|
|
* description: User not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "کاربر مورد نظر پیدا نشد" }
|
|
* '422':
|
|
* description: Validation error. Indicates that the input data is invalid.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* example: { "password": { "msg": "طول رمز عبور باید حداقل 4 کاراکتر باشد" } }
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "مشکلی در اجرای درخواست شما بوجود امده است" }
|
|
*/
|
|
router.put(
|
|
"/user/changePass/:id",
|
|
hasPermission("users"),
|
|
userController.changePassword
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/user:
|
|
* get:
|
|
* summary: Retrieve a list of all users
|
|
* description: Fetches a paginated list of all non-private users.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* required: false
|
|
* description: Page number for pagination
|
|
* responses:
|
|
* '200':
|
|
* description: A paginated list of users.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/User'
|
|
* totalDocs:
|
|
* type: integer
|
|
* limit:
|
|
* type: integer
|
|
* totalPages:
|
|
* type: integer
|
|
* page:
|
|
* type: integer
|
|
* pagingCounter:
|
|
* type: integer
|
|
* hasPrevPage:
|
|
* type: boolean
|
|
* hasNextPage:
|
|
* type: boolean
|
|
* prevPage:
|
|
* type: integer
|
|
* nullable: true
|
|
* nextPage:
|
|
* type: integer
|
|
* nullable: true
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "مشکلی در گرفتن اطلاعات پیش آمده لطفا دوباره تلاش کنید" }
|
|
*/
|
|
router.get("/user", hasPermission("users"), userController.getAllUsers);
|
|
/**
|
|
* @swagger
|
|
* /admin/user/{id}:
|
|
* get:
|
|
* summary: Retrieve user details by admin
|
|
* description: Fetches details of a user by their ID, accessible by admin users.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the user to retrieve
|
|
* responses:
|
|
* '200':
|
|
* description: User details retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/User'
|
|
* '404':
|
|
* description: User not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "کاربر مورد نظر پیدا نشد" }
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: string
|
|
* example: { "message": "An error occurred while processing your request." }
|
|
*/
|
|
router.get("/user/:id", hasPermission("users"), userController.getUserByAdmin);
|
|
/**
|
|
* @swagger
|
|
* /admin/user/{id}:
|
|
* delete:
|
|
* summary: Delete a user by admin
|
|
* description: Deletes a user by their ID, accessible by admin users. Ensures that private users cannot be deleted.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the user to delete
|
|
* responses:
|
|
* '200':
|
|
* description: User deleted successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/User'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user is private and cannot be deleted.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "شما نمیتوانید این کاربر را حذف کنید"
|
|
* '404':
|
|
* description: User not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "کاربر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "An error occurred while processing your request."
|
|
*/
|
|
router.delete(
|
|
"/user/:id",
|
|
hasPermission("users"),
|
|
userController.deleteOneUser
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/user/{id}:
|
|
* put:
|
|
* summary: Update a user by admin
|
|
* description: Updates a user's information by their ID, accessible by admin users. Ensures that private users cannot be updated by regular users.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the user to update
|
|
* - in: formData
|
|
* name: firstName
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The user's first name
|
|
* - in: formData
|
|
* name: lastName
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The user's last name
|
|
* - in: formData
|
|
* name: mobileNumber
|
|
* schema:
|
|
* type: string
|
|
* description: The user's mobile number
|
|
* - in: formData
|
|
* name: permissions
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: The user's permissions
|
|
* - in: formData
|
|
* name: specialPermissions
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: The user's special permissions
|
|
* - in: formData
|
|
* name: portals
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: The user's portals
|
|
* - in: formData
|
|
* name: registration_done
|
|
* schema:
|
|
* type: boolean
|
|
* description: The user's registration status
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/User'
|
|
* responses:
|
|
* '200':
|
|
* description: User updated successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/User'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user is private and cannot be updated.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "شما نمیتوانید این کاربر را آپدیت کنید"
|
|
* '404':
|
|
* description: User not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "کاربر مورد نظر پیدا نشد"
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that there was an issue with the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* example: "فیلد نام الزامی است"
|
|
* lastName:
|
|
* type: string
|
|
* example: "فیلد نام خانوادگی الزامی است"
|
|
* ...
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "An error occurred while processing your request."
|
|
*/
|
|
router.put("/user/:id", hasPermission("users"), userController.updateUser);
|
|
/**
|
|
* @swagger
|
|
* /admin/user/search:
|
|
* post:
|
|
* summary: Search for users
|
|
* description: Searches for users based on various criteria such as name, email, phone, permissions, specialPermissions, portals, status, and username.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description: Name of the user
|
|
* email:
|
|
* type: string
|
|
* description: Email of the user
|
|
* phone:
|
|
* type: string
|
|
* description: Phone number of the user
|
|
* permissions:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Permissions of the user
|
|
* specialPermissions:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Special permissions of the user
|
|
* portals:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Portals of the user
|
|
* status:
|
|
* type: boolean
|
|
* description: Registration status of the user
|
|
* username:
|
|
* type: string
|
|
* description: Username of the user
|
|
* responses:
|
|
* '200':
|
|
* description: Users found successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/User'
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "An error occurred while processing your request."
|
|
*/
|
|
router.post("/user/search", hasPermission("users"), userController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/profile:
|
|
* get:
|
|
* summary: Get admin profile
|
|
* description: Retrieves the profile information of the authenticated admin user.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Admin profile retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/User'
|
|
* '404':
|
|
* description: Admin profile not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "کاربر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "مشکلی در اجرای درخواست شما بوجود امده است"
|
|
*/
|
|
router.get("/profile", userController.getProfile);
|
|
/**
|
|
* @swagger
|
|
* /admin/profile:
|
|
* put:
|
|
* summary: Update admin profile
|
|
* description: Updates the profile information of the authenticated admin user.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* lastName:
|
|
* type: string
|
|
* email:
|
|
* type: string
|
|
* mobileNumber:
|
|
* type: string
|
|
* profilePic:
|
|
* type: string
|
|
* required:
|
|
* - firstName
|
|
* - lastName
|
|
* responses:
|
|
* '200':
|
|
* description: Admin profile updated successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/User'
|
|
* '422':
|
|
* description: Validation error. Indicates that the request body did not pass the validation checks.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* '404':
|
|
* description: Admin profile not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "کاربر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "مشکلی در اجرای درخواست شما بوجود امده است"
|
|
*/
|
|
router.put("/profile", userController.updateProfile);
|
|
/**
|
|
* @swagger
|
|
* /admin/profile/changePass:
|
|
* put:
|
|
* summary: Change admin password
|
|
* description: Changes the password of the authenticated admin user.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* password:
|
|
* type: string
|
|
* password_confirmation:
|
|
* type: string
|
|
* required:
|
|
* - password
|
|
* - password_confirmation
|
|
* responses:
|
|
* '200':
|
|
* description: Admin password changed successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "ذخیره با موفقیت انجام شد."
|
|
* '422':
|
|
* description: Validation error. Indicates that the request body did not pass the validation checks.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* '404':
|
|
* description: Admin profile not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "کاربر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "مشکلی در اجرای درخواست شما بوجود امده است"
|
|
*/
|
|
router.put("/profile/changePass", userController.changePasswordProfile);
|
|
|
|
router.post("/book/add", pdfController.AddPDF);
|
|
|
|
router.get("/book/:id", pdfController.GetOne);
|
|
|
|
router.delete("/book/:id", pdfController.DeleteOne);
|
|
|
|
//////////////// news policy
|
|
router.use("/news", hasPermission("news"));
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/news:
|
|
* post:
|
|
* summary: Add news
|
|
* description: Add a new news article.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* leadTitle:
|
|
* type: string
|
|
* catId:
|
|
* type: string
|
|
* priority:
|
|
* type: boolean
|
|
* allowComment:
|
|
* type: boolean
|
|
* showInHome:
|
|
* type: boolean
|
|
* special:
|
|
* type: boolean
|
|
* notifications:
|
|
* type: boolean
|
|
* siteMap:
|
|
* type: boolean
|
|
* publish:
|
|
* type: boolean
|
|
* keywords:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* metaTagDesc:
|
|
* type: string
|
|
* modelType:
|
|
* type: string
|
|
* newsFileId:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: New news article added successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/News'
|
|
* '422':
|
|
* description: Validation error. Indicates that the request body did not pass the validation checks.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* '404':
|
|
* description: News file not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "پرونده خبری انتخاب شده وجود ندارد"
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "مشکلی در اجرای درخواست شما بوجود امده است"
|
|
*/
|
|
router.post("/news", newsController.addNews);
|
|
/**
|
|
* @swagger
|
|
* /admin/news/{id}:
|
|
* put:
|
|
* summary: Update news
|
|
* description: Update an existing news article.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the news article to update
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/News'
|
|
* responses:
|
|
* '200':
|
|
* description: Updated news article successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/News'
|
|
* '422':
|
|
* description: Validation error. Indicates that the request body did not pass the validation checks.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* '404':
|
|
* description: News article not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خبر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "مشکلی در اجرای درخواست شما بوجود امده است"
|
|
*/
|
|
router.put("/news/:id", newsController.updateNews);
|
|
/**
|
|
* @swagger
|
|
* /admin/news/{id}:
|
|
* delete:
|
|
* summary: Delete news
|
|
* description: Delete a news article by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the news article to delete
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: News article deleted successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/News'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to delete the news article.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "شما مجاز به حذف این خبر نمی باشید"
|
|
* '404':
|
|
* description: News article not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خبر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "مشکلی در اجرای درخواست شما بوجود امده است"
|
|
*/
|
|
|
|
router.get("/news/mostviewed", newsController.MostViewdNews);
|
|
|
|
router.delete("/news/:id", newsController.deletOneNews);
|
|
/**
|
|
* @swagger
|
|
* /admin/news:
|
|
* get:
|
|
* summary: Get all news articles
|
|
* description: Retrieve all news articles.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* description: Page number for paginated results
|
|
* - in: query
|
|
* name: limit
|
|
* schema:
|
|
* type: integer
|
|
* description: Maximum number of news articles to return per page
|
|
* responses:
|
|
* '200':
|
|
* description: List of news articles retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewsPagination'
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "مشکلی در گرفتن اطلاعات پیش آمده است"
|
|
*/
|
|
router.get("/news", newsController.getAll);
|
|
/**
|
|
* @swagger
|
|
* /admin/news/search:
|
|
* post:
|
|
* summary: Search news articles
|
|
* description: Search for news articles based on various criteria.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: The search term to look for in the title and summary of news articles.
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID to filter news articles by.
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: Filter news articles based on whether they should be shown on the home page or not.
|
|
* publish:
|
|
* type: boolean
|
|
* description: Filter news articles based on their publish status.
|
|
* portals:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: The portals to filter news articles by.
|
|
* status:
|
|
* type: boolean
|
|
* description: Filter news articles based on their status.
|
|
* notifications:
|
|
* type: boolean
|
|
* description: Filter news articles based on their notification status.
|
|
* special:
|
|
* type: boolean
|
|
* description: Filter news articles based on their special status.
|
|
* newsFile:
|
|
* type: string
|
|
* description: The news file ID to filter news articles by.
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* format: date
|
|
* description: An array containing start and end dates to filter news articles by custom date.
|
|
* responses:
|
|
* '200':
|
|
* description: List of news articles matching the search criteria retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewsPagination'
|
|
* '500':
|
|
* description: Internal server error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خطای سرور: مشکلی در جستجوی خبرها رخ داده است"
|
|
*/
|
|
router.post("/news/search", newsController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/news/{id}:
|
|
* get:
|
|
* summary: Get a news article by ID
|
|
* description: Retrieve a single news article by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the news article to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: News article retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/News'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to access the news article.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "شما اجازه دسترسی به اطلاعات این خبر را ندارید"
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested news article was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خبر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خطای سرور: مشکلی در بازیابی خبر رخ داده است"
|
|
*/
|
|
router.get("/news/:id", newsController.getOneNews);
|
|
/**
|
|
* @swagger
|
|
* /admin/news/attachments/{newsId}:
|
|
* post:
|
|
* summary: Add an attachment to a news article
|
|
* description: Add an attachment to a news article by providing the news article ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: newsId
|
|
* required: true
|
|
* description: ID of the news article to which the attachment will be added.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: attTitle
|
|
* required: true
|
|
* description: Title of the attachment.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: file
|
|
* required: true
|
|
* description: The attachment file to upload (PDF format).
|
|
* schema:
|
|
* type: file
|
|
* responses:
|
|
* '200':
|
|
* description: Attachment added successfully to the news article.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "ذخیره با موفقیت انجام شد"
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that the request was well-formed but unable to be followed due to validation errors.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* properties:
|
|
* file:
|
|
* type: string
|
|
* example: "فقط فرمت PDF قابل قبول است"
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested news article was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خبر مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خطای سرور: مشکلی در ذخیره اطلاعات رخ داده است"
|
|
*/
|
|
router.post("/news/attachments/:newsId", newsController.addAttachmentToNews);
|
|
/**
|
|
* @swagger
|
|
* /admin/news/attachments/{fileId}:
|
|
* delete:
|
|
* summary: Remove an attachment from a news article
|
|
* description: Remove an attachment from a news article by providing the attachment ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: fileId
|
|
* required: true
|
|
* description: ID of the attachment to be removed.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Attachment removed successfully from the news article.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "حذف با موفقیت انجام شد"
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested attachment was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "فایل مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خطای سرور: مشکلی در ذخیره اطلاعات رخ داده است"
|
|
*/
|
|
router.delete(
|
|
"/news/attachments/:fileId",
|
|
newsController.removeAttachmentFromNews
|
|
);
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/newsFile:
|
|
* post:
|
|
* summary: Add a news file
|
|
* description: Add a news file with relevant details like title, description, category, etc.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: Title of the news file.
|
|
* description:
|
|
* type: string
|
|
* description: Description of the news file (optional).
|
|
* catId:
|
|
* type: string
|
|
* description: ID of the category associated with the news file.
|
|
* index:
|
|
* type: number
|
|
* description: Order of display for the news file.
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: Indicates whether the news file should be shown on the home page.
|
|
* siteMap:
|
|
* type: boolean
|
|
* description: Indicates whether the news file should be included in the site map.
|
|
* modelType:
|
|
* type: string
|
|
* description: Model type of the news file.
|
|
* cover:
|
|
* type: string
|
|
* format: binary
|
|
* description: Cover image for the news file (optional).
|
|
* responses:
|
|
* '200':
|
|
* description: News file added successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that one or more request parameters are missing or invalid.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Validation errors.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خطای سرور: مشکلی در اضافه کردن پرونده پرونده خبریی پیش آمده است"
|
|
*/
|
|
router.post(
|
|
"/newsFile",
|
|
hasPermission("newsFile"),
|
|
newsFileController.addNewsFile
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/newsFile/{id}:
|
|
* put:
|
|
* summary: Update a news file
|
|
* description: Update details of a specific news file.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the news file to update.
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: Title of the news file.
|
|
* description:
|
|
* type: string
|
|
* description: Description of the news file (optional).
|
|
* catId:
|
|
* type: string
|
|
* description: ID of the category associated with the news file.
|
|
* index:
|
|
* type: number
|
|
* description: Order of display for the news file.
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: Indicates whether the news file should be shown on the home page.
|
|
* siteMap:
|
|
* type: boolean
|
|
* description: Indicates whether the news file should be included in the site map.
|
|
* modelType:
|
|
* type: string
|
|
* description: Model type of the news file.
|
|
* cover:
|
|
* type: string
|
|
* format: binary
|
|
* description: Cover image for the news file (optional).
|
|
* responses:
|
|
* '200':
|
|
* description: News file updated successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that one or more request parameters are missing or invalid.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Validation errors.
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to update the news file.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "شما اجازه آپدیت این پرونده خبری را ندارید"
|
|
* '404':
|
|
* description: Not Found. Indicates that the news file with the provided ID was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "پرونده خبری مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "خطای سرور: مشکلی در آپدیت کردن پرونده خبریی پیش آمده است"
|
|
*/
|
|
router.put(
|
|
"/newsFile/:id",
|
|
hasPermission("newsFile"),
|
|
newsFileController.updateNewsFile
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/newsFile/{id}:
|
|
* delete:
|
|
* summary: Delete a news file
|
|
* description: Delete a specific news file by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the news file to delete.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: News file deleted successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have permission to delete the news file.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "شما اجازه حذف این پرونده خبری را ندارید"
|
|
* '404':
|
|
* description: Not Found. Indicates that the news file with the provided ID was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "پرونده خبری مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.delete(
|
|
"/newsFile/:id",
|
|
hasPermission("newsFile"),
|
|
newsFileController.deletOneNewsFile
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/newsFile:
|
|
* get:
|
|
* summary: Get all news files
|
|
* description: Retrieve all news files based on user permissions.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: A list of news files retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.get("/newsFile", newsFileController.getAll);
|
|
/**
|
|
* @swagger
|
|
* /admin/newsFile/{id}:
|
|
* get:
|
|
* summary: Get a news file by ID
|
|
* description: Retrieve a news file by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the news file to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The news file retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* '403':
|
|
* description: Forbidden. Indicates that the user does not have access to view the requested news file.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "شما اجازه دسترسی به اطلاعات این پرونده خبری را ندارید"
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested news file with the given ID does not exist.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "پرونده خبری مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.get(
|
|
"/newsFile/:id",
|
|
hasPermission("newsFile"),
|
|
newsFileController.getOneNewsFile
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/newsFile/search:
|
|
* post:
|
|
* summary: Search for news files
|
|
* description: Search for news files based on various criteria such as title, category, portals, etc.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: The search term.
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: Indicates whether the news files should be shown on the home page.
|
|
* catId:
|
|
* type: string
|
|
* description: The ID of the category to filter the news files.
|
|
* portals:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: The portals to filter the news files.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The search was successful.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.post(
|
|
"/newsFile/search",
|
|
hasPermission("newsFile"),
|
|
newsFileController.search
|
|
);
|
|
|
|
//////////////// contents policy
|
|
router.use("/content", hasPermission("contents"));
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/content:
|
|
* post:
|
|
* summary: Add new content
|
|
* description: Add new content to the system with the provided details.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the content.
|
|
* param:
|
|
* type: string
|
|
* description: The parameter for the content.
|
|
* pageContent:
|
|
* type: string
|
|
* description: The content of the page.
|
|
* email:
|
|
* type: string
|
|
* description: The email associated with the content.
|
|
* showInMenu:
|
|
* type: boolean
|
|
* description: Indicates whether the content should be shown in the menu.
|
|
* cover:
|
|
* type: string
|
|
* format: binary
|
|
* description: The cover image for the content.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The content was successfully added.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Content'
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that the request was well-formed but contains invalid parameters.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Object containing validation errors.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.post("/content", contentController.addContent);
|
|
/**
|
|
* @swagger
|
|
* /admin/content/{param}:
|
|
* put:
|
|
* summary: Update content
|
|
* description: Update existing content with the provided details.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: param
|
|
* required: true
|
|
* description: The parameter of the content to update.
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The updated title of the content.
|
|
* pageContent:
|
|
* type: string
|
|
* description: The updated content of the page.
|
|
* email:
|
|
* type: string
|
|
* description: The updated email associated with the content.
|
|
* showInMenu:
|
|
* type: boolean
|
|
* description: Indicates whether the content should be shown in the menu.
|
|
* cover:
|
|
* type: string
|
|
* format: binary
|
|
* description: The updated cover image for the content.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The content was successfully updated.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Content'
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested content was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that the request was well-formed but contains invalid parameters.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Object containing validation errors.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.put("/content/:param", contentController.updateContent);
|
|
/**
|
|
* @swagger
|
|
* /admin/content/{param}:
|
|
* get:
|
|
* summary: Get one content
|
|
* description: Retrieve details of a specific content identified by its parameter.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: param
|
|
* required: true
|
|
* description: The parameter of the content to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The requested content details.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Content'
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested content was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.get("/content/:param", contentController.getOneContent);
|
|
|
|
//////////////// comments policy
|
|
// router.use('/comment/:model', hasPermission('newsComment'));
|
|
|
|
router.param("model", hasSubPermission());
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/{model}/changeStatus/{id}:
|
|
* put:
|
|
* summary: Change status of a comment
|
|
* description: Change the status of a comment (allowShow) identified by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type of the comment.
|
|
* schema:
|
|
* type: string
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the comment to update.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The updated comment object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested comment was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.put("/comment/:model/changeStatus/:id", commentController.changeStatus);
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/{model}/{id}:
|
|
* put:
|
|
* summary: Update a comment
|
|
* description: Update a comment identified by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type of the comment.
|
|
* schema:
|
|
* type: string
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the comment to update.
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description:
|
|
* type: string
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* allowShow:
|
|
* type: boolean
|
|
* example:
|
|
* name: John Doe
|
|
* description: This is a comment.
|
|
* email: john@example.com
|
|
* allowShow: true
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The updated comment object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested comment was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that there were validation errors in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* example:
|
|
* name: "Name is required"
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.put("/comment/:model/:id", commentController.updateComment);
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/{model}/{id}:
|
|
* delete:
|
|
* summary: Delete a comment
|
|
* description: Delete a comment identified by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type of the comment.
|
|
* schema:
|
|
* type: string
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the comment to delete.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: The deleted comment object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested comment was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.delete("/comment/:model/:id", commentController.deletOneComment);
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/countAll/{model}:
|
|
* get:
|
|
* summary: Get count of all comments for a specific model
|
|
* description: Retrieve the count of all comments associated with a specific model.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type for which comments are counted.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the count of all comments for the specified model.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the model.
|
|
* count:
|
|
* type: number
|
|
* description: The count of comments associated with the model.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.get("/comment/countAll/:model", commentController.getAllforCount);
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/{model}:
|
|
* get:
|
|
* summary: Get all comments for a specific model
|
|
* description: Retrieve all comments associated with a specific model.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type for which comments are fetched.
|
|
* schema:
|
|
* type: string
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* description: The page number for paginated results.
|
|
* - in: query
|
|
* name: limit
|
|
* schema:
|
|
* type: integer
|
|
* description: The maximum number of comments to return per page.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the paginated list of comments for the specified model.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: The total number of comments.
|
|
* totalPages:
|
|
* type: integer
|
|
* description: The total number of pages.
|
|
* page:
|
|
* type: integer
|
|
* description: The current page number.
|
|
* limit:
|
|
* type: integer
|
|
* description: The maximum number of comments per page.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.get("/comment/:model", commentController.getAll);
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/{model}/search:
|
|
* post:
|
|
* summary: Search comments for a specific model
|
|
* description: Retrieve comments associated with a specific model based on search criteria.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type for which comments are searched.
|
|
* schema:
|
|
* type: string
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* description: The page number for paginated results.
|
|
* - in: query
|
|
* name: limit
|
|
* schema:
|
|
* type: integer
|
|
* description: The maximum number of comments to return per page.
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description: The name to search for.
|
|
* email:
|
|
* type: string
|
|
* description: The email to search for.
|
|
* read:
|
|
* type: boolean
|
|
* description: Indicates whether the comment has been read or not.
|
|
* allowShow:
|
|
* type: boolean
|
|
* description: Indicates whether the comment is allowed to be shown or not.
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Array containing start and end dates for filtering comments by creation date.
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the paginated list of comments based on the search criteria.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: The total number of comments.
|
|
* totalPages:
|
|
* type: integer
|
|
* description: The total number of pages.
|
|
* page:
|
|
* type: integer
|
|
* description: The current page number.
|
|
* limit:
|
|
* type: integer
|
|
* description: The maximum number of comments per page.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "Internal Server Error: Something went wrong"
|
|
*/
|
|
router.post("/comment/:model/search", commentController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/{model}/{id}:
|
|
* get:
|
|
* summary: Get a single comment for a specific model
|
|
* description: Retrieve a single comment associated with a specific model by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type associated with the comment.
|
|
* schema:
|
|
* type: string
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the comment to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the requested comment.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested comment was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.get("/comment/:model/:id", commentController.getOneComment);
|
|
|
|
/////////////// contactUs
|
|
// router.put('/contactUs' , contactUsController.updateContacUs);
|
|
// router.get('/contactUs' , contactUsController.getOneContacUs);
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/comment/{model}/{id}:
|
|
* get:
|
|
* summary: Get a single comment for a specific model
|
|
* description: Retrieve a single comment associated with a specific model by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: model
|
|
* required: true
|
|
* description: The model type associated with the comment.
|
|
* schema:
|
|
* type: string
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the comment to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the requested comment.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* '404':
|
|
* description: Not Found. Indicates that the requested comment was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.post("/yearBanner", yearBannerController.updateYearBanner);
|
|
/**
|
|
* @swagger
|
|
* /admin/counterDay:
|
|
* post:
|
|
* summary: Update counter day settings
|
|
* description: Update the counter day settings, including the title, publish status, and expiration date.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the counter day.
|
|
* publish:
|
|
* type: boolean
|
|
* description: Whether to publish the counter day.
|
|
* expireDate:
|
|
* type: string
|
|
* format: date
|
|
* description: The expiration date of the counter day (YYYY-MM-DD).
|
|
* example:
|
|
* title: Sample Counter Day
|
|
* publish: true
|
|
* expireDate: 2024-12-31
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Indicates that the counter day settings have been updated successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: A success message indicating that the settings have been updated.
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates that the request parameters are invalid.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/ValidationError'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
////////////// counter day
|
|
router.post("/counterDay", counterDayController.updateCounterDay);
|
|
/**
|
|
* @swagger
|
|
* /admin/counterDay:
|
|
* get:
|
|
* summary: Get counter day settings
|
|
* description: Retrieve the counter day settings, including the title, publish status, and expiration date.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the counter day settings.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/CounterDay'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.get("/counterDay", counterDayController.getCounterDayByAdmin);
|
|
|
|
router.use("/gallery", hasPermission("gallery"));
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery/uploadFile:
|
|
* post:
|
|
* summary: Upload a file to the gallery
|
|
* description: Upload a file (image, video, or graphic) to a specified gallery.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* galleryId:
|
|
* type: string
|
|
* description: The ID of the gallery
|
|
* example: "60c72b2f9b1d4e4f88e3e9a1"
|
|
* fileType:
|
|
* type: string
|
|
* enum: ['image', 'video', 'graphic']
|
|
* description: The type of the file being uploaded
|
|
* example: "image"
|
|
* file:
|
|
* type: string
|
|
* format: binary
|
|
* description: The file to upload
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the updated gallery object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* '422':
|
|
* description: Unprocessable Entity. Validation error in the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.post("/gallery/uploadFile", galleryController.uploadFile);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery/deleteFile:
|
|
* post:
|
|
* summary: Delete a file from the gallery
|
|
* description: Delete a specified file (image, video, or graphic) from a specified gallery.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* galleryId:
|
|
* type: string
|
|
* description: The ID of the gallery
|
|
* example: "60c72b2f9b1d4e4f88e3e9a1"
|
|
* name:
|
|
* type: string
|
|
* description: The name of the file to delete
|
|
* example: "example.jpg"
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the updated gallery object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* '422':
|
|
* description: Unprocessable Entity. Validation error in the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '404':
|
|
* description: Not Found. The gallery or file was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.post("/gallery/deleteFile", galleryController.deleteFile);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery/uploadCover:
|
|
* post:
|
|
* summary: Upload a cover image for a gallery
|
|
* description: Upload a cover image for a specified gallery.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* galleryId:
|
|
* type: string
|
|
* description: The ID of the gallery
|
|
* example: "60c72b2f9b1d4e4f88e3e9a1"
|
|
* file:
|
|
* type: string
|
|
* format: binary
|
|
* description: The cover image file to upload
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the updated gallery object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* '422':
|
|
* description: Unprocessable Entity. Validation error in the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '404':
|
|
* description: Not Found. The gallery was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.post("/gallery/uploadCover", galleryController.uploadCover);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery:
|
|
* post:
|
|
* summary: Add a new gallery
|
|
* description: Adds a new gallery with the specified details.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the gallery
|
|
* leadTitle:
|
|
* type: string
|
|
* description: The lead title of the gallery
|
|
* catId:
|
|
* type: string
|
|
* description: The ID of the category
|
|
* priority:
|
|
* type: number
|
|
* description: The priority of the gallery
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: Whether to show the gallery on the home page
|
|
* special:
|
|
* type: boolean
|
|
* description: Whether the gallery is special
|
|
* siteMap:
|
|
* type: boolean
|
|
* description: Whether to include the gallery in the sitemap
|
|
* isEmbedded:
|
|
* type: boolean
|
|
* description: Whether the gallery is embedded
|
|
* publish:
|
|
* type: boolean
|
|
* description: Whether the gallery is published
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the gallery (image, video, graphic)
|
|
* keywords:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Keywords associated with the gallery
|
|
* modelType:
|
|
* type: string
|
|
* description: The model type of the gallery
|
|
* metaTagDesc:
|
|
* type: string
|
|
* description: Meta tag description for the gallery
|
|
* newsFileId:
|
|
* type: string
|
|
* description: The ID of the associated news file
|
|
* favorite:
|
|
* type: boolean
|
|
* description: Whether the gallery is marked as a favorite
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the created gallery object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* '422':
|
|
* description: Unprocessable Entity. Validation error in the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '403':
|
|
* description: Forbidden. The user does not have permission to perform this action.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '404':
|
|
* description: Not Found. The category was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.post("/gallery", galleryController.addGallery);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery/{id}:
|
|
* put:
|
|
* summary: Update an existing gallery
|
|
* description: Updates the details of an existing gallery.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the gallery to update
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the gallery
|
|
* leadTitle:
|
|
* type: string
|
|
* description: The lead title of the gallery
|
|
* catId:
|
|
* type: string
|
|
* description: The ID of the category
|
|
* priority:
|
|
* type: number
|
|
* description: The priority of the gallery
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: Whether to show the gallery on the home page
|
|
* special:
|
|
* type: boolean
|
|
* description: Whether the gallery is special
|
|
* siteMap:
|
|
* type: boolean
|
|
* description: Whether to include the gallery in the sitemap
|
|
* isEmbedded:
|
|
* type: boolean
|
|
* description: Whether the gallery is embedded
|
|
* embeddedCode:
|
|
* type: string
|
|
* description: The embedded code for the gallery
|
|
* publish:
|
|
* type: boolean
|
|
* description: Whether the gallery is published
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the gallery (image, video, graphic)
|
|
* keywords:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Keywords associated with the gallery
|
|
* modelType:
|
|
* type: string
|
|
* description: The model type of the gallery
|
|
* metaTagDesc:
|
|
* type: string
|
|
* description: Meta tag description for the gallery
|
|
* customDate:
|
|
* type: string
|
|
* description: Custom date for the gallery
|
|
* newsFileId:
|
|
* type: string
|
|
* description: The ID of the associated news file
|
|
* favorite:
|
|
* type: boolean
|
|
* description: Whether the gallery is marked as a favorite
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the updated gallery object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* '422':
|
|
* description: Unprocessable Entity. Validation error in the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '403':
|
|
* description: Forbidden. The user does not have permission to perform this action.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '404':
|
|
* description: Not Found. The gallery or category was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.put("/gallery/:id", galleryController.updateGallery);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery/{id}:
|
|
* delete:
|
|
* summary: Delete an existing gallery
|
|
* description: Deletes the specified gallery.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the gallery to delete
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the deleted gallery object.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* '403':
|
|
* description: Forbidden. The user does not have permission to perform this action.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '404':
|
|
* description: Not Found. The gallery was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.delete("/gallery/:id", galleryController.deletOneGallery);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery:
|
|
* get:
|
|
* summary: Get all galleries
|
|
* description: Retrieves a list of all galleries with pagination.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* description: Page number for pagination
|
|
* - in: query
|
|
* name: limit
|
|
* schema:
|
|
* type: integer
|
|
* description: Number of items per page
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns a list of galleries.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* totalDocs:
|
|
* type: integer
|
|
* limit:
|
|
* type: integer
|
|
* totalPages:
|
|
* type: integer
|
|
* page:
|
|
* type: integer
|
|
* pagingCounter:
|
|
* type: integer
|
|
* hasPrevPage:
|
|
* type: boolean
|
|
* hasNextPage:
|
|
* type: boolean
|
|
* prevPage:
|
|
* type: integer
|
|
* nullable: true
|
|
* nextPage:
|
|
* type: integer
|
|
* nullable: true
|
|
* '500':
|
|
* description: Internal Server Error. Indicates that an unexpected error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Error'
|
|
*/
|
|
router.get("/gallery", galleryController.getAll);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery/search:
|
|
* post:
|
|
* summary: Search for galleries
|
|
* description: Searches for galleries based on various criteria.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: Search term for gallery title
|
|
* catId:
|
|
* type: string
|
|
* description: Category ID to filter galleries
|
|
* showInHome:
|
|
* type: boolean
|
|
* description: Filter by show in home
|
|
* portals:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Filter by portals
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: Filter by gallery status
|
|
* publish:
|
|
* type: boolean
|
|
* description: Filter by publish status
|
|
* galleryType:
|
|
* type: string
|
|
* enum: [image, video, graphic]
|
|
* description: Filter by gallery type
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* format: date
|
|
* description: Filter by creation date range
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns a list of galleries matching the search criteria.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* totalDocs:
|
|
* type: integer
|
|
* limit:
|
|
* type: integer
|
|
* totalPages:
|
|
* type: integer
|
|
* page:
|
|
* type: integer
|
|
* pagingCounter:
|
|
* type: integer
|
|
* '422':
|
|
* description: Validation error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* additionalProperties:
|
|
* type: object
|
|
* properties:
|
|
* msg:
|
|
* type: string
|
|
* '500':
|
|
* description: Server error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
*/
|
|
router.post("/gallery/search", galleryController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/gallery/{id}:
|
|
* get:
|
|
* summary: Get a gallery by ID
|
|
* description: Retrieves a gallery by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the gallery to retrieve
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the requested gallery.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Gallery'
|
|
* '404':
|
|
* description: Gallery not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: Gallery not found
|
|
* '500':
|
|
* description: Server error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
*/
|
|
router.get("/gallery/:id", galleryController.getOneGallery);
|
|
|
|
//////////// policy
|
|
router.use("/links", hasPermission("superAdmin"));
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/links:
|
|
* post:
|
|
* summary: Add a new link
|
|
* description: Add a new link to the system.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* url:
|
|
* type: string
|
|
* index:
|
|
* type: number
|
|
* showInHome:
|
|
* type: boolean
|
|
* siteMap:
|
|
* type: boolean
|
|
* modelType:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the created link.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Links'
|
|
* '422':
|
|
* description: Validation error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* url:
|
|
* type: string
|
|
* index:
|
|
* type: string
|
|
* showInHome:
|
|
* type: string
|
|
* siteMap:
|
|
* type: string
|
|
* '500':
|
|
* description: Server error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
*/
|
|
router.post("/links", linksController.addLinks);
|
|
/**
|
|
* @swagger
|
|
* /admin/links/{id}:
|
|
* put:
|
|
* summary: Update a link
|
|
* description: Update an existing link in the system.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the link to update
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* url:
|
|
* type: string
|
|
* index:
|
|
* type: number
|
|
* showInHome:
|
|
* type: boolean
|
|
* siteMap:
|
|
* type: boolean
|
|
* modelType:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the updated link.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Links'
|
|
* '422':
|
|
* description: Validation error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* url:
|
|
* type: string
|
|
* index:
|
|
* type: string
|
|
* showInHome:
|
|
* type: string
|
|
* siteMap:
|
|
* type: string
|
|
* '404':
|
|
* description: Link not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* '500':
|
|
* description: Server error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
*/
|
|
router.put("/links/:id", linksController.updateLinks);
|
|
/**
|
|
* @swagger
|
|
* /admin/links/{id}:
|
|
* delete:
|
|
* summary: Delete a link
|
|
* description: Delete an existing link from the system.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the link to delete
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the deleted link.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Links'
|
|
* '404':
|
|
* description: Link not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* '500':
|
|
* description: Server error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
*/
|
|
router.delete("/links/:id", linksController.deletOneLinks);
|
|
/**
|
|
* @swagger
|
|
* /admin/links:
|
|
* get:
|
|
* summary: Get all links
|
|
* description: Retrieve all links from the system.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns an array of links.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Links'
|
|
* '500':
|
|
* description: Server error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
*/
|
|
router.get("/links", linksController.getAll);
|
|
/**
|
|
* @swagger
|
|
* /admin/links/{id}:
|
|
* get:
|
|
* summary: Get a specific link
|
|
* description: Retrieve a specific link by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* description: ID of the link to retrieve
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the requested link.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Links'
|
|
* '403':
|
|
* description: Forbidden. User does not have access to the link.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating lack of access.
|
|
* '404':
|
|
* description: Not Found. The link with the specified ID was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating link not found.
|
|
* '500':
|
|
* description: Server error
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating server error.
|
|
*/
|
|
router.get("/links/:id", linksController.getOneLinks);
|
|
|
|
//////////// policy
|
|
router.use("/slider", hasPermission("superAdmin"));
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/slider:
|
|
* post:
|
|
* summary: Add a new slider
|
|
* description: Add a new slider with the provided details.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* multipart/form-data:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* summaryTitle:
|
|
* type: string
|
|
* url:
|
|
* type: string
|
|
* index:
|
|
* type: integer
|
|
* isLocal:
|
|
* type: boolean
|
|
* siteMap:
|
|
* type: boolean
|
|
* modelType:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the newly created slider.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Slider'
|
|
* '422':
|
|
* description: Unprocessable Entity. Validation error in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Validation errors.
|
|
* '500':
|
|
* description: Server error.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating server error.
|
|
*/
|
|
router.post("/slider", sliderController.addSlider);
|
|
/**
|
|
* @swagger
|
|
* /admin/slider/{id}:
|
|
* put:
|
|
* summary: Update slider by ID
|
|
* description: Update the slider with the specified ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the slider to update
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* summaryTitle:
|
|
* type: string
|
|
* url:
|
|
* type: string
|
|
* isLocal:
|
|
* type: boolean
|
|
* index:
|
|
* type: integer
|
|
* siteMap:
|
|
* type: boolean
|
|
* modelType:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the updated slider.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Slider'
|
|
* '422':
|
|
* description: Unprocessable Entity. Validation error in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Validation errors.
|
|
* '404':
|
|
* description: Not Found. The specified slider ID was not found.
|
|
* '500':
|
|
* description: Server error.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating server error.
|
|
*/
|
|
router.put("/slider/:id", sliderController.updateSlider);
|
|
/**
|
|
* @swagger
|
|
* /admin/slider/{id}:
|
|
* delete:
|
|
* summary: Delete slider by ID
|
|
* description: Delete the slider with the specified ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the slider to delete
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the deleted slider.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Slider'
|
|
* '404':
|
|
* description: Not Found. The specified slider ID was not found.
|
|
* '500':
|
|
* description: Server error.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating server error.
|
|
*/
|
|
router.delete("/slider/:id", sliderController.deletOneSlider);
|
|
/**
|
|
* @swagger
|
|
* /admin/slider:
|
|
* get:
|
|
* summary: Get all sliders
|
|
* description: Retrieve all sliders based on the user's portals.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns an array of sliders.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Slider'
|
|
* '500':
|
|
* description: Server error.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating server error.
|
|
*/
|
|
router.get("/slider", sliderController.getAllSliderByAdmin);
|
|
/**
|
|
* @swagger
|
|
* /admin/slider/search:
|
|
* post:
|
|
* summary: Search sliders
|
|
* description: Search sliders based on specified criteria.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* description: Object containing search parameters.
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: Term to search for in slider titles.
|
|
* portals:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: Array of portal IDs to filter sliders.
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: Status of the sliders to filter.
|
|
* publish:
|
|
* type: boolean
|
|
* description: Publish status of the sliders to filter.
|
|
* galleryType:
|
|
* type: string
|
|
* description: Type of sliders to filter.
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* format: date
|
|
* description: Array containing start and end dates to filter by creation date.
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns paginated list of sliders based on search criteria.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/PaginatedSlider'
|
|
* '500':
|
|
* description: Server error.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating server error.
|
|
*/
|
|
router.post("/slider/search", sliderController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/slider/{id}:
|
|
* get:
|
|
* summary: Get a slider by ID
|
|
* description: Retrieve details of a slider by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* format: uuid
|
|
* description: ID of the slider to retrieve.
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the details of the requested slider.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Slider'
|
|
* '403':
|
|
* description: Forbidden. The user does not have permission to access the slider.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating lack of permission.
|
|
* '404':
|
|
* description: Not Found. The requested slider does not exist.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating that the slider was not found.
|
|
* '500':
|
|
* description: Server error.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating server error.
|
|
*/
|
|
router.get("/slider/:id", sliderController.getOneSlider);
|
|
|
|
/**
|
|
* @swagger
|
|
* /admin/occasion:
|
|
* post:
|
|
* summary: Add a new occasion
|
|
* description: Add a new occasion with title, publish status, index, start date, and end date.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the occasion.
|
|
* publish:
|
|
* type: boolean
|
|
* description: The publish status of the occasion.
|
|
* index:
|
|
* type: number
|
|
* description: The index of the occasion.
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* description: The start date of the occasion.
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* description: The end date of the occasion.
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the details of the added occasion.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Occasion'
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates validation errors in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Validation errors mapped by field.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
//////////// occasion
|
|
router.post("/occasion", occasionController.addOccasion);
|
|
/**
|
|
* @swagger
|
|
* /occasion/{id}:
|
|
* put:
|
|
* summary: Update an occasion
|
|
* description: Update an existing occasion with the specified ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the occasion to update.
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The updated title of the occasion.
|
|
* publish:
|
|
* type: boolean
|
|
* description: The updated publish status of the occasion.
|
|
* index:
|
|
* type: number
|
|
* description: The updated index of the occasion.
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* description: The updated start date of the occasion.
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* description: The updated end date of the occasion.
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the updated occasion details.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Occasion'
|
|
* '422':
|
|
* description: Unprocessable Entity. Indicates validation errors in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Validation errors mapped by field.
|
|
* '404':
|
|
* description: Not Found. Indicates the specified occasion was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the occasion was not found.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
router.put("/occasion/:id", occasionController.updateOccasion);
|
|
/**
|
|
* @swagger
|
|
* /occasion/{id}:
|
|
* delete:
|
|
* summary: Delete an occasion
|
|
* description: Delete an existing occasion with the specified ID.
|
|
* tags:
|
|
* - Admin
|
|
* security:
|
|
* - bearerAuth: []
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the occasion to delete.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Indicates the occasion was successfully deleted.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message indicating the occasion was deleted.
|
|
* '404':
|
|
* description: Not Found. Indicates the specified occasion was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating the occasion was not found.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
router.delete("/occasion/:id", occasionController.deleteOccasion);
|
|
/**
|
|
* @swagger
|
|
* /occasion:
|
|
* get:
|
|
* summary: Get all occasions
|
|
* description: Retrieve a list of all occasions.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: query
|
|
* name: page
|
|
* description: The page number.
|
|
* schema:
|
|
* type: integer
|
|
* minimum: 1
|
|
* default: 1
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns a paginated list of occasions.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Occasion'
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: Total number of occasions.
|
|
* limit:
|
|
* type: integer
|
|
* description: Maximum number of occasions per page.
|
|
* totalPages:
|
|
* type: integer
|
|
* description: Total number of pages.
|
|
* page:
|
|
* type: integer
|
|
* description: Current page number.
|
|
* pagingCounter:
|
|
* type: integer
|
|
* description: The starting index of the first occasion in the current page.
|
|
* hasPrevPage:
|
|
* type: boolean
|
|
* description: Indicates if there is a previous page.
|
|
* hasNextPage:
|
|
* type: boolean
|
|
* description: Indicates if there is a next page.
|
|
* prevPage:
|
|
* type: integer
|
|
* description: The previous page number if exists, otherwise null.
|
|
* nextPage:
|
|
* type: integer
|
|
* description: The next page number if exists, otherwise null.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
router.get("/occasion", occasionController.getAllOccasionByAdmin);
|
|
/**
|
|
* @swagger
|
|
* /occasion/allOccasion:
|
|
* get:
|
|
* summary: Get all occasions for index
|
|
* description: Retrieve a list of all occasions for displaying on the index page.
|
|
* tags:
|
|
* - Admin
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns a list of occasions.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Occasion'
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
router.get("/occasion/allOccasion", occasionController.getAllOccasionForIndex);
|
|
/**
|
|
* @swagger
|
|
* /occasion/search:
|
|
* post:
|
|
* summary: Search occasions
|
|
* description: Search occasions based on various criteria such as title, publish status, date range, etc.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* description: Object containing search parameters
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: Search term to match against occasion titles.
|
|
* publish:
|
|
* type: boolean
|
|
* description: Publish status of the occasions.
|
|
* status:
|
|
* type: boolean
|
|
* description: Status of the occasions.
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* format: date
|
|
* description: Array containing start and end date of the occasions.
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns a list of occasions matching the search criteria.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Occasion'
|
|
* totalDocs:
|
|
* type: number
|
|
* description: Total number of documents matching the search criteria.
|
|
* totalPages:
|
|
* type: number
|
|
* description: Total number of pages.
|
|
* page:
|
|
* type: number
|
|
* description: Current page number.
|
|
* limit:
|
|
* type: number
|
|
* description: Number of documents per page.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
router.post("/occasion/search", occasionController.search);
|
|
/**
|
|
* @swagger
|
|
* /occasion/{id}:
|
|
* get:
|
|
* summary: Get occasion by ID
|
|
* description: Retrieve an occasion by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: ID of the occasion to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Returns the occasion with the specified ID.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Occasion'
|
|
* '404':
|
|
* description: Not Found. Indicates that the occasion with the specified ID does not exist.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating that the occasion was not found.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
router.get("/occasion/:id", occasionController.getOccasionByAdmin);
|
|
/**
|
|
* @swagger
|
|
* /admin/clearBackups:
|
|
* post:
|
|
* summary: Remove old backups
|
|
* description: Removes old backup files and directories from the server.
|
|
* tags:
|
|
* - Admin
|
|
* responses:
|
|
* '200':
|
|
* description: Success. Indicates that old backups have been successfully removed.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message indicating that old backups have been removed.
|
|
* '500':
|
|
* description: Internal Server Error. Indicates a server-side error occurred.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message indicating a server error.
|
|
*/
|
|
//////////// backup
|
|
router.post("/clearBackups", dataBackupController.removeOldBackups);
|
|
|
|
router.post("/create-model", dynamicController.CreateModel);
|
|
|
|
router.post("/save-form", dynamicController.SaveDataModel);
|
|
|
|
//////////////// polls policy
|
|
router.use("/poll", hasPermission("polls"));
|
|
/**
|
|
* @swagger
|
|
* /admin/poll:
|
|
* post:
|
|
* summary: Add a new survey
|
|
* description: Creates a new survey with the provided details.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the survey.
|
|
* example: "Customer Satisfaction Survey"
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID associated with the survey.
|
|
* example: "60c72b2f9b1d4c4a3a1e6a6f"
|
|
* description:
|
|
* type: string
|
|
* description: A brief description of the survey.
|
|
* example: "This survey aims to gather customer feedback."
|
|
* surveyType:
|
|
* type: string
|
|
* description: The type of survey (check or radio).
|
|
* enum:
|
|
* - check
|
|
* - radio
|
|
* example: "radio"
|
|
* startDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The start date of the survey.
|
|
* example: "2024-06-01T00:00:00.000Z"
|
|
* endDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The end date of the survey.
|
|
* example: "2024-06-30T23:59:59.999Z"
|
|
* options:
|
|
* type: array
|
|
* description: The options available for the survey.
|
|
* items:
|
|
* type: string
|
|
* example: ["Very satisfied", "Satisfied", "Neutral", "Dissatisfied", "Very dissatisfied"]
|
|
* publish:
|
|
* type: boolean
|
|
* description: Whether the survey should be published.
|
|
* example: true
|
|
* responses:
|
|
* '200':
|
|
* description: Success. The survey has been created.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "اطلاعات با موفقیت ذخیره شد"
|
|
* '422':
|
|
* description: Validation Error. One or more of the provided fields are invalid.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* additionalProperties:
|
|
* type: object
|
|
* properties:
|
|
* msg:
|
|
* type: string
|
|
* description: Validation error message.
|
|
* '403':
|
|
* description: Forbidden. The user does not have permission to create a survey in the specified category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Forbidden message.
|
|
* example: "شما نمیتوانید این دسته بندی را انتخاب کنید"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
/////////////// polls
|
|
router.post("/poll", pollController.addSurvey);
|
|
/**
|
|
* @swagger
|
|
* /admin/poll/{id}:
|
|
* put:
|
|
* summary: Update an existing survey
|
|
* description: Updates the details of an existing survey based on the provided information.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The ID of the survey to update.
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the survey.
|
|
* example: "Customer Satisfaction Survey"
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID associated with the survey.
|
|
* example: "60c72b2f9b1d4c4a3a1e6a6f"
|
|
* description:
|
|
* type: string
|
|
* description: A brief description of the survey.
|
|
* example: "This survey aims to gather customer feedback."
|
|
* surveyType:
|
|
* type: string
|
|
* description: The type of survey (check or radio).
|
|
* enum:
|
|
* - check
|
|
* - radio
|
|
* example: "radio"
|
|
* startDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The start date of the survey.
|
|
* example: "2024-06-01T00:00:00.000Z"
|
|
* endDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The end date of the survey.
|
|
* example: "2024-06-30T23:59:59.999Z"
|
|
* options:
|
|
* type: array
|
|
* description: The options available for the survey.
|
|
* items:
|
|
* type: string
|
|
* example: ["Very satisfied", "Satisfied", "Neutral", "Dissatisfied", "Very dissatisfied"]
|
|
* publish:
|
|
* type: boolean
|
|
* description: Whether the survey should be published.
|
|
* example: true
|
|
* responses:
|
|
* '200':
|
|
* description: Success. The survey has been updated.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "اطلاعات با موفقیت ذخیره شد"
|
|
* '422':
|
|
* description: Validation Error. One or more of the provided fields are invalid.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* additionalProperties:
|
|
* type: object
|
|
* properties:
|
|
* msg:
|
|
* type: string
|
|
* description: Validation error message.
|
|
* '403':
|
|
* description: Forbidden. The user does not have permission to update the survey in the specified category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Forbidden message.
|
|
* example: "شما نمیتوانید این دسته بندی را انتخاب کنید"
|
|
* '404':
|
|
* description: Not Found. The specified survey or category does not exist.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Not found message.
|
|
* example: "نظر سنجی مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.put("/poll/:id", pollController.updateSurvey);
|
|
/**
|
|
* @swagger
|
|
* /admin/poll/{id}:
|
|
* delete:
|
|
* summary: Delete a survey
|
|
* description: Deletes an existing survey by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The ID of the survey to delete.
|
|
* responses:
|
|
* '200':
|
|
* description: Success. The survey has been deleted.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "اطلاعات با موفقیت حذف شد"
|
|
* '403':
|
|
* description: Forbidden. The user does not have permission to delete the survey.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Forbidden message.
|
|
* example: "شما اجازه حذف این نظرسنجی را ندارید"
|
|
* '404':
|
|
* description: Not Found. The specified survey does not exist.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Not found message.
|
|
* example: "نظرسنجی مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.delete("/poll/:id", pollController.deletOneSurvey);
|
|
/**
|
|
* @swagger
|
|
* /admin/poll:
|
|
* get:
|
|
* summary: Get all surveys
|
|
* description: Retrieves a paginated list of all surveys.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* example: 1
|
|
* description: The page number for pagination.
|
|
* responses:
|
|
* '200':
|
|
* description: Success. A list of surveys is returned.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* example: "60d21b4667d0d8992e610c85"
|
|
* title:
|
|
* type: string
|
|
* example: "Customer Satisfaction Survey"
|
|
* catId:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* example: "60d21b4567d0d8992e610c83"
|
|
* name:
|
|
* type: string
|
|
* example: "Customer Feedback"
|
|
* description:
|
|
* type: string
|
|
* example: "Survey to gauge customer satisfaction."
|
|
* surveyType:
|
|
* type: string
|
|
* example: "radio"
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2023-01-01"
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2023-12-31"
|
|
* options:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* example: ["Excellent", "Good", "Average", "Poor"]
|
|
* publish:
|
|
* type: boolean
|
|
* example: true
|
|
* created_at:
|
|
* type: string
|
|
* format: date-time
|
|
* example: "2023-01-01T00:00:00.000Z"
|
|
* updated_at:
|
|
* type: string
|
|
* format: date-time
|
|
* example: "2023-01-02T00:00:00.000Z"
|
|
* totalDocs:
|
|
* type: integer
|
|
* example: 100
|
|
* limit:
|
|
* type: integer
|
|
* example: 10
|
|
* page:
|
|
* type: integer
|
|
* example: 1
|
|
* totalPages:
|
|
* type: integer
|
|
* example: 10
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.get("/poll", pollController.getAllSurvey);
|
|
/**
|
|
* @swagger
|
|
* /admin/poll/search:
|
|
* post:
|
|
* summary: Search for surveys
|
|
* description: Searches for surveys based on various criteria.
|
|
* tags:
|
|
* - Admin
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: Search term for the survey title.
|
|
* example: "Customer Satisfaction"
|
|
* catId:
|
|
* type: string
|
|
* description: Category ID to filter surveys.
|
|
* example: "60d21b4567d0d8992e610c83"
|
|
* publish:
|
|
* type: boolean
|
|
* description: Filter by publish status.
|
|
* example: true
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* format: date
|
|
* description: Date range to filter surveys (start date and end date).
|
|
* example: ["2023-01-01", "2023-12-31"]
|
|
* responses:
|
|
* '200':
|
|
* description: Success. A list of surveys matching the search criteria is returned.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* example: "60d21b4667d0d8992e610c85"
|
|
* title:
|
|
* type: string
|
|
* example: "Customer Satisfaction Survey"
|
|
* catId:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* example: "60d21b4567d0d8992e610c83"
|
|
* name:
|
|
* type: string
|
|
* example: "Customer Feedback"
|
|
* description:
|
|
* type: string
|
|
* example: "Survey to gauge customer satisfaction."
|
|
* surveyType:
|
|
* type: string
|
|
* example: "radio"
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2023-01-01"
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2023-12-31"
|
|
* options:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* example: ["Excellent", "Good", "Average", "Poor"]
|
|
* publish:
|
|
* type: boolean
|
|
* example: true
|
|
* created_at:
|
|
* type: string
|
|
* format: date-time
|
|
* example: "2023-01-01T00:00:00.000Z"
|
|
* updated_at:
|
|
* type: string
|
|
* format: date-time
|
|
* example: "2023-01-02T00:00:00.000Z"
|
|
* totalDocs:
|
|
* type: integer
|
|
* example: 50
|
|
* limit:
|
|
* type: integer
|
|
* example: 10
|
|
* page:
|
|
* type: integer
|
|
* example: 1
|
|
* totalPages:
|
|
* type: integer
|
|
* example: 5
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.post("/poll/search", pollController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/poll/{id}:
|
|
* get:
|
|
* summary: Get a specific survey
|
|
* description: Retrieves details of a specific survey by its ID.
|
|
* tags:
|
|
* - Admin
|
|
* parameters:
|
|
* - name: id
|
|
* in: path
|
|
* required: true
|
|
* description: The ID of the survey to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* example: "60d21b4667d0d8992e610c85"
|
|
* responses:
|
|
* '200':
|
|
* description: Success. The details of the survey are returned.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* example: "60d21b4667d0d8992e610c85"
|
|
* title:
|
|
* type: string
|
|
* example: "Customer Satisfaction Survey"
|
|
* catId:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* example: "60d21b4567d0d8992e610c83"
|
|
* name:
|
|
* type: string
|
|
* example: "Customer Feedback"
|
|
* description:
|
|
* type: string
|
|
* example: "Survey to gauge customer satisfaction."
|
|
* surveyType:
|
|
* type: string
|
|
* example: "radio"
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2023-01-01"
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2023-12-31"
|
|
* options:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* example: ["Excellent", "Good", "Average", "Poor"]
|
|
* publish:
|
|
* type: boolean
|
|
* example: true
|
|
* created_at:
|
|
* type: string
|
|
* format: date-time
|
|
* example: "2023-01-01T00:00:00.000Z"
|
|
* updated_at:
|
|
* type: string
|
|
* format: date-time
|
|
* example: "2023-01-02T00:00:00.000Z"
|
|
* '403':
|
|
* description: Forbidden. The user is not allowed to view this survey.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "شما مجاز به دیدن اطلاعات این نظرسنجی نمی باشید"
|
|
* '404':
|
|
* description: Not Found. The survey with the specified ID was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "اطلاعات مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.get("/poll/:id", pollController.getOneSurvey);
|
|
|
|
//////////////// election policy
|
|
router.use("/election", hasPermission("elections"));
|
|
/**
|
|
* @swagger
|
|
* /admin/election:
|
|
* post:
|
|
* summary: Add a new election
|
|
* description: Creates a new election with the provided details.
|
|
* tags:
|
|
* - Election
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* example: "Presidential Election 2024"
|
|
* catId:
|
|
* type: string
|
|
* example: "60d21b4567d0d8992e610c83"
|
|
* description:
|
|
* type: string
|
|
* example: "Election to select the next president."
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2024-01-01"
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2024-12-31"
|
|
* publish:
|
|
* type: boolean
|
|
* example: true
|
|
* responses:
|
|
* '200':
|
|
* description: Success. The new election is created.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* example: "60d21b4667d0d8992e610c85"
|
|
* title:
|
|
* type: string
|
|
* example: "Presidential Election 2024"
|
|
* catId:
|
|
* type: string
|
|
* example: "60d21b4567d0d8992e610c83"
|
|
* description:
|
|
* type: string
|
|
* example: "Election to select the next president."
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2024-01-01"
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2024-12-31"
|
|
* publish:
|
|
* type: boolean
|
|
* example: true
|
|
* _creator:
|
|
* type: string
|
|
* example: "60d21b4667d0d8992e610c86"
|
|
* _updatedBy:
|
|
* type: string
|
|
* example: "60d21b4667d0d8992e610c87"
|
|
* '403':
|
|
* description: Forbidden. The user is not allowed to create an election in the specified category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "شما نمیتوانید این دسته بندی را انتخاب کنید"
|
|
* '404':
|
|
* description: Not Found. The specified category was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "دسته بندی مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
/////////////// election
|
|
router.post("/election", electionController.addElection);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/{id}:
|
|
* put:
|
|
* summary: Update an existing election
|
|
* description: Updates the details of an existing election by ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the election to update
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* example: "Updated Presidential Election 2024"
|
|
* catId:
|
|
* type: string
|
|
* example: "60d21b4567d0d8992e610c83"
|
|
* description:
|
|
* type: string
|
|
* example: "Updated description for the election."
|
|
* startDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2024-02-01"
|
|
* endDate:
|
|
* type: string
|
|
* format: date
|
|
* example: "2024-11-30"
|
|
* publish:
|
|
* type: boolean
|
|
* example: false
|
|
* responses:
|
|
* '200':
|
|
* description: Success. The election is updated.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "ذخیره سازی با موفقیت انجام شد"
|
|
* '403':
|
|
* description: Forbidden. The user is not allowed to update the election in the specified category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "شما نمیتوانید این دسته بندی را انتخاب کنید"
|
|
* '404':
|
|
* description: Not Found. The specified election or category was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد" or "دسته بندی مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.put("/election/:id", electionController.updateElection);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/{id}:
|
|
* delete:
|
|
* summary: Delete an existing election
|
|
* description: Deletes an election by ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the election to delete
|
|
* responses:
|
|
* '200':
|
|
* description: Success. The election is deleted.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* example: "حذف با موفقیت انجام شد"
|
|
* '403':
|
|
* description: Forbidden. The user is not allowed to delete the election in the specified category.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "شما اجازه حذف این انتخابات را ندارید"
|
|
* '404':
|
|
* description: Not Found. The specified election was not found.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.delete("/election/:id", electionController.deletOneElection);
|
|
/**
|
|
* @swagger
|
|
* /admin/election:
|
|
* get:
|
|
* summary: Get all elections
|
|
* description: Retrieves a paginated list of all elections.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* required: false
|
|
* description: The page number to retrieve
|
|
* responses:
|
|
* '200':
|
|
* description: A paginated list of elections
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The election ID
|
|
* title:
|
|
* type: string
|
|
* description: The title of the election
|
|
* catId:
|
|
* type: object
|
|
* description: The category of the election
|
|
* description:
|
|
* type: string
|
|
* description: The description of the election
|
|
* startDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The start date of the election
|
|
* endDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The end date of the election
|
|
* publish:
|
|
* type: boolean
|
|
* description: The publish status of the election
|
|
* _creator:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* description: The first name of the creator
|
|
* lastName:
|
|
* type: string
|
|
* description: The last name of the creator
|
|
* profilePic:
|
|
* type: string
|
|
* description: The profile picture of the creator
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: Total number of documents
|
|
* limit:
|
|
* type: integer
|
|
* description: Limit per page
|
|
* page:
|
|
* type: integer
|
|
* description: Current page number
|
|
* totalPages:
|
|
* type: integer
|
|
* description: Total number of pages
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.get("/election", electionController.getAllElection);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/search:
|
|
* post:
|
|
* summary: Search for elections
|
|
* description: |
|
|
* Searches for elections based on the provided criteria such as search term, category, publish status, and date range.
|
|
* tags:
|
|
* - Election
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* term:
|
|
* type: string
|
|
* description: The search term.
|
|
* catId:
|
|
* type: string
|
|
* description: The ID of the category to filter elections by.
|
|
* publish:
|
|
* type: boolean
|
|
* description: The publish status of the elections to filter by.
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* format: date
|
|
* description: The date range to filter elections by. If one date is provided, it will be treated as the start and end date.
|
|
* responses:
|
|
* '200':
|
|
* description: A list of elections that match the search criteria
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Election'
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: Total number of documents
|
|
* limit:
|
|
* type: integer
|
|
* description: Limit per page
|
|
* page:
|
|
* type: integer
|
|
* description: Current page number
|
|
* totalPages:
|
|
* type: integer
|
|
* description: Total number of pages
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.post("/election/search", electionController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/{id}:
|
|
* get:
|
|
* summary: Get information about a specific election
|
|
* description: |
|
|
* Retrieves information about a specific election identified by its ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the election to retrieve information about.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Information about the specified election
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Election'
|
|
* '404':
|
|
* description: The requested election was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "اطلاعات مورد نظر پیدا نشد"
|
|
* '403':
|
|
* description: Forbidden. The user is not authorized to view the election.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "شما مجاز به دیدن اطلاعات این انتخابات نمی باشید"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.get("/election/:id", electionController.getOneElection);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/candidate/{id}:
|
|
* post:
|
|
* summary: Add a candidate to an election
|
|
* description: |
|
|
* Adds a candidate to the specified election identified by its ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the election to which the candidate will be added.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: profilePic
|
|
* required: true
|
|
* description: The profile picture of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* format: binary
|
|
* - in: formData
|
|
* name: firstName
|
|
* required: true
|
|
* description: The first name of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: lastName
|
|
* required: true
|
|
* description: The last name of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: bornDate
|
|
* required: false
|
|
* description: The birth date of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* format: date
|
|
* - in: formData
|
|
* name: education
|
|
* required: false
|
|
* description: The education level of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: nationalCode
|
|
* required: false
|
|
* description: The national code of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: resume
|
|
* required: false
|
|
* description: The resume of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* consumes:
|
|
* - multipart/form-data
|
|
* produces:
|
|
* - application/json
|
|
* responses:
|
|
* '200':
|
|
* description: Candidate added successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "اطلاعات با موفقیت ذخیره شد"
|
|
* '404':
|
|
* description: The specified election was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد"
|
|
* '422':
|
|
* description: Unprocessable Entity. Missing or invalid input data.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* properties:
|
|
* profilePic:
|
|
* type: object
|
|
* properties:
|
|
* msg:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "لطفا یک فایل ارسال کنید"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
/////////////// candidate
|
|
router.post("/election/candidate/:id", electionController.addCandidate);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/candidate/{id}:
|
|
* put:
|
|
* summary: Update a candidate in an election
|
|
* description: |
|
|
* Updates the details of a candidate in the specified election identified by its ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the election containing the candidate to be updated.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: candidateId
|
|
* required: true
|
|
* description: The ID of the candidate to be updated.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: profilePic
|
|
* required: false
|
|
* description: The updated profile picture of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* format: binary
|
|
* - in: formData
|
|
* name: firstName
|
|
* required: true
|
|
* description: The updated first name of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: lastName
|
|
* required: true
|
|
* description: The updated last name of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: bornDate
|
|
* required: false
|
|
* description: The updated birth date of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* format: date
|
|
* - in: formData
|
|
* name: education
|
|
* required: false
|
|
* description: The updated education level of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: nationalCode
|
|
* required: false
|
|
* description: The updated national code of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* - in: formData
|
|
* name: resume
|
|
* required: false
|
|
* description: The updated resume of the candidate.
|
|
* schema:
|
|
* type: string
|
|
* consumes:
|
|
* - multipart/form-data
|
|
* produces:
|
|
* - application/json
|
|
* responses:
|
|
* '200':
|
|
* description: Candidate updated successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "اطلاعات با موفقیت ذخیره شد"
|
|
* '404':
|
|
* description: The specified election or candidate was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد" or "کاندید مورد نظر پیدا نشد"
|
|
* '422':
|
|
* description: Unprocessable Entity. Missing or invalid input data.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* properties:
|
|
* profilePic:
|
|
* type: object
|
|
* properties:
|
|
* msg:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "لطفا یک فایل ارسال کنید"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.put("/election/candidate/:id", electionController.updateCandidate);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/candidate/{id}/{canId}:
|
|
* delete:
|
|
* summary: Delete a candidate from an election
|
|
* description: |
|
|
* Deletes a candidate from the specified election identified by its ID and the candidate's ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the election containing the candidate to be deleted.
|
|
* schema:
|
|
* type: string
|
|
* - in: path
|
|
* name: canId
|
|
* required: true
|
|
* description: The ID of the candidate to be deleted.
|
|
* schema:
|
|
* type: string
|
|
* produces:
|
|
* - application/json
|
|
* responses:
|
|
* '200':
|
|
* description: Candidate deleted successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "مشخصات کاندیدا با موفقیت حذف شد"
|
|
* '404':
|
|
* description: The specified election or candidate was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد" or "کاندید مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.delete(
|
|
"/election/candidate/:id/:canId",
|
|
electionController.deleteCandidate
|
|
);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/voter/{id}:
|
|
* post:
|
|
* summary: Add a voter to an election
|
|
* description: |
|
|
* Adds a voter to the specified election identified by its ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the election to which the voter will be added.
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* description: The first name of the voter.
|
|
* lastName:
|
|
* type: string
|
|
* description: The last name of the voter.
|
|
* nationalCode:
|
|
* type: string
|
|
* description: The national code of the voter (must be 10 characters long).
|
|
* username:
|
|
* type: string
|
|
* description: The username of the voter (min. 4 characters, Latin characters and symbols only, no whitespace).
|
|
* mobileNumber:
|
|
* type: string
|
|
* description: The mobile number of the voter.
|
|
* job:
|
|
* type: string
|
|
* description: The job of the voter.
|
|
* responses:
|
|
* '200':
|
|
* description: Voter added successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "اطلاعات رای دهنده با موفقیت ذخیره شد"
|
|
* '404':
|
|
* description: The specified election was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
/////////////// voter
|
|
router.post("/election/voter/:id", electionController.addVoter);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/voter/{id}:
|
|
* put:
|
|
* summary: Update a voter in an election
|
|
* description: |
|
|
* Updates a voter in the specified election identified by its ID.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the election in which the voter is updated.
|
|
* schema:
|
|
* type: string
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* voterId:
|
|
* type: string
|
|
* description: The ID of the voter to be updated.
|
|
* firstName:
|
|
* type: string
|
|
* description: The updated first name of the voter.
|
|
* lastName:
|
|
* type: string
|
|
* description: The updated last name of the voter.
|
|
* nationalCode:
|
|
* type: string
|
|
* description: The updated national code of the voter.
|
|
* mobileNumber:
|
|
* type: string
|
|
* description: The updated mobile number of the voter.
|
|
* job:
|
|
* type: string
|
|
* description: The updated job of the voter.
|
|
* responses:
|
|
* '200':
|
|
* description: Voter updated successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "اطلاعات رای دهنده با موفقیت ذخیره شد"
|
|
* '404':
|
|
* description: The specified election or voter was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.put("/election/voter/:id", electionController.updateVoter);
|
|
/**
|
|
* @swagger
|
|
* /admin/election/voter/{id}/{voterId}:
|
|
* delete:
|
|
* summary: Delete a voter from an election
|
|
* description: |
|
|
* Deletes a voter from the specified election identified by its ID and the ID of the voter.
|
|
* tags:
|
|
* - Election
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the election from which the voter is deleted.
|
|
* schema:
|
|
* type: string
|
|
* - in: path
|
|
* name: voterId
|
|
* required: true
|
|
* description: The ID of the voter to be deleted.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Voter deleted successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "کاربر با موفقیت حذف شد"
|
|
* '404':
|
|
* description: The specified election or voter was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "انتخابات مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.delete("/election/voter/:id/:voterId", electionController.deleteVoter);
|
|
/**
|
|
* @swagger
|
|
* /admin/meeting/{id}:
|
|
* put:
|
|
* summary: Update a meeting
|
|
* description: |
|
|
* Updates the details of a meeting specified by its ID.
|
|
* tags:
|
|
* - Meeting
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the meeting to be updated.
|
|
* schema:
|
|
* type: string
|
|
* - in: body
|
|
* name: body
|
|
* description: The meeting details to be updated.
|
|
* required: true
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* subject:
|
|
* type: string
|
|
* description:
|
|
* type: string
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* phoneNumber:
|
|
* type: string
|
|
* nationalCode:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Meeting updated successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description: Updated name of the meeting.
|
|
* subject:
|
|
* type: string
|
|
* description: Updated subject of the meeting.
|
|
* description:
|
|
* type: string
|
|
* description: Updated description of the meeting.
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* description: Updated email of the meeting.
|
|
* phoneNumber:
|
|
* type: string
|
|
* description: Updated phone number of the meeting.
|
|
* nationalCode:
|
|
* type: string
|
|
* description: Updated national code of the meeting.
|
|
* '404':
|
|
* description: The specified meeting was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "درخواست مورد نظر پیدا نشد"
|
|
* '422':
|
|
* description: Validation error. The request body contains invalid data.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Validation errors mapped by field names.
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
//////////// meeting
|
|
router.put("/meeting/:id", meetingController.updateMeeting);
|
|
/**
|
|
* @swagger
|
|
* /admin/meeting/{id}:
|
|
* delete:
|
|
* summary: Delete a meeting
|
|
* description: Deletes a meeting specified by its ID.
|
|
* tags:
|
|
* - Meeting
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the meeting to be deleted.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Meeting deleted successfully
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message.
|
|
* example: "Meeting deleted successfully"
|
|
* '404':
|
|
* description: The specified meeting was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "درخواست مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
|
|
router.delete("/meeting/:id", meetingController.deletOneMeeting);
|
|
/**
|
|
* @swagger
|
|
* /admin/meeting:
|
|
* get:
|
|
* summary: Get all meetings
|
|
* description: Retrieve all meetings.
|
|
* tags:
|
|
* - Meeting
|
|
* parameters:
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* description: The page number for pagination (default: 1)
|
|
* - in: query
|
|
* name: limit
|
|
* schema:
|
|
* type: integer
|
|
* description: The maximum number of meetings per page
|
|
* responses:
|
|
* '200':
|
|
* description: A list of meetings
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Meeting'
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: Total number of meetings
|
|
* totalPages:
|
|
* type: integer
|
|
* description: Total number of pages
|
|
* page:
|
|
* type: integer
|
|
* description: Current page number
|
|
* limit:
|
|
* type: integer
|
|
* description: Maximum number of meetings per page
|
|
* nextPage:
|
|
* type: integer
|
|
* description: Next page number (null if no next page)
|
|
* prevPage:
|
|
* type: integer
|
|
* description: Previous page number (null if no previous page)
|
|
* pagingCounter:
|
|
* type: integer
|
|
* description: Counter for pagination
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.get("/meeting", meetingController.getAll);
|
|
/**
|
|
* @swagger
|
|
* /admin/meeting/getCount:
|
|
* get:
|
|
* summary: Get count of all meetings
|
|
* description: Retrieve the total count of all meetings.
|
|
* tags:
|
|
* - Meeting
|
|
* responses:
|
|
* '200':
|
|
* description: The total count of meetings
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: integer
|
|
* description: Total count of meetings
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.get("/meeting/getCount", meetingController.getAllForCount);
|
|
/**
|
|
* @swagger
|
|
* /admin/meeting/search:
|
|
* post:
|
|
* summary: Search meetings
|
|
* description: Retrieve meetings based on search criteria.
|
|
* tags:
|
|
* - Meeting
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description: Name of the meeting.
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* description: Email address associated with the meeting.
|
|
* terms:
|
|
* type: string
|
|
* description: Search terms to match against the subject and description of the meeting.
|
|
* phoneNumber:
|
|
* type: string
|
|
* description: Phone number associated with the meeting.
|
|
* nationalCode:
|
|
* type: string
|
|
* description: National code associated with the meeting.
|
|
* read:
|
|
* type: boolean
|
|
* description: Indicates if the meeting has been read or not.
|
|
* date:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* format: date
|
|
* description: Range of dates for which meetings were created.
|
|
* responses:
|
|
* '200':
|
|
* description: Successfully retrieved meetings based on search criteria
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Meeting'
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.post("/meeting/search", meetingController.search);
|
|
/**
|
|
* @swagger
|
|
* /admin/meeting/{id}:
|
|
* get:
|
|
* summary: Get a meeting by ID
|
|
* description: Retrieve a meeting specified by its ID.
|
|
* tags:
|
|
* - Meeting
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the meeting to retrieve.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: Successfully retrieved the meeting
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Meeting'
|
|
* '404':
|
|
* description: The specified meeting was not found
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "درخواست مورد نظر پیدا نشد"
|
|
* '500':
|
|
* description: Internal Server Error. An error occurred while processing the request.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Error message.
|
|
* example: "مشکلی در اجرای درخواست شما بوجود آمده است"
|
|
*/
|
|
router.get("/meeting/:id", meetingController.getOneMeeting);
|
|
|
|
module.exports = router;
|