Operational Endpoints for Admin, Products, Assignments, Location, Vendor, Venue completed. Geofence Testing PEnding
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
import { createAccess } from "../models/Access/operations.js";
|
import { createAccess } from "../models/Access/operations.js";
|
||||||
import { createRole, getAllRoles } from "../models/Role/operations.js";
|
import {
|
||||||
|
createRole,
|
||||||
|
getAllRoles,
|
||||||
|
updateRole,
|
||||||
|
} from "../models/Role/operations.js";
|
||||||
import {
|
import {
|
||||||
createDesignation,
|
createDesignation,
|
||||||
updateDesignation,
|
updateDesignation,
|
||||||
@@ -60,6 +64,7 @@ export const updateDepartmentController = async (req, res, next) => {
|
|||||||
export const updateRoleController = async (req, res, next) => {
|
export const updateRoleController = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
console.log("REQ BODY", req.body, id);
|
||||||
const role = await updateRole(id, req.body);
|
const role = await updateRole(id, req.body);
|
||||||
res.status(200).json({ result: role });
|
res.status(200).json({ result: role });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -78,6 +83,7 @@ export const createRoleController = async (req, res) => {
|
|||||||
});
|
});
|
||||||
res.status(200).json({ result: role });
|
res.status(200).json({ result: role });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("createRoleController Error", error);
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -251,7 +257,7 @@ export const getEmployeeDetailsController = async (req, res, next) => {
|
|||||||
const pipeline = [
|
const pipeline = [
|
||||||
{
|
{
|
||||||
$match: {
|
$match: {
|
||||||
_id: new ObjectId.createFromHexString(id),
|
_id: ObjectId.createFromHexString(id),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -336,9 +342,9 @@ export const getEmployeeDetailsController = async (req, res, next) => {
|
|||||||
$project: {
|
$project: {
|
||||||
_id: 1,
|
_id: 1,
|
||||||
name: 1,
|
name: 1,
|
||||||
department: "$department.name",
|
department: 1,
|
||||||
designation: "$designation.name",
|
designation: 1,
|
||||||
role: "$role.name",
|
role: 1,
|
||||||
profile: 1,
|
profile: 1,
|
||||||
branches: 1,
|
branches: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import {
|
|||||||
createAssignment,
|
createAssignment,
|
||||||
updateAssignment,
|
updateAssignment,
|
||||||
getAssignmentsByQuery,
|
getAssignmentsByQuery,
|
||||||
|
aggregateAssignment,
|
||||||
} from "../models/Assignment/operations.js";
|
} from "../models/Assignment/operations.js";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
|
||||||
export const createAssignmentHandler = async (req, res) => {
|
export const createAssignmentHandler = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
@@ -13,6 +15,7 @@ export const createAssignmentHandler = async (req, res) => {
|
|||||||
});
|
});
|
||||||
const assignment = await createAssignment({
|
const assignment = await createAssignment({
|
||||||
...req.body,
|
...req.body,
|
||||||
|
isActive: true,
|
||||||
createdOn: dayjs().toISOString(),
|
createdOn: dayjs().toISOString(),
|
||||||
createdBy: user.id,
|
createdBy: user.id,
|
||||||
});
|
});
|
||||||
@@ -35,7 +38,41 @@ export const updateAssignmentHandler = async (req, res) => {
|
|||||||
export const getAssignmentsByUserHandler = async (req, res) => {
|
export const getAssignmentsByUserHandler = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const assignment = await getAssignmentsByQuery({ user: id });
|
const pipeline = [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
user: ObjectId?.createFromHexString(id),
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "venues",
|
||||||
|
localField: "venue",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "venue",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$venue",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "partners",
|
||||||
|
localField: "venue.entity",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "partner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$partner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const assignment = await aggregateAssignment(pipeline);
|
||||||
res.status(200).json({ result: assignment });
|
res.status(200).json({ result: assignment });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Error getting assignment", error });
|
res.status(500).json({ message: "Error getting assignment", error });
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import {
|
|||||||
getLocationByQuery,
|
getLocationByQuery,
|
||||||
getLocationByRadius,
|
getLocationByRadius,
|
||||||
} from "../models/Location/operations";
|
} from "../models/Location/operations";
|
||||||
|
import { aggregateAssignment } from "../models/Assignment/operations";
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sample Location Payload
|
Sample Location Payload
|
||||||
@@ -69,3 +71,48 @@ export const getLocationController = async (req, res) => {
|
|||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMyAssignedVenuesHandler = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { user } = res.locals;
|
||||||
|
const pipeline = [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
user: ObjectId?.createFromHexString(user.id),
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "venues",
|
||||||
|
localField: "venue",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "venue",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$venue",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "partners",
|
||||||
|
localField: "venue.entity",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "partner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$partner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const assignment = await aggregateAssignment(pipeline);
|
||||||
|
res.status(200).json({ result: assignment });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getMyAssignedVenuesHandler Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import {
|
||||||
|
createProduct,
|
||||||
|
updateProduct,
|
||||||
|
getAllProducts,
|
||||||
|
getProductByQuery,
|
||||||
|
getProductById,
|
||||||
|
deleteProduct,
|
||||||
|
} from "../models/Product/operations";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
export const createProductController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { user } = res.locals;
|
||||||
|
|
||||||
|
const product = await createProduct({
|
||||||
|
...req.body,
|
||||||
|
createdBy: user.id,
|
||||||
|
createdOn: dayjs().toISOString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
result: product,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("createProductController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateProductController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const product = await updateProduct(id, {
|
||||||
|
...req.body,
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
result: product,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("updateProductController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAllProductsController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const products = await getAllProducts();
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
result: products,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getAllProductsController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteProductController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const product = await deleteProduct(id);
|
||||||
|
res.status(200).json({
|
||||||
|
result: product,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("deleteProductController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import dayjs from "dayjs";
|
||||||
|
import {
|
||||||
|
createVendor,
|
||||||
|
updateVendor,
|
||||||
|
deleteVendor,
|
||||||
|
getVendorsByQuery,
|
||||||
|
getVendorById,
|
||||||
|
getAllVendors,
|
||||||
|
} from "../models/Vendor/operations";
|
||||||
|
|
||||||
|
export const createVendorController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { user } = res.locals;
|
||||||
|
const vendor = await createVendor({
|
||||||
|
...req.body,
|
||||||
|
createdBy: user?.id,
|
||||||
|
createdOn: dayjs().toISOString(),
|
||||||
|
});
|
||||||
|
res.status(201).json({ result: vendor });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("createVendorController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateVendorController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const vendor = await updateVendor(id, req.body);
|
||||||
|
res.status(200).json({ result: vendor });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("updateVendorController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getActiveVendorsController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const vendors = await getVendorsByQuery({ isActive: true });
|
||||||
|
res.status(200).json({ result: vendors });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getActiveVendorsController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAllVendorsController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const vendors = await getAllVendors();
|
||||||
|
res.status(200).json({ result: vendors });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getAllVendorsController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deactivateVendorController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
const deactivatedVendor = await updateVendor(id, { isActive: false });
|
||||||
|
res.status(200).json({ result: deactivatedVendor });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("deactivateVendorController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getVendorByIdController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
const vendor = await getVendorById(id);
|
||||||
|
|
||||||
|
res.status(200).json({ result: vendor });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getVendorByIdController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -6,6 +6,8 @@ import {
|
|||||||
updateVenue,
|
updateVenue,
|
||||||
aggregateVenue,
|
aggregateVenue,
|
||||||
} from "../models/Venue/operations.js";
|
} from "../models/Venue/operations.js";
|
||||||
|
import { ObjectId } from "mongodb";
|
||||||
|
import { aggregateAssignment } from "../models/Assignment/operations.js";
|
||||||
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
|
import { coordinatesToGeoJson } from "../helpers/geoJson.helper.js";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
@@ -69,3 +71,106 @@ export const getVenueController = async (req, res, next) => {
|
|||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAssignedVenuesController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const { userId } = req.params;
|
||||||
|
// const { user } = res.locals;
|
||||||
|
|
||||||
|
const assignedVenues = await aggregateAssignment([
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
user: ObjectId.createFromHexString(userId),
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "venues",
|
||||||
|
localField: "venue",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "venue",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$venue",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "partners",
|
||||||
|
localField: "venue.entity",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "partner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$partner",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
res.status(200).json({ result: assignedVenues });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getAssignedVenues Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getUnassignedVenuesController = async (req, res, next) => {
|
||||||
|
try {
|
||||||
|
const unassignedVenues = await aggregateVenue([
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
category: "PARTNER"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "assignments",
|
||||||
|
localField: "_id",
|
||||||
|
foreignField: "venue",
|
||||||
|
pipeline: [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
as: "activeAssignments",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$or: [
|
||||||
|
{ activeAssignments: { $size: 0 } },
|
||||||
|
{ activeAssignments: { $exists: false } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "partners",
|
||||||
|
localField: "entity",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "partner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: "$partner",
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
res.status(200).json({ result: unassignedVenues });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("getUnassignedVenuesController Error", error);
|
||||||
|
next(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -226,6 +226,40 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"/admin/role/{id}": {
|
||||||
|
patch: {
|
||||||
|
tags: ["Admin"],
|
||||||
|
summary: "Edit New Role",
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
name: "id",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
requestBody: {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
"/admin/employee/{id}": {
|
"/admin/employee/{id}": {
|
||||||
get: {
|
get: {
|
||||||
tags: ["Admin"],
|
tags: ["Admin"],
|
||||||
|
|||||||
@@ -244,6 +244,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/location/venues/assigned/me": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"Location"
|
||||||
|
],
|
||||||
|
"summary": "Get Assigned Venues for creating Geofence",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/uploads/single/{folder}": {
|
"/uploads/single/{folder}": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -521,6 +535,42 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/admin/role/{id}": {
|
||||||
|
"patch": {
|
||||||
|
"tags": [
|
||||||
|
"Admin"
|
||||||
|
],
|
||||||
|
"summary": "Edit New Role",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "id"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/admin/employee/{id}": {
|
"/admin/employee/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -1116,6 +1166,410 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/product": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Create a New Product",
|
||||||
|
"tags": [
|
||||||
|
"Product"
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"sku": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"stock": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"buyingPrice": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"sellingPrice": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"gst": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"hsn": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"vendors": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"get": {
|
||||||
|
"summary": "Get All Products",
|
||||||
|
"tags": [
|
||||||
|
"Product"
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/product/{id}": {
|
||||||
|
"patch": {
|
||||||
|
"summary": "Update a Product",
|
||||||
|
"tags": [
|
||||||
|
"Product"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"description": "Product ID",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"sku": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"stock": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"buyingPrice": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"sellingPrice": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"gst": {
|
||||||
|
"type": "number",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"hsn": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"vendors": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"summary": "Delete a Product",
|
||||||
|
"tags": [
|
||||||
|
"Product"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"description": "Product ID",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/vendor/all": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Get All Vendors",
|
||||||
|
"tags": [
|
||||||
|
"Vendor"
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/vendor/{id}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Get Vendor Details",
|
||||||
|
"tags": [
|
||||||
|
"Vendor"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"description": "Vendor ID",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"patch": {
|
||||||
|
"summary": "Get Vendor Details",
|
||||||
|
"tags": [
|
||||||
|
"Vendor"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"description": "Vendor ID",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"mobile": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"city": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"picode": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"isActive": {
|
||||||
|
"type": "boolean",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"contactPersons": {
|
||||||
|
"type": "array",
|
||||||
|
"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": {
|
||||||
|
"summary": "Deactivate Vendor",
|
||||||
|
"tags": [
|
||||||
|
"Vendor"
|
||||||
|
],
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"description": "Vendor ID",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"content": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/vendor": {
|
||||||
|
"post": {
|
||||||
|
"summary": "Create New Vendor",
|
||||||
|
"tags": [
|
||||||
|
"Vendor"
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"mobile": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"city": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"state": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"picode": {
|
||||||
|
"type": "string",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"isActive": {
|
||||||
|
"type": "boolean",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"contactPersons": {
|
||||||
|
"type": "array",
|
||||||
|
"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": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,8 @@ import location from "./location.js";
|
|||||||
import assignment from "./assignment.js";
|
import assignment from "./assignment.js";
|
||||||
import partner from "./partner.js";
|
import partner from "./partner.js";
|
||||||
import venue from "./venue.js";
|
import venue from "./venue.js";
|
||||||
|
import product from "./product.js";
|
||||||
|
import vendor from "./vendor.js";
|
||||||
|
|
||||||
const GENERAL_CONFIG = {
|
const GENERAL_CONFIG = {
|
||||||
openapi: "3.0.1",
|
openapi: "3.0.1",
|
||||||
@@ -53,6 +55,8 @@ let paths = {
|
|||||||
...assignment,
|
...assignment,
|
||||||
...partner,
|
...partner,
|
||||||
...venue,
|
...venue,
|
||||||
|
...product,
|
||||||
|
...vendor,
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSwaggerDocument = () => {
|
const getSwaggerDocument = () => {
|
||||||
|
|||||||
@@ -27,12 +27,11 @@ export default {
|
|||||||
coordinates: {
|
coordinates: {
|
||||||
type: "array",
|
type: "array",
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
venue: {
|
venue: {
|
||||||
type: "string",
|
type: "string",
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -46,4 +45,16 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"/location/venues/assigned/me": {
|
||||||
|
get: {
|
||||||
|
tags: ["Location"],
|
||||||
|
summary: "Get Assigned Venues for creating Geofence",
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,176 @@
|
|||||||
|
export default {
|
||||||
|
"/product": {
|
||||||
|
post: {
|
||||||
|
summary: "Create a New Product",
|
||||||
|
tags: ["Product"],
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
sku: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
stock: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
buyingPrice: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
sellingPrice: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
gst: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
hsn: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
stock: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
vendors: {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
get: {
|
||||||
|
summary: "Get All Products",
|
||||||
|
tags: ["Product"],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/product/{id}": {
|
||||||
|
patch: {
|
||||||
|
summary: "Update a Product",
|
||||||
|
tags: ["Product"],
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
name: "id",
|
||||||
|
in: "path",
|
||||||
|
required: true,
|
||||||
|
description: "Product ID",
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
sku: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
stock: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
buyingPrice: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
sellingPrice: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
gst: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
hsn: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
stock: {
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
vendors: {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
summary: "Delete a Product",
|
||||||
|
tags: ["Product"],
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
name: "id",
|
||||||
|
in: "path",
|
||||||
|
required: true,
|
||||||
|
description: "Product ID",
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
export default {
|
||||||
|
"/vendor/all": {
|
||||||
|
get: {
|
||||||
|
summary: "Get All Vendors",
|
||||||
|
tags: ["Vendor"],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/vendor/{id}": {
|
||||||
|
get: {
|
||||||
|
summary: "Get Vendor Details",
|
||||||
|
tags: ["Vendor"],
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
required: true,
|
||||||
|
description: "Vendor ID",
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
patch: {
|
||||||
|
summary: "Get Vendor Details",
|
||||||
|
tags: ["Vendor"],
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
required: true,
|
||||||
|
description: "Vendor ID",
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
mobile: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
picode: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
isActive: {
|
||||||
|
type: "boolean",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
contactPersons: {
|
||||||
|
type: "array",
|
||||||
|
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: {
|
||||||
|
summary: "Deactivate Vendor",
|
||||||
|
tags: ["Vendor"],
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
in: "path",
|
||||||
|
required: true,
|
||||||
|
description: "Vendor ID",
|
||||||
|
schema: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "OK",
|
||||||
|
content: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"/vendor": {
|
||||||
|
post: {
|
||||||
|
summary: "Create New Vendor",
|
||||||
|
tags: ["Vendor"],
|
||||||
|
requestBody: {
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
mobile: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
city: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
picode: {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
isActive: {
|
||||||
|
type: "boolean",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
contactPersons: {
|
||||||
|
type: "array",
|
||||||
|
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: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -17,7 +17,9 @@ import {
|
|||||||
LocationRoutes,
|
LocationRoutes,
|
||||||
AssignmentRoutes,
|
AssignmentRoutes,
|
||||||
PartnerRoutes,
|
PartnerRoutes,
|
||||||
VenueRoutes
|
VenueRoutes,
|
||||||
|
ProductRoutes,
|
||||||
|
VendorRoutes,
|
||||||
} from "./routes";
|
} from "./routes";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
@@ -44,9 +46,22 @@ db.once("open", () =>
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(cors());
|
app.use(
|
||||||
|
cors({
|
||||||
|
origin: [
|
||||||
|
"http://localhost:1420",
|
||||||
|
"tauri://localhost",
|
||||||
|
"https://tauri.localhost",
|
||||||
|
"http://tauri.localhost",
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
|
app.get("/test", (req, res, next) => {
|
||||||
|
res.json({status: "success"})
|
||||||
|
})
|
||||||
|
|
||||||
app.use("/v0/docs", swaggerUi.serve, swaggerUi.setup(swaggerDoc));
|
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);
|
||||||
@@ -54,6 +69,8 @@ app.use("/v0/location", LocationRoutes);
|
|||||||
app.use("/v0/assignment", AssignmentRoutes);
|
app.use("/v0/assignment", AssignmentRoutes);
|
||||||
app.use("/v0/partner", PartnerRoutes);
|
app.use("/v0/partner", PartnerRoutes);
|
||||||
app.use("/v0/venue", VenueRoutes);
|
app.use("/v0/venue", VenueRoutes);
|
||||||
|
app.use("/v0/product", ProductRoutes);
|
||||||
|
app.use("/v0/vendor", VendorRoutes);
|
||||||
|
|
||||||
app.use((err, req, res, next) => {
|
app.use((err, req, res, next) => {
|
||||||
const statusCode = err.status || 500;
|
const statusCode = err.status || 500;
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
@@ -36,6 +36,14 @@ const schema = new Schema({
|
|||||||
type: Date,
|
type: Date,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
city: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default model("access", schema);
|
export default model("access", schema);
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ const schema = new Schema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
hsn: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
stock: {
|
stock: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
@@ -17,7 +17,16 @@ export const getProductByQuery = async (query) => {
|
|||||||
|
|
||||||
// Read (Get all)
|
// Read (Get all)
|
||||||
export const getAllProducts = async () => {
|
export const getAllProducts = async () => {
|
||||||
return await Model.find();
|
return await Model.aggregate([
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "vendors",
|
||||||
|
localField: "vendors",
|
||||||
|
foreignField: "_id",
|
||||||
|
as: "vendors"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ const moduleSchema = new Schema({
|
|||||||
"salary",
|
"salary",
|
||||||
"vendor",
|
"vendor",
|
||||||
"expense",
|
"expense",
|
||||||
|
"venue",
|
||||||
|
"metadata",
|
||||||
"product",
|
"product",
|
||||||
"invoice",
|
"invoice",
|
||||||
"partner",
|
"partner",
|
||||||
@@ -28,6 +30,12 @@ const moduleSchema = new Schema({
|
|||||||
"inventoryLog",
|
"inventoryLog",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
region: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
default: "CITY",
|
||||||
|
enum: ["CITY", "STATE", "COUNTRY"],
|
||||||
|
},
|
||||||
permission: {
|
permission: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ const schema = new Schema({
|
|||||||
required: true,
|
required: true,
|
||||||
ref: "user",
|
ref: "user",
|
||||||
},
|
},
|
||||||
|
isActive: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default model("user", schema);
|
export default model("user", schema);
|
||||||
|
|||||||
Vendored
+7
-2
@@ -10,10 +10,15 @@ export const getVendorById = async (id) => {
|
|||||||
return await Model.findById(id);
|
return await Model.findById(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Read (Get by Query)
|
// Read (Get One by Query)
|
||||||
export const getVendorByQuery = async (query) => {
|
export const getVendorByQuery = async (query) => {
|
||||||
return await Model.findOne(query);
|
return await Model.findOne(query);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Read (Get All by Query)
|
||||||
|
export const getVendorsByQuery = async (query) => {
|
||||||
|
return await Model.find(query);
|
||||||
|
};
|
||||||
|
|
||||||
// Read (Get all)
|
// Read (Get all)
|
||||||
export const getAllVendors = async () => {
|
export const getAllVendors = async () => {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
createDepartmentController,
|
createDepartmentController,
|
||||||
createDesignationController,
|
createDesignationController,
|
||||||
createRoleController,
|
createRoleController,
|
||||||
|
updateRoleController,
|
||||||
getAllEmployeeController,
|
getAllEmployeeController,
|
||||||
getEmployeeDetailsController,
|
getEmployeeDetailsController,
|
||||||
getEmployeeLocationHistoryController,
|
getEmployeeLocationHistoryController,
|
||||||
@@ -29,20 +30,16 @@ router.post(
|
|||||||
authorize("department", "write"),
|
authorize("department", "write"),
|
||||||
createDepartmentController,
|
createDepartmentController,
|
||||||
);
|
);
|
||||||
router.get(
|
router.get("/employees", authorize("user", "read"), getAllEmployeeController);
|
||||||
"/employees",
|
router.post("/employee", authorize("user", "write"), createEmployee);
|
||||||
authorize("employee", "read"),
|
|
||||||
getAllEmployeeController,
|
|
||||||
);
|
|
||||||
router.post("/employee", authorize("employee", "write"), createEmployee);
|
|
||||||
router.get(
|
router.get(
|
||||||
"/employee/:id",
|
"/employee/:id",
|
||||||
authorize("employee", "read"),
|
authorize("user", "read"),
|
||||||
getEmployeeDetailsController,
|
getEmployeeDetailsController,
|
||||||
);
|
);
|
||||||
router.get(
|
router.get(
|
||||||
"/employee/:user/locations",
|
"/employee/:user/locations",
|
||||||
authorize("employee", "read"),
|
authorize("user", "read"),
|
||||||
getEmployeeLocationHistoryController,
|
getEmployeeLocationHistoryController,
|
||||||
);
|
);
|
||||||
router.post(
|
router.post(
|
||||||
@@ -52,4 +49,6 @@ router.post(
|
|||||||
);
|
);
|
||||||
router.post("/role", authorize("role", "write"), createRoleController);
|
router.post("/role", authorize("role", "write"), createRoleController);
|
||||||
|
|
||||||
|
router.patch("/role/:id", authorize("role", "write"), updateRoleController);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -5,3 +5,5 @@ export { default as LocationRoutes } from "./location.route";
|
|||||||
export { default as AssignmentRoutes } from "./assignment.route";
|
export { default as AssignmentRoutes } from "./assignment.route";
|
||||||
export { default as VenueRoutes } from "./venue.route";
|
export { default as VenueRoutes } from "./venue.route";
|
||||||
export { default as PartnerRoutes } from "./partner.route";
|
export { default as PartnerRoutes } from "./partner.route";
|
||||||
|
export { default as ProductRoutes } from "./product.route";
|
||||||
|
export { default as VendorRoutes } from "./vendor.route";
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import { authorizeWithEncryptedKey } from "../middlewares/jwt.middleware";
|
import {
|
||||||
import { createLocationController } from "../controllers/location.controller";
|
authorize,
|
||||||
|
authorizeWithEncryptedKey,
|
||||||
|
} from "../middlewares/jwt.middleware";
|
||||||
|
import {
|
||||||
|
createLocationController,
|
||||||
|
getMyAssignedVenuesHandler,
|
||||||
|
} from "../controllers/location.controller";
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
@@ -10,4 +16,10 @@ router.post(
|
|||||||
createLocationController,
|
createLocationController,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.get(
|
||||||
|
"/venues/assigned/me",
|
||||||
|
authorize("generic", "generic"),
|
||||||
|
getMyAssignedVenuesHandler,
|
||||||
|
);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import { authorize } from "../middlewares/jwt.middleware";
|
||||||
|
import {
|
||||||
|
createProductController,
|
||||||
|
deleteProductController,
|
||||||
|
getAllProductsController,
|
||||||
|
updateProductController,
|
||||||
|
} from "../controllers/product.controller";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.post("/", authorize("product", "write"), createProductController);
|
||||||
|
router.get("/", authorize("product", "read"), getAllProductsController);
|
||||||
|
router.patch("/:id", authorize("product", "write"), updateProductController);
|
||||||
|
router.delete("/:id", authorize("product", "delete"), deleteProductController);
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import {
|
||||||
|
createVendorController,
|
||||||
|
updateVendorController,
|
||||||
|
getActiveVendorsController,
|
||||||
|
getAllVendorsController,
|
||||||
|
deactivateVendorController,
|
||||||
|
getVendorByIdController,
|
||||||
|
} from "../controllers/vendor.controller";
|
||||||
|
import { authorize } from "../middlewares/jwt.middleware";
|
||||||
|
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
router.post("/", authorize("vendor", "write"), createVendorController);
|
||||||
|
router.patch("/:id", authorize("vendor", "write"), updateVendorController);
|
||||||
|
router.get("/active", authorize("vendor", "read"), getActiveVendorsController);
|
||||||
|
router.get("/all", authorize("vendor", "read"), getAllVendorsController);
|
||||||
|
router.delete(
|
||||||
|
"/:id",
|
||||||
|
authorize("vendor", "delete"),
|
||||||
|
deactivateVendorController,
|
||||||
|
);
|
||||||
|
router.get("/:id", authorize("vendor", "read"), getVendorByIdController);
|
||||||
|
|
||||||
|
export default router;
|
||||||
+13
-1
@@ -4,6 +4,8 @@ import {
|
|||||||
deleteVenueController,
|
deleteVenueController,
|
||||||
getVenuesByEntityController,
|
getVenuesByEntityController,
|
||||||
getVenueController,
|
getVenueController,
|
||||||
|
getAssignedVenuesController,
|
||||||
|
getUnassignedVenuesController,
|
||||||
} from "../controllers/venue.controller";
|
} from "../controllers/venue.controller";
|
||||||
import { authorize } from "../middlewares/jwt.middleware";
|
import { authorize } from "../middlewares/jwt.middleware";
|
||||||
|
|
||||||
@@ -15,7 +17,17 @@ router.get(
|
|||||||
authorize("venue", "read"),
|
authorize("venue", "read"),
|
||||||
getVenuesByEntityController,
|
getVenuesByEntityController,
|
||||||
);
|
);
|
||||||
router.get("/:id", authorize("venue", "read"), getVenueController);
|
router.get("/details/:id", authorize("venue", "read"), getVenueController);
|
||||||
|
router.get(
|
||||||
|
"/assigned/:userId",
|
||||||
|
authorize("venue", "read"),
|
||||||
|
getAssignedVenuesController,
|
||||||
|
);
|
||||||
|
router.get(
|
||||||
|
"/unassigned",
|
||||||
|
authorize("venue", "read"),
|
||||||
|
getUnassignedVenuesController,
|
||||||
|
);
|
||||||
router.delete("/:id", authorize("venue", "write"), deleteVenueController);
|
router.delete("/:id", authorize("venue", "write"), deleteVenueController);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
Reference in New Issue
Block a user