location controller updated with heading and created new models and controllers for remaining modules
This commit is contained in:
+263
-39
@@ -2,15 +2,19 @@ import { createAccess } from "../models/Access/operations.js";
|
|||||||
import { createRole, getAllRoles } from "../models/Role/operations.js";
|
import { createRole, getAllRoles } from "../models/Role/operations.js";
|
||||||
import {
|
import {
|
||||||
createDesignation,
|
createDesignation,
|
||||||
|
updateDesignation,
|
||||||
getAllDesignations,
|
getAllDesignations,
|
||||||
} from "../models/Designation/operations.js";
|
} from "../models/Designation/operations.js";
|
||||||
|
import { aggregateUser } from "../models/User/operations.js";
|
||||||
import {
|
import {
|
||||||
createDepartment,
|
createDepartment,
|
||||||
getAllDepartments,
|
getAllDepartments,
|
||||||
} from "../models/Department/operations.js";
|
} from "../models/Department/operations.js";
|
||||||
import { getAllVenues, createVenue } from "../models/Venue/operations.js";
|
import { getAllVenues, createVenue } from "../models/Venue/operations.js";
|
||||||
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
|
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
|
||||||
|
import { getLocationsByQuery } from "../models/Location/operations.js";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
|
||||||
export const createAccessController = async (req, res) => {
|
export const createAccessController = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
@@ -31,57 +35,36 @@ export const createAccessController = async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAllMetadataController = async (req, res) => {
|
export const updateDesignationController = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const roles = await getAllRoles();
|
const { id } = req.params;
|
||||||
const designations = await getAllDesignations();
|
const designation = await updateDesignation(id, req.body);
|
||||||
const departments = await getAllDepartments();
|
res.status(200).json({ result: designation });
|
||||||
const branches = await getAllVenues({ category: "OWN" });
|
|
||||||
const metadata = {
|
|
||||||
roles,
|
|
||||||
designations,
|
|
||||||
departments,
|
|
||||||
branches,
|
|
||||||
};
|
|
||||||
res.status(200).json({ result: metadata });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
console.log("updateDesignationController Error", error);
|
||||||
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAllRolesController = async (req, res) => {
|
export const updateDepartmentController = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const roles = await getAllRoles();
|
const { id } = req.params;
|
||||||
res.status(200).json({ result: roles });
|
const department = await updateDepartment(id, req.body);
|
||||||
|
res.status(200).json({ result: department });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
console.log("updateDepartmentController Error", error);
|
||||||
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAllDesignationsController = async (req, res) => {
|
export const updateRoleController = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const designations = await getAllDesignations();
|
const { id } = req.params;
|
||||||
res.status(200).json({ result: designations });
|
const role = await updateRole(id, req.body);
|
||||||
|
res.status(200).json({ result: role });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
console.log("updateRoleController Error", error);
|
||||||
}
|
next(error);
|
||||||
};
|
|
||||||
|
|
||||||
export const getAllDepartmentsController = async (req, res) => {
|
|
||||||
try {
|
|
||||||
const departments = await getAllDepartments();
|
|
||||||
res.status(200).json({ result: departments });
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ error: error.message });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getAllBranchesController = async (req, res) => {
|
|
||||||
try {
|
|
||||||
const branches = await getAllVenues({ category: "OWN" });
|
|
||||||
res.status(200).json({ result: branches });
|
|
||||||
} catch (error) {
|
|
||||||
res.status(500).json({ error: error.message });
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -149,3 +132,244 @@ export const createBranchController = async (req, res) => {
|
|||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAllEmployeeController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const pipeline = [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "profiles",
|
||||||
|
localField: "_id",
|
||||||
|
foreignField: "user",
|
||||||
|
as: "profile",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$profile",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "accesses",
|
||||||
|
localField: "_id",
|
||||||
|
foreignField: "user",
|
||||||
|
as: "access",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$access",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "designations",
|
||||||
|
localField: "access.designation",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "designation",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$designation",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "departments",
|
||||||
|
localField: "access.department",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "department",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$department",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 1,
|
||||||
|
name: 1,
|
||||||
|
id: 1,
|
||||||
|
profile: 1,
|
||||||
|
designation: "$designation.name",
|
||||||
|
department: "$department.name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const data = await aggregateUser(pipeline);
|
||||||
|
|
||||||
|
res.status(200).json({ result: data });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getAllEmployeeController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAllMetadataController = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const roles = await getAllRoles();
|
||||||
|
const designations = await getAllDesignations();
|
||||||
|
const departments = await getAllDepartments();
|
||||||
|
const branches = await getAllVenues({ category: "OWN" });
|
||||||
|
const metadata = {
|
||||||
|
roles,
|
||||||
|
designations,
|
||||||
|
departments,
|
||||||
|
branches,
|
||||||
|
};
|
||||||
|
res.status(200).json({ result: metadata });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAllBranchesController = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const branches = await getAllVenues({ category: "OWN" });
|
||||||
|
res.status(200).json({ result: branches });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEmployeeDetailsController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const pipeline = [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
_id: new ObjectId.createFromHexString(id),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "profiles",
|
||||||
|
localField: "_id",
|
||||||
|
foreignField: "user",
|
||||||
|
as: "profile",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$profile",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "accesses",
|
||||||
|
localField: "_id",
|
||||||
|
foreignField: "user",
|
||||||
|
as: "access",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$access",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "designations",
|
||||||
|
localField: "access.designation",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "designation",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$designation",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "departments",
|
||||||
|
localField: "access.department",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "department",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$department",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "roles",
|
||||||
|
localField: "access.role",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "role",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$role",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "venues",
|
||||||
|
localField: "access.branch",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "branches",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 1,
|
||||||
|
name: 1,
|
||||||
|
department: "$department.name",
|
||||||
|
designation: "$designation.name",
|
||||||
|
role: "$role.name",
|
||||||
|
profile: 1,
|
||||||
|
branches: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const [data] = await aggregateUser(pipeline);
|
||||||
|
res.status(200).json({ result: data });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getEmployeeDetails Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEmployeeLocationHistoryController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { user } = req.params;
|
||||||
|
const { date = dayjs().subtract(330, "minute").toISOString() } = req.query;
|
||||||
|
const start = dayjs(date).startOf("day").toISOString();
|
||||||
|
const end = dayjs(date).endOf("day").toISOString();
|
||||||
|
|
||||||
|
console.log("Start Date", start, end, user);
|
||||||
|
|
||||||
|
const locations = await getLocationsByQuery({
|
||||||
|
user,
|
||||||
|
createdOn: { $gte: start, $lte: end },
|
||||||
|
});
|
||||||
|
console.log("LOCATIONS", locations);
|
||||||
|
res.status(200).json({ result: locations });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getEmployeeLocationHistory Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import {
|
||||||
|
createAssignment,
|
||||||
|
updateAssignment,
|
||||||
|
getAssignmentsByQuery,
|
||||||
|
} from "../models/Assignment/operations.js";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
export const createAssignmentHandler = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { user } = res.locals;
|
||||||
|
const previousAssignment = await updateAssignment(req.body.venue, {
|
||||||
|
isActive: false,
|
||||||
|
});
|
||||||
|
const assignment = await createAssignment({
|
||||||
|
...req.body,
|
||||||
|
createdOn: dayjs().toISOString(),
|
||||||
|
createdBy: user.id,
|
||||||
|
});
|
||||||
|
res.status(201).json({ result: { assignment, previousAssignment } });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Error creating assignment", error });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateAssignmentHandler = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const assignment = await updateAssignment(id, req.body);
|
||||||
|
res.status(200).json({ result: assignment });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Error updating assignment", error });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAssignmentsByUserHandler = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const assignment = await getAssignmentsByQuery({ user: id });
|
||||||
|
res.status(200).json({ result: assignment });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Error getting assignment", error });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deactivateAssignmentHandler = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const assignment = await updateAssignment(id, { isActive: false });
|
||||||
|
res.status(200).json({ result: assignment });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Error deactivating assignment", error });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAssignmentByVenueHandler = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const assignment = await getAssignmentsByQuery({ venue: id });
|
||||||
|
res.status(200).json({ result: assignment });
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ message: "Error getting assignment", error });
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -4,6 +4,42 @@ import {
|
|||||||
getLocationByRadius,
|
getLocationByRadius,
|
||||||
} from "../models/Location/operations";
|
} from "../models/Location/operations";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sample Location Payload
|
||||||
|
|
||||||
|
{
|
||||||
|
"extras": {},
|
||||||
|
"activity": {
|
||||||
|
"confidence": 100,
|
||||||
|
"type": "still"
|
||||||
|
},
|
||||||
|
"timestamp": "2026-04-25T17:31:25.320Z",
|
||||||
|
"battery": {
|
||||||
|
"level": 0.57,
|
||||||
|
"is_charging": false
|
||||||
|
},
|
||||||
|
"recorded_at": "2026-04-25T17:31:25.388Z",
|
||||||
|
"age": 0.074,
|
||||||
|
"is_moving": false,
|
||||||
|
"event": "motionchange",
|
||||||
|
"uuid": "4c476d94-b7db-4823-9270-805235ed0ec8",
|
||||||
|
"coords": {
|
||||||
|
"ellipsoidal_altitude": 0,
|
||||||
|
"altitude": 0,
|
||||||
|
"altitude_accuracy": 0.5,
|
||||||
|
"heading_accuracy": -1,
|
||||||
|
"heading": -1,
|
||||||
|
"speed": 0,
|
||||||
|
"accuracy": 5,
|
||||||
|
"longitude": 77.48675,
|
||||||
|
"speed_accuracy": 0.5,
|
||||||
|
"latitude": 9.9707883
|
||||||
|
},
|
||||||
|
"odometer_error": 0,
|
||||||
|
"odometer": 0
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
export const createLocationController = async (req, res) => {
|
export const createLocationController = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { user } = res.locals;
|
const { user } = res.locals;
|
||||||
@@ -11,6 +47,9 @@ export const createLocationController = async (req, res) => {
|
|||||||
const dbPayload = {
|
const dbPayload = {
|
||||||
battery: location.battery.level,
|
battery: location.battery.level,
|
||||||
coordinates: location.coords,
|
coordinates: location.coords,
|
||||||
|
event: location.event,
|
||||||
|
heading: location.coords.heading,
|
||||||
|
activity: location?.activity?.type,
|
||||||
recorded_at: location.recorded_at,
|
recorded_at: location.recorded_at,
|
||||||
};
|
};
|
||||||
const uploaded = await createLocation({ ...dbPayload, user: user?.id });
|
const uploaded = await createLocation({ ...dbPayload, user: user?.id });
|
||||||
|
|||||||
@@ -0,0 +1,194 @@
|
|||||||
|
import {
|
||||||
|
createPartner,
|
||||||
|
getPartnerById,
|
||||||
|
getPartnerByQuery,
|
||||||
|
getPartnersByQuery,
|
||||||
|
getAllPartners,
|
||||||
|
updatePartner,
|
||||||
|
aggregatePartner,
|
||||||
|
} from "../models/Partner/operations";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
|
||||||
|
export const createPartnerController = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { user } = res.locals;
|
||||||
|
const partner = await createPartner({
|
||||||
|
...req.body,
|
||||||
|
createdBy: user.id,
|
||||||
|
createdOn: dayjs().toISOString(),
|
||||||
|
});
|
||||||
|
res.status(200).json({ result: partner });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("createPartnerController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPartnerController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const pipeline = [
|
||||||
|
// 1. Match the specific partner (Satisfies Req #1)
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
_id: ObjectId.createFromHexString(id),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// 2. Fetch all invoices for this partner
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "invoices", // Ensure this matches your actual collection name
|
||||||
|
localField: "_id",
|
||||||
|
foreignField: "customer",
|
||||||
|
as: "partnerInvoices",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// 3. Calculate Invoice Metrics without unwinding (Satisfies Reqs #3, #4, #5)
|
||||||
|
{
|
||||||
|
$addFields: {
|
||||||
|
totalInvoicesCount: { $size: "$partnerInvoices" },
|
||||||
|
pendingOrPartialInvoicesCount: {
|
||||||
|
$size: {
|
||||||
|
$filter: {
|
||||||
|
input: "$partnerInvoices",
|
||||||
|
as: "invoice",
|
||||||
|
cond: {
|
||||||
|
$in: ["$$invoice.status", ["PENDING", "PARTIAL"]],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Note: Your schema uses "PAID", assuming that correlates to "COMPLETED"
|
||||||
|
totalInvoicesAmount: { $sum: "$partnerInvoices.total" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// 4. Remove the heavy invoices array from memory before doing more lookups
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
partnerInvoices: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// 5. Lookup Venues and nested Users/Profiles (Satisfies Reqs #2 & #6)
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "venues",
|
||||||
|
let: { partnerId: "$_id" },
|
||||||
|
pipeline: [
|
||||||
|
// Match venues to the partner (Assuming 'entity' field links to Partner _id)
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$expr: { $eq: ["$entity", "$$partnerId"] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Lookup Assignments for this specific venue
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "assignments",
|
||||||
|
let: { venueId: "$_id" },
|
||||||
|
pipeline: [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$expr: { $eq: ["$venue", "$$venueId"] },
|
||||||
|
isActive: true, // Optional: ensuring we only get active assignments
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Lookup the User for the assignment
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "users",
|
||||||
|
localField: "user",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "userDetails",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$userDetails",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Lookup the Profile for the assigned User
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "profiles",
|
||||||
|
localField: "user",
|
||||||
|
foreignField: "user",
|
||||||
|
as: "userProfile",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$userProfile",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Clean up the assignment shape
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 1,
|
||||||
|
targetedVisits: 1,
|
||||||
|
user: "$userDetails",
|
||||||
|
profile: "$userProfile",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: "assignedUsers",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: "venues",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const partner = await aggregatePartner(pipeline);
|
||||||
|
|
||||||
|
if (!partner?.length) {
|
||||||
|
throw new Error("Partner not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
res.status(200).json({ result: partner[0] || {} });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getPartnerController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAllPartnersController = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const partners = await getAllPartners();
|
||||||
|
res.status(200).json({ result: partners });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getAllPartnersController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updatePartnerController = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const partner = await updatePartner(id, req.body);
|
||||||
|
res.status(200).json({ result: partner });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("updatePartnerController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deletePartnerController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const partner = await updatePartner(id, { isActive: false });
|
||||||
|
res.status(200).json({ result: partner });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("deletePartnerController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -20,7 +20,7 @@ export const createOrEditProfileController = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProfileController = async (req, res, next) => {
|
export const getOwnProfileController = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const { user } = res.locals;
|
const { user } = res.locals;
|
||||||
const profile = await getProfileByQuery({ userId: user.id });
|
const profile = await getProfileByQuery({ userId: user.id });
|
||||||
@@ -30,4 +30,3 @@ export const getProfileController = async (req, res, next) => {
|
|||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import {
|
||||||
|
createVenue,
|
||||||
|
getVenueById,
|
||||||
|
getVenuesByQuery,
|
||||||
|
getAllVenues,
|
||||||
|
updateVenue,
|
||||||
|
aggregateVenue,
|
||||||
|
} from "../models/Venue/operations.js";
|
||||||
|
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
export const createVenueController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { user } = res.locals;
|
||||||
|
|
||||||
|
const { location } = req.body;
|
||||||
|
|
||||||
|
const geoJson = coordinatesToGeoJson({
|
||||||
|
latitude: location.lat,
|
||||||
|
longitude: location.lng,
|
||||||
|
});
|
||||||
|
const dbPayload = {
|
||||||
|
...req.body,
|
||||||
|
location: geoJson,
|
||||||
|
createdBy: user.id,
|
||||||
|
createdOn: dayjs().toISOString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
const venue = await createVenue(dbPayload);
|
||||||
|
|
||||||
|
res.status(200).json({ result: venue });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("createVenueController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteVenueController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const venue = await updateVenue(id, { isActive: false });
|
||||||
|
|
||||||
|
res.status(200).json({ result: venue });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("deleteVenueController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getVenuesByEntityController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
const venues = await getVenuesByQuery({ entity: id });
|
||||||
|
res.status(200).json({ result: venues });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getVenuesByEntity Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getVenueController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const venue = await getVenueById(id);
|
||||||
|
res.status(200).json({ result: venue });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getVenueController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
|
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
|
||||||
import bcrypt from "bcryptjs";
|
import bcrypt from "bcrypt";
|
||||||
|
|
||||||
export const createEmployee = async (req, res) => {
|
export const createEmployee = async (req, res) => {
|
||||||
const session = await mongoose.startSession();
|
const session = await mongoose.startSession();
|
||||||
@@ -41,7 +41,7 @@ export const createEmployee = async (req, res) => {
|
|||||||
throw { code: 400, message: "ID already assigned for Another Employee" };
|
throw { code: 400, message: "ID already assigned for Another Employee" };
|
||||||
}
|
}
|
||||||
|
|
||||||
const employee = await User.create(
|
const [employee] = await User.create(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
@@ -49,11 +49,15 @@ export const createEmployee = async (req, res) => {
|
|||||||
hash,
|
hash,
|
||||||
createdOn: dayjs().toISOString(),
|
createdOn: dayjs().toISOString(),
|
||||||
createdBy: user.id,
|
createdBy: user.id,
|
||||||
|
isFirstTime: true,
|
||||||
|
isActive: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
{ session },
|
{ session },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log("EMPLOYEE", employee);
|
||||||
|
|
||||||
const profile = await Profile.create(
|
const profile = await Profile.create(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@@ -83,8 +87,13 @@ export const createEmployee = async (req, res) => {
|
|||||||
],
|
],
|
||||||
{ session },
|
{ session },
|
||||||
);
|
);
|
||||||
|
await session.commitTransaction();
|
||||||
|
session.endSession();
|
||||||
res.status(200).json({ result: access });
|
res.status(200).json({ result: access });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("createEmployee Error", error);
|
||||||
|
await session.abortTransaction();
|
||||||
|
session.endSession();
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+56
-16
@@ -60,10 +60,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"/admin/designations": {
|
"/admin/metadata": {
|
||||||
get: {
|
get: {
|
||||||
tags: ["Admin"],
|
tags: ["Admin"],
|
||||||
summary: "Get All Designations",
|
summary: "Get All Metadata",
|
||||||
responses: {
|
responses: {
|
||||||
200: {
|
200: {
|
||||||
description: "OK",
|
description: "OK",
|
||||||
@@ -72,22 +72,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"/admin/departments": {
|
"/admin/employees": {
|
||||||
get: {
|
get: {
|
||||||
tags: ["Admin"],
|
tags: ["Admin"],
|
||||||
summary: "Get All Departments",
|
summary: "Get All Employees",
|
||||||
responses: {
|
|
||||||
200: {
|
|
||||||
description: "OK",
|
|
||||||
content: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"/admin/roles": {
|
|
||||||
get: {
|
|
||||||
tags: ["Admin"],
|
|
||||||
summary: "Get All Roles",
|
|
||||||
responses: {
|
responses: {
|
||||||
200: {
|
200: {
|
||||||
description: "OK",
|
description: "OK",
|
||||||
@@ -238,4 +226,56 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"/admin/employee/{id}": {
|
||||||
|
get: {
|
||||||
|
tags: ["Admin"],
|
||||||
|
summary: "Get Employee Details by ID",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/admin/employee/{user}/locations": {
|
||||||
|
get: {
|
||||||
|
tags: ["Admin"],
|
||||||
|
summary: "Get Employee Details by ID",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "user",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: "query",
|
||||||
|
name: "date",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
export default {
|
||||||
|
"/assignment": {
|
||||||
|
post: {
|
||||||
|
tags: ["Assignment"],
|
||||||
|
summary: "Create an assignment",
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
user: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
venue: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
targetedVisits: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/assignment/{id}": {
|
||||||
|
patch: {
|
||||||
|
tags: ["Assignment"],
|
||||||
|
summary: "Update an assignment",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
user: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
venue: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
targetedVisits: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
tags: ["Assignment"],
|
||||||
|
summary: "Delete an assignment",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/assignment/user/{id}": {
|
||||||
|
get: {
|
||||||
|
tags: ["Assignment"],
|
||||||
|
summary: "Get all assignments for a user",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
description: "User ID",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/assignment/venue/{id}": {
|
||||||
|
get: {
|
||||||
|
tags: ["Assignment"],
|
||||||
|
summary: "Get all assignments for a Venue",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
description: "Venue ID",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -343,12 +343,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/admin/designations": {
|
"/admin/metadata": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Admin"
|
"Admin"
|
||||||
],
|
],
|
||||||
"summary": "Get All Designations",
|
"summary": "Get All Metadata",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
@@ -357,26 +357,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/admin/departments": {
|
"/admin/employees": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"Admin"
|
"Admin"
|
||||||
],
|
],
|
||||||
"summary": "Get All Departments",
|
"summary": "Get All Employees",
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "OK",
|
|
||||||
"content": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admin/roles": {
|
|
||||||
"get": {
|
|
||||||
"tags": [
|
|
||||||
"Admin"
|
|
||||||
],
|
|
||||||
"summary": "Get All Roles",
|
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
@@ -534,6 +520,602 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/admin/employee/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Admin"
|
||||||
|
],
|
||||||
|
"summary": "Get Employee Details by ID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/admin/employee/{user}/locations": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Admin"
|
||||||
|
],
|
||||||
|
"summary": "Get Employee Details by ID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "user",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "date",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/assignment": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"Assignment"
|
||||||
|
],
|
||||||
|
"summary": "Create an assignment",
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"venue": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"targetedVisits": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/assignment/{id}": {
|
||||||
|
"patch": {
|
||||||
|
"tags": [
|
||||||
|
"Assignment"
|
||||||
|
],
|
||||||
|
"summary": "Update an assignment",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"user": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"venue": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"targetedVisits": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"tags": [
|
||||||
|
"Assignment"
|
||||||
|
],
|
||||||
|
"summary": "Delete an assignment",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/assignment/user/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Assignment"
|
||||||
|
],
|
||||||
|
"summary": "Get all assignments for a user",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "User ID",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/assignment/venue/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Assignment"
|
||||||
|
],
|
||||||
|
"summary": "Get all assignments for a Venue",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "Venue ID",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/partner": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Partner"
|
||||||
|
],
|
||||||
|
"summary": "Get all Partners",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"Partner"
|
||||||
|
],
|
||||||
|
"summary": "Create New Partner",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"city": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"pincode": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"contactPersons": {
|
||||||
|
"type": "array",
|
||||||
|
"required": true,
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"mobile": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"designation": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/partner/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Partner"
|
||||||
|
],
|
||||||
|
"summary": "Get Partner Details by ID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"patch": {
|
||||||
|
"tags": [
|
||||||
|
"Partner"
|
||||||
|
],
|
||||||
|
"summary": "Update Partner Details by ID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"city": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"pincode": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"contactPersons": {
|
||||||
|
"type": "array",
|
||||||
|
"required": true,
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"mobile": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"designation": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"tags": [
|
||||||
|
"Partner"
|
||||||
|
],
|
||||||
|
"summary": "Deactivate Partner by ID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/venue/": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"Venues"
|
||||||
|
],
|
||||||
|
"summary": "Create New Venue",
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"category": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"city": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"pincode": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"contactPerson": {
|
||||||
|
"type": "object",
|
||||||
|
"required": true,
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"mobile": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"designation": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"location": {
|
||||||
|
"type": "object",
|
||||||
|
"required": true,
|
||||||
|
"properties": {
|
||||||
|
"latitude": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"longitude": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/venue/entity/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Venues"
|
||||||
|
],
|
||||||
|
"summary": "Get Venues by Entity",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "Entity ID",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"response": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/venue/{id}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Venues"
|
||||||
|
],
|
||||||
|
"summary": "Get Venue by ID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "Venue ID",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"respose": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"tags": [
|
||||||
|
"Venues"
|
||||||
|
],
|
||||||
|
"summary": "Delete Venue by ID",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id",
|
||||||
|
"description": "Venue ID",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"respose": {
|
||||||
|
"200": {
|
||||||
|
"description": "Success",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,10 @@ import upload from "./upload.js";
|
|||||||
import user from "./user.js";
|
import user from "./user.js";
|
||||||
import profile from "./profile.js";
|
import profile from "./profile.js";
|
||||||
import admin from "./admin.js";
|
import admin from "./admin.js";
|
||||||
import location from "./location.js"
|
import location from "./location.js";
|
||||||
|
import assignment from "./assignment.js";
|
||||||
|
import partner from "./partner.js";
|
||||||
|
import venue from "./venue.js";
|
||||||
|
|
||||||
const GENERAL_CONFIG = {
|
const GENERAL_CONFIG = {
|
||||||
openapi: "3.0.1",
|
openapi: "3.0.1",
|
||||||
@@ -47,6 +50,9 @@ let paths = {
|
|||||||
...location,
|
...location,
|
||||||
...upload,
|
...upload,
|
||||||
...admin,
|
...admin,
|
||||||
|
...assignment,
|
||||||
|
...partner,
|
||||||
|
...venue,
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSwaggerDocument = () => {
|
const getSwaggerDocument = () => {
|
||||||
|
|||||||
@@ -0,0 +1,216 @@
|
|||||||
|
export default {
|
||||||
|
"/partner": {
|
||||||
|
get: {
|
||||||
|
tags: ["Partner"],
|
||||||
|
summary: "Get all Partners",
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
post: {
|
||||||
|
tags: ["Partner"],
|
||||||
|
summary: "Create New Partner",
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
phone: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
pincode: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
contactPersons: {
|
||||||
|
type: "array",
|
||||||
|
required: true,
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
mobile: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
designation: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/partner/{id}": {
|
||||||
|
get: {
|
||||||
|
tags: ["Partner"],
|
||||||
|
summary: "Get Partner Details by ID",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
patch: {
|
||||||
|
tags: ["Partner"],
|
||||||
|
summary: "Update Partner Details by ID",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
phone: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
pincode: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
contactPersons: {
|
||||||
|
type: "array",
|
||||||
|
required: true,
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
mobile: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
designation: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
tags: ["Partner"],
|
||||||
|
summary: "Deactivate Partner by ID",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import { response } from "express";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
"/venue/": {
|
||||||
|
post: {
|
||||||
|
tags: ["Venues"],
|
||||||
|
summary: "Create New Venue",
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
category: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
entity: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
pincode: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
contactPerson: {
|
||||||
|
type: "object",
|
||||||
|
required: true,
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
mobile: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
designation: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
location: {
|
||||||
|
type: "object",
|
||||||
|
required: true,
|
||||||
|
properties: {
|
||||||
|
latitude: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
longitude: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/venue/entity/{id}": {
|
||||||
|
get: {
|
||||||
|
tags: ["Venues"],
|
||||||
|
summary: "Get Venues by Entity",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
description: "Entity ID",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
response: {
|
||||||
|
200: {
|
||||||
|
description: "Success",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/venue/{id}": {
|
||||||
|
get: {
|
||||||
|
tags: ["Venues"],
|
||||||
|
summary: "Get Venue by ID",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
description: "Venue ID",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
respose: {
|
||||||
|
200: {
|
||||||
|
description: "Success",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
tags: ["Venues"],
|
||||||
|
summary: "Delete Venue by ID",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
description: "Venue ID",
|
||||||
|
required: true,
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
respose: {
|
||||||
|
200: {
|
||||||
|
description: "Success",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -11,7 +11,14 @@ import swaggerUi from "swagger-ui-express";
|
|||||||
import swaggerDoc from "./documentation/documentation.json";
|
import swaggerDoc from "./documentation/documentation.json";
|
||||||
import getSwaggerDocument from "./documentation";
|
import getSwaggerDocument from "./documentation";
|
||||||
// import socketState from "./state/socketState.js";
|
// import socketState from "./state/socketState.js";
|
||||||
import { AdminRoutes, UserRoutes, LocationRoutes } from "./routes";
|
import {
|
||||||
|
AdminRoutes,
|
||||||
|
UserRoutes,
|
||||||
|
LocationRoutes,
|
||||||
|
AssignmentRoutes,
|
||||||
|
PartnerRoutes,
|
||||||
|
VenueRoutes
|
||||||
|
} from "./routes";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
@@ -44,6 +51,9 @@ app.use("/v0/docs", swaggerUi.serve, swaggerUi.setup(swaggerDoc));
|
|||||||
app.use("/v0/user", UserRoutes);
|
app.use("/v0/user", UserRoutes);
|
||||||
app.use("/v0/admin", AdminRoutes);
|
app.use("/v0/admin", AdminRoutes);
|
||||||
app.use("/v0/location", LocationRoutes);
|
app.use("/v0/location", LocationRoutes);
|
||||||
|
app.use("/v0/assignment", AssignmentRoutes);
|
||||||
|
app.use("/v0/partner", PartnerRoutes);
|
||||||
|
app.use("/v0/venue", VenueRoutes);
|
||||||
|
|
||||||
app.use((err, req, res, next) => {
|
app.use((err, req, res, next) => {
|
||||||
const statusCode = err.status || 500;
|
const statusCode = err.status || 500;
|
||||||
|
|||||||
@@ -1,5 +1,34 @@
|
|||||||
import { model, Schema, Types } from "mongoose";
|
import { model, Schema, Types } from "mongoose";
|
||||||
|
|
||||||
const schema = new Schema({});
|
const schema = new Schema({
|
||||||
|
createdOn: {
|
||||||
|
type: Date,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
createdBy: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
required: true,
|
||||||
|
ref: "user",
|
||||||
|
},
|
||||||
|
isActive: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
required: true,
|
||||||
|
ref: "user",
|
||||||
|
},
|
||||||
|
venue: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
required: true,
|
||||||
|
ref: "venue",
|
||||||
|
},
|
||||||
|
targetedVisits: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
default: 5,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export default model("assignment", schema);
|
export default model("assignment", schema);
|
||||||
|
|||||||
@@ -10,11 +10,16 @@ export const getAssignmentById = async (id) => {
|
|||||||
return await Model.findById(id);
|
return await Model.findById(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read (Get by Query)
|
// Read (Get One by Query)
|
||||||
export const getAssignmentByQuery = async (query) => {
|
export const getAssignmentByQuery = async (query) => {
|
||||||
return await Model.findOne(query);
|
return await Model.findOne(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read (Get All by Query)
|
||||||
|
export const getAssignmentsByQuery = async (query) => {
|
||||||
|
return await Model.find(query);
|
||||||
|
};
|
||||||
|
|
||||||
// Read (Get all)
|
// Read (Get all)
|
||||||
export const getAllAssignments = async () => {
|
export const getAllAssignments = async () => {
|
||||||
return await Model.find();
|
return await Model.find();
|
||||||
|
|||||||
+104
-1
@@ -1,5 +1,108 @@
|
|||||||
import { model, Schema, Types } from "mongoose";
|
import { model, Schema, Types } from "mongoose";
|
||||||
|
|
||||||
const schema = new Schema({});
|
const paymentHistorySchema = new Schema({
|
||||||
|
amount: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
paymentDate: {
|
||||||
|
type: Date,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
paymentMethod: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
transactionId: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
createdOn: {
|
||||||
|
type: Date,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
createdBy: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
ref: "user",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const itemSchema = new Schema({
|
||||||
|
id: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
unitCostPrice: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
unitSellingPrice: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
qty: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
taxPercent: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
taxAmount: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
discount: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
total: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const schema = new Schema({
|
||||||
|
customer: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
ref: "partner",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
items: {
|
||||||
|
type: [itemSchema],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
netTotal: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
total: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
type: String,
|
||||||
|
enum: ["PENDING", "COMPLETED", "PARTIAL"],
|
||||||
|
default: "PENDING",
|
||||||
|
},
|
||||||
|
dueDate: {
|
||||||
|
type: Date,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
createdOn: {
|
||||||
|
type: Date,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
createdBy: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
ref: "user",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
paymentHistory: {
|
||||||
|
type: [paymentHistorySchema],
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export default model("invoice", schema);
|
export default model("invoice", schema);
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
import { model, Schema, Types } from "mongoose";
|
import { model, Schema, Types } from "mongoose";
|
||||||
import { locationSchema } from "../../helpers";
|
import { locationSchema } from "../../helpers";
|
||||||
|
|
||||||
|
const geofenceSchema = new Schema({
|
||||||
|
venue: {
|
||||||
|
type: Types.ObjectId,
|
||||||
|
required: false,
|
||||||
|
ref: "venue",
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const schema = new Schema({
|
const schema = new Schema({
|
||||||
user: {
|
user: {
|
||||||
type: Types.ObjectId,
|
type: Types.ObjectId,
|
||||||
@@ -16,10 +28,21 @@ const schema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
venue: {
|
event: {
|
||||||
type: Types.ObjectId,
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
activity: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
heading: {
|
||||||
|
type: Number,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
geofence: {
|
||||||
|
type: geofenceSchema,
|
||||||
required: false,
|
required: false,
|
||||||
ref: "venue",
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ export const getLocationById = async (id) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Read (Get by Query)
|
// Read (Get by Query)
|
||||||
export const getLocationByQuery = async (query) => {
|
export const getLocationsByQuery = async (query) => {
|
||||||
return await Model.findOne(query).sort({ createdOn: -1 });
|
console.log("QUERY", query);
|
||||||
|
return await Model.find(query).sort({ createdOn: -1 });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read (Get by Radius)
|
// Read (Get by Radius)
|
||||||
export const getLocationByRadius = async (radius) => {
|
export const getLocationsByRadius = async (radius) => {
|
||||||
return await Model.find(query);
|
return await Model.find(query);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+16
-2
@@ -20,10 +20,17 @@ const contactPersonSchema = new Schema({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const schema = new Schema({
|
const schema = new Schema({
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
tags: {
|
||||||
|
type: [String],
|
||||||
|
},
|
||||||
createdBy: {
|
createdBy: {
|
||||||
type: Types.ObjectId,
|
type: Types.ObjectId,
|
||||||
required: true,
|
required: true,
|
||||||
@@ -37,7 +44,7 @@ const schema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
mobile: {
|
phone: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
@@ -57,11 +64,18 @@ const schema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
gst: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
isActive: {
|
isActive: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
contactPersons: [contactPersonSchema],
|
contactPersons: {
|
||||||
|
type: [contactPersonSchema],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default model("partner", schema);
|
export default model("partner", schema);
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ export const getPartnerById = async (id) => {
|
|||||||
// Read (Get by Query)
|
// Read (Get by Query)
|
||||||
export const getPartnerByQuery = async (query) => {
|
export const getPartnerByQuery = async (query) => {
|
||||||
return await Model.findOne(query);
|
return await Model.findOne(query);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Read (Get all)
|
||||||
|
export const getPartnersByQuery = async (query) => {
|
||||||
|
return await Model.find(query);
|
||||||
|
};
|
||||||
|
|
||||||
// Read (Get all)
|
// Read (Get all)
|
||||||
export const getAllPartners = async () => {
|
export const getAllPartners = async () => {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ const schema = new Schema({
|
|||||||
user: {
|
user: {
|
||||||
type: Types.ObjectId,
|
type: Types.ObjectId,
|
||||||
required: true,
|
required: true,
|
||||||
|
ref: 'user'
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const schema = new Schema({
|
|||||||
},
|
},
|
||||||
refreshToken: {
|
refreshToken: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: false,
|
||||||
},
|
},
|
||||||
isFirstTime: {
|
isFirstTime: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
@@ -1,6 +1,25 @@
|
|||||||
import { model, Schema, Types } from "mongoose";
|
import { model, Schema, Types } from "mongoose";
|
||||||
import { locationSchema } from "../../helpers";
|
import { locationSchema } from "../../helpers";
|
||||||
|
|
||||||
|
const contactPersonSchema = new Schema({
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
mobile: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
designation: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const schema = new Schema({
|
const schema = new Schema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -47,6 +66,10 @@ const schema = new Schema({
|
|||||||
type: Types.ObjectId,
|
type: Types.ObjectId,
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
|
contactPerson: {
|
||||||
|
type: contactPersonSchema,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
schema.index({ location: "2dsphere" });
|
schema.index({ location: "2dsphere" });
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ export const getVenueById = async (id) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Read (Get by Query)
|
// Read (Get by Query)
|
||||||
export const getVenueByQuery = async (query) => {
|
export const getVenuesByQuery = async (query) => {
|
||||||
return await Model.findOne(query);
|
return await Model.find(query);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read (Get all)
|
// Read (Get all)
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ import {
|
|||||||
createDepartmentController,
|
createDepartmentController,
|
||||||
createDesignationController,
|
createDesignationController,
|
||||||
createRoleController,
|
createRoleController,
|
||||||
|
getAllEmployeeController,
|
||||||
|
getEmployeeDetailsController,
|
||||||
|
getEmployeeLocationHistoryController,
|
||||||
} from "../controllers/admin.controller";
|
} from "../controllers/admin.controller";
|
||||||
|
import { createEmployee } from "../controllers/workflow.controller";
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
@@ -25,6 +29,22 @@ router.post(
|
|||||||
authorize("department", "write"),
|
authorize("department", "write"),
|
||||||
createDepartmentController,
|
createDepartmentController,
|
||||||
);
|
);
|
||||||
|
router.get(
|
||||||
|
"/employees",
|
||||||
|
authorize("employee", "read"),
|
||||||
|
getAllEmployeeController,
|
||||||
|
);
|
||||||
|
router.post("/employee", authorize("employee", "write"), createEmployee);
|
||||||
|
router.get(
|
||||||
|
"/employee/:id",
|
||||||
|
authorize("employee", "read"),
|
||||||
|
getEmployeeDetailsController,
|
||||||
|
);
|
||||||
|
router.get(
|
||||||
|
"/employee/:user/locations",
|
||||||
|
authorize("employee", "read"),
|
||||||
|
getEmployeeLocationHistoryController,
|
||||||
|
);
|
||||||
router.post(
|
router.post(
|
||||||
"/designation",
|
"/designation",
|
||||||
authorize("designation", "write"),
|
authorize("designation", "write"),
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import {
|
||||||
|
createAssignmentHandler,
|
||||||
|
updateAssignmentHandler,
|
||||||
|
getAssignmentsByUserHandler,
|
||||||
|
deactivateAssignmentHandler,
|
||||||
|
getAssignmentByVenueHandler,
|
||||||
|
} from "../controllers/assignment.controller";
|
||||||
|
import {authorize} from "../middlewares/jwt.middleware";
|
||||||
|
|
||||||
|
const router = new Router();
|
||||||
|
|
||||||
|
router.post("/", authorize("assignment", "write"), createAssignmentHandler);
|
||||||
|
router.patch("/:id", authorize("assignment", "write"), updateAssignmentHandler);
|
||||||
|
router.get("/user/:id", authorize("assignment", "read"), getAssignmentsByUserHandler);
|
||||||
|
router.delete("/:id", authorize("assignment", "write"), deactivateAssignmentHandler);
|
||||||
|
router.get("/venue/:id", authorize("assignment", "read"), getAssignmentByVenueHandler);
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -2,3 +2,6 @@ export { default as UserRoutes } from "./user.route";
|
|||||||
export { default as ProfileRoutes } from "./profile.route";
|
export { default as ProfileRoutes } from "./profile.route";
|
||||||
export { default as AdminRoutes } from "./admin.route";
|
export { default as AdminRoutes } from "./admin.route";
|
||||||
export { default as LocationRoutes } from "./location.route";
|
export { default as LocationRoutes } from "./location.route";
|
||||||
|
export { default as AssignmentRoutes } from "./assignment.route";
|
||||||
|
export { default as VenueRoutes } from "./venue.route";
|
||||||
|
export { default as PartnerRoutes } from "./partner.route";
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import {
|
||||||
|
createPartnerController,
|
||||||
|
getPartnerController,
|
||||||
|
getPartnersController,
|
||||||
|
getAllPartnersController,
|
||||||
|
updatePartnerController,
|
||||||
|
deletePartnerController,
|
||||||
|
} from "../controllers/partner.controller";
|
||||||
|
import { authorize } from "../middlewares/jwt.middleware";
|
||||||
|
|
||||||
|
const router = new Router();
|
||||||
|
|
||||||
|
router.post("/", authorize("partner", "write"), createPartnerController);
|
||||||
|
router.get("/", authorize("partner", "read"), getAllPartnersController);
|
||||||
|
router.get("/:id", authorize("partner", "read"), getPartnerController);
|
||||||
|
router.patch("/:id", authorize("partner", "write"), updatePartnerController);
|
||||||
|
router.delete("/:id", authorize("partner", "write"), deletePartnerController);
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import {
|
import {
|
||||||
createOrEditProfileController,
|
createOrEditProfileController,
|
||||||
getProfileController,
|
getOwnProfileController,
|
||||||
} from "../controllers/profile.controller";
|
} from "../controllers/profile.controller";
|
||||||
import { authorize } from "../middlewares/jwt.middleware";
|
import { authorize } from "../middlewares/jwt.middleware";
|
||||||
|
|
||||||
@@ -12,6 +12,6 @@ router.post(
|
|||||||
authorize("generic", "generic"),
|
authorize("generic", "generic"),
|
||||||
createOrEditProfileController,
|
createOrEditProfileController,
|
||||||
);
|
);
|
||||||
router.get("/", authorize("generic", "generic"), getProfileController);
|
router.get("/", authorize("generic", "generic"), getOwnProfileController);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import {
|
||||||
|
createVenueController,
|
||||||
|
deleteVenueController,
|
||||||
|
getVenuesByEntityController,
|
||||||
|
getVenueController,
|
||||||
|
} from "../controllers/venue.controller";
|
||||||
|
import { authorize } from "../middlewares/jwt.middleware";
|
||||||
|
|
||||||
|
const router = new Router();
|
||||||
|
|
||||||
|
router.post("/", authorize("venue", "write"), createVenueController);
|
||||||
|
router.get(
|
||||||
|
"/entity/:id",
|
||||||
|
authorize("venue", "read"),
|
||||||
|
getVenuesByEntityController,
|
||||||
|
);
|
||||||
|
router.get("/:id", authorize("venue", "read"), getVenueController);
|
||||||
|
router.delete("/:id", authorize("venue", "write"), deleteVenueController);
|
||||||
|
|
||||||
|
export default router;
|
||||||
Reference in New Issue
Block a user