Compare commits
1 Commits
main
...
Main-dupli
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b15772692 |
10
.env
10
.env
@@ -1,8 +1,12 @@
|
|||||||
MONGO_URI=mongodb://mongo/
|
# MONGO_URI=mongodb://mongo/
|
||||||
MONGO_USER=admin
|
# MONGO_USER=admin
|
||||||
MONGO_PASSWORD=admin321
|
# MONGO_PASSWORD=admin321
|
||||||
MONGO_AUTH_DB=admin
|
MONGO_AUTH_DB=admin
|
||||||
|
|
||||||
|
MONGO_URI=mongodb://192.168.0.110/
|
||||||
|
MONGO_USER=mydata
|
||||||
|
MONGO_PASSWORD=mongodb@hexr2002
|
||||||
|
MONGO_AUTH_DB=admin
|
||||||
API_PORT=5000
|
API_PORT=5000
|
||||||
SOCKET_PORT=8000
|
SOCKET_PORT=8000
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|||||||
22
Dwinzo-Backend-OLD.code-workspace
Normal file
22
Dwinzo-Backend-OLD.code-workspace
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"name": "Dwinzo-Backend",
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"files.exclude": {
|
||||||
|
"**/.git": true,
|
||||||
|
"**/.svn": true,
|
||||||
|
"**/.hg": true,
|
||||||
|
"**/CVS": true,
|
||||||
|
"**/.DS_Store": true,
|
||||||
|
"**/Thumbs.db": true,
|
||||||
|
"**/.retool_types/**": true,
|
||||||
|
"**/*tsconfig.json": true,
|
||||||
|
".cache": true,
|
||||||
|
"retool.config.json": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { ProductFlowService } from "../controller/simulation/productService.ts";
|
import { ProductFlowService } from "../controller/simulation/productService.ts";
|
||||||
const productRouter = express.Router();
|
const productRouter = express.Router();
|
||||||
productRouter.post("/UpsertProductOrEvent", ProductFlowService.productAdd);
|
productRouter.post("/UpsertProductOrEvent", ProductFlowService.productAdd);
|
||||||
productRouter.get("/productData", ProductFlowService.getProductDatas);
|
productRouter.get("/productData", ProductFlowService.getProductDatas);
|
||||||
productRouter.patch("/EventDataDelete", ProductFlowService.EventDataDelete);
|
productRouter.patch("/EventDataDelete", ProductFlowService.EventDataDelete);
|
||||||
productRouter.patch("/productDataDelete", ProductFlowService.productDataDelete);
|
productRouter.patch("/productDataDelete", ProductFlowService.productDataDelete);
|
||||||
productRouter.get("/AllProducts/:organization", ProductFlowService.AllProductDatas);
|
productRouter.get("/AllProducts/:organization", ProductFlowService.AllProductDatas);
|
||||||
productRouter.patch("/productRename", ProductFlowService.productRename);
|
productRouter.patch("/productRename", ProductFlowService.productRename);
|
||||||
export default productRouter;
|
export default productRouter;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { createProjectController } from "../controller/project/projectController.ts";
|
import { createProjectController } from "../controller/project/projectController.ts";
|
||||||
|
|
||||||
const projectRouter = express.Router();
|
const projectRouter = express.Router();
|
||||||
projectRouter.post("/upsertProject",createProjectController)
|
projectRouter.post("/upsertProject",createProjectController)
|
||||||
export default projectRouter
|
export default projectRouter
|
||||||
@@ -1,45 +1,45 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { createProject } from "../../../shared/services/project/project-Serivices.ts";
|
import { createProject } from "../../../shared/services/project/project-Serivices.ts";
|
||||||
|
|
||||||
export const createProjectController = async (req: Request, res: Response): Promise<void> => {
|
export const createProjectController = async (req: Request, res: Response): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const result = await createProject(req.body);
|
const result = await createProject(req.body);
|
||||||
|
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
case "project_exists":
|
case "project_exists":
|
||||||
res.status(409).json({
|
res.status(409).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "Project already exists",
|
message: "Project already exists",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "user_not_found":
|
case "user_not_found":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "User not found",
|
message: "User not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "success":
|
case "success":
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Project created successfully",
|
message: "Project created successfully",
|
||||||
data: result.project,
|
data: result.project,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "Internal server error",
|
message: "Internal server error",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in controller:", error);
|
console.error("Error in controller:", error);
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "Internal server error",
|
message: "Internal server error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,234 +1,234 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
import ProductModel from "../../../shared/model/simulation/productModel.ts";
|
||||||
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
import EventsDataModel from "../../../shared/model/simulation/eventsDataModel.ts";
|
||||||
|
|
||||||
export class ProductFlowService {
|
export class ProductFlowService {
|
||||||
static async productAdd(req: Request, res: Response): Promise<any> {
|
static async productAdd(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productName, productId, eventDatas, organization } = req.body;
|
const { productName, productId, eventDatas, organization } = req.body;
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
return res.json({ message: "organization not found" });
|
return res.json({ message: "organization not found" });
|
||||||
}
|
}
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existingProduct) {
|
if (existingProduct) {
|
||||||
const existingEventData = await EventsDataModel(organization).findOne({
|
const existingEventData = await EventsDataModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
modelUuid: eventDatas.modelUuid,
|
modelUuid: eventDatas.modelUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existingEventData) {
|
if (existingEventData) {
|
||||||
await EventsDataModel(organization).findOneAndUpdate(
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
modelUuid: eventDatas.modelUuid,
|
modelUuid: eventDatas.modelUuid,
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
modelUuid: eventDatas?.modelUuid,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
modelName: eventDatas?.modelName,
|
modelName: eventDatas?.modelName,
|
||||||
position: eventDatas?.position,
|
position: eventDatas?.position,
|
||||||
rotation: eventDatas?.rotation,
|
rotation: eventDatas?.rotation,
|
||||||
type: eventDatas?.type,
|
type: eventDatas?.type,
|
||||||
speed: eventDatas?.speed,
|
speed: eventDatas?.speed,
|
||||||
point: eventDatas?.point,
|
point: eventDatas?.point,
|
||||||
points: eventDatas?.points,
|
points: eventDatas?.points,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return res
|
return res
|
||||||
.status(200)
|
.status(200)
|
||||||
.json({ message: "EventData updated successfully" });
|
.json({ message: "EventData updated successfully" });
|
||||||
} else {
|
} else {
|
||||||
await EventsDataModel(organization).create({
|
await EventsDataModel(organization).create({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
modelUuid: eventDatas?.modelUuid,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
modelName: eventDatas?.modelName,
|
modelName: eventDatas?.modelName,
|
||||||
position: eventDatas?.position,
|
position: eventDatas?.position,
|
||||||
rotation: eventDatas?.rotation,
|
rotation: eventDatas?.rotation,
|
||||||
type: eventDatas?.type,
|
type: eventDatas?.type,
|
||||||
speed: eventDatas?.speed,
|
speed: eventDatas?.speed,
|
||||||
point: eventDatas?.point,
|
point: eventDatas?.point,
|
||||||
points: eventDatas?.points,
|
points: eventDatas?.points,
|
||||||
});
|
});
|
||||||
return res
|
return res
|
||||||
.status(201)
|
.status(201)
|
||||||
.json({ message: "EventData add successfully" });
|
.json({ message: "EventData add successfully" });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const newProduct = await ProductModel(organization).create({
|
const newProduct = await ProductModel(organization).create({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
productName: productName,
|
productName: productName,
|
||||||
});
|
});
|
||||||
if (newProduct) {
|
if (newProduct) {
|
||||||
if (eventDatas) {
|
if (eventDatas) {
|
||||||
await EventsDataModel(organization).create({
|
await EventsDataModel(organization).create({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
modelUuid: eventDatas?.modelUuid,
|
modelUuid: eventDatas?.modelUuid,
|
||||||
modelName: eventDatas?.modelName,
|
modelName: eventDatas?.modelName,
|
||||||
position: eventDatas?.position,
|
position: eventDatas?.position,
|
||||||
rotation: eventDatas?.rotation,
|
rotation: eventDatas?.rotation,
|
||||||
type: eventDatas?.type,
|
type: eventDatas?.type,
|
||||||
speed: eventDatas?.speed,
|
speed: eventDatas?.speed,
|
||||||
point: eventDatas?.point,
|
point: eventDatas?.point,
|
||||||
points: eventDatas?.points,
|
points: eventDatas?.points,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
.status(201)
|
.status(201)
|
||||||
.json({ message: "Product created successfully" });
|
.json({ message: "Product created successfully" });
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to create product" });
|
res.status(500).json({ message: "Failed to create product" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async getProductDatas(req: Request, res: Response): Promise<any> {
|
static async getProductDatas(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productId, organization } = req.query;
|
const { productId, organization } = req.query;
|
||||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||||
return res
|
return res
|
||||||
.status(400)
|
.status(400)
|
||||||
.json({ message: "Missing or invalid query parameters" });
|
.json({ message: "Missing or invalid query parameters" });
|
||||||
}
|
}
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
const existingEventDatas = await EventsDataModel(organization)
|
const existingEventDatas = await EventsDataModel(organization)
|
||||||
.find({ productId: productId })
|
.find({ productId: productId })
|
||||||
.select("-productId");
|
.select("-productId");
|
||||||
|
|
||||||
return res.status(200).json(existingEventDatas);
|
return res.status(200).json(existingEventDatas);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to get product" });
|
res.status(500).json({ message: "Failed to get product" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async productDataDelete(req: Request, res: Response): Promise<any> {
|
static async productDataDelete(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productId, organization } = req.query;
|
const { productId, organization } = req.query;
|
||||||
if (typeof productId !== "string" || typeof organization !== "string") {
|
if (typeof productId !== "string" || typeof organization !== "string") {
|
||||||
return res
|
return res
|
||||||
.status(400)
|
.status(400)
|
||||||
.json({ message: "Missing or invalid query parameters" });
|
.json({ message: "Missing or invalid query parameters" });
|
||||||
}
|
}
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
await ProductModel(organization).findOneAndUpdate(
|
await ProductModel(organization).findOneAndUpdate(
|
||||||
{ productId: productId },
|
{ productId: productId },
|
||||||
{
|
{
|
||||||
isArchive: true,
|
isArchive: true,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
const existingEventDatas = await EventsDataModel(organization).find({
|
const existingEventDatas = await EventsDataModel(organization).find({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
});
|
});
|
||||||
if (existingEventDatas) {
|
if (existingEventDatas) {
|
||||||
await EventsDataModel(organization).updateMany(
|
await EventsDataModel(organization).updateMany(
|
||||||
{ productId },
|
{ productId },
|
||||||
{ $set: { isArchive: true } }
|
{ $set: { isArchive: true } }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return res.status(201).json({ message: "product deleted successfully" });
|
return res.status(201).json({ message: "product deleted successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to delete product" });
|
res.status(500).json({ message: "Failed to delete product" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async EventDataDelete(req: Request, res: Response): Promise<any> {
|
static async EventDataDelete(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productId, organization, modelUuid } = req.body;
|
const { productId, organization, modelUuid } = req.body;
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
await EventsDataModel(organization).findOneAndUpdate(
|
await EventsDataModel(organization).findOneAndUpdate(
|
||||||
{ productId: productId, modelUuid: modelUuid },
|
{ productId: productId, modelUuid: modelUuid },
|
||||||
{
|
{
|
||||||
isArchive: true,
|
isArchive: true,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
return res
|
return res
|
||||||
.status(201)
|
.status(201)
|
||||||
.json({ message: "EventData deleted successfully" });
|
.json({ message: "EventData deleted successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to delete Eventdata" });
|
res.status(500).json({ message: "Failed to delete Eventdata" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async AllProductDatas(req: Request, res: Response): Promise<any> {
|
static async AllProductDatas(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { organization } = req.params;
|
const { organization } = req.params;
|
||||||
|
|
||||||
if (!organization) {
|
if (!organization) {
|
||||||
return res.json({ message: "organization not found" });
|
return res.json({ message: "organization not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).find({
|
const existingProduct = await ProductModel(organization).find({
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingProduct) {
|
if (!existingProduct) {
|
||||||
return res.status(404).json({ message: "No products found" });
|
return res.status(404).json({ message: "No products found" });
|
||||||
}
|
}
|
||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
for (const product of existingProduct) {
|
for (const product of existingProduct) {
|
||||||
const eventDatas = await EventsDataModel(organization)
|
const eventDatas = await EventsDataModel(organization)
|
||||||
.find({ productId: product.productId, isArchive: false })
|
.find({ productId: product.productId, isArchive: false })
|
||||||
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
.select("-productId -isArchive -createdAt -updatedAt -__v -_id");
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
productName: product.productName,
|
productName: product.productName,
|
||||||
productId: product.productId,
|
productId: product.productId,
|
||||||
eventDatas,
|
eventDatas,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to get Allproduct" });
|
res.status(500).json({ message: "Failed to get Allproduct" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async productRename(req: Request, res: Response): Promise<any> {
|
static async productRename(req: Request, res: Response): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const { productId, productName, organization } = req.body;
|
const { productId, productName, organization } = req.body;
|
||||||
|
|
||||||
const existingProduct = await ProductModel(organization).findOne({
|
const existingProduct = await ProductModel(organization).findOne({
|
||||||
productId: productId,
|
productId: productId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existingProduct)
|
if (!existingProduct)
|
||||||
return res.status(404).json({ message: "Product not found" });
|
return res.status(404).json({ message: "Product not found" });
|
||||||
|
|
||||||
await ProductModel(organization).findOneAndUpdate(
|
await ProductModel(organization).findOneAndUpdate(
|
||||||
{ productId: productId },
|
{ productId: productId },
|
||||||
{
|
{
|
||||||
productName: productName,
|
productName: productName,
|
||||||
},
|
},
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.status(201).json({ message: "product Rename successfully" });
|
return res.status(201).json({ message: "product Rename successfully" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ message: "Failed to product Rename" });
|
res.status(500).json({ message: "Failed to product Rename" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
import { User } from "../user-Model.ts";
|
import { User } from "../user-Model.ts";
|
||||||
|
|
||||||
export interface Project extends Document {
|
export interface Project extends Document {
|
||||||
projectUuid: string;
|
projectUuid: string;
|
||||||
projectName: string;
|
projectName: string;
|
||||||
createdBy: User["_id"];
|
createdBy: User["_id"];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
thumbnail: string;
|
thumbnail: string;
|
||||||
sharedUsers: [];
|
sharedUsers: [];
|
||||||
}
|
}
|
||||||
const projectSchema: Schema = new Schema(
|
const projectSchema: Schema = new Schema(
|
||||||
{
|
{
|
||||||
projectUuid: { type: String, required: true },
|
projectUuid: { type: String, required: true },
|
||||||
projectName: { type: String },
|
projectName: { type: String },
|
||||||
thumbnail: { type: String },
|
thumbnail: { type: String },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
createdBy: { type: Schema.Types.ObjectId, ref: "user" },
|
createdBy: { type: Schema.Types.ObjectId, ref: "user" },
|
||||||
sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }],
|
sharedUsers: [{ type: Schema.Types.ObjectId, ref: "user" }],
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const projectModel = (db: string) => {
|
const projectModel = (db: string) => {
|
||||||
return MainModel(db, "Projects", projectSchema, "Projects");
|
return MainModel(db, "Projects", projectSchema, "Projects");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default projectModel;
|
export default projectModel;
|
||||||
|
|||||||
@@ -1,178 +1,178 @@
|
|||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
|
|
||||||
interface AssetEventSchema {
|
interface AssetEventSchema {
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
state: "idle" | "running" | "stopped" | "disabled" | "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TriggerSchema {
|
interface TriggerSchema {
|
||||||
triggerUuid: string;
|
triggerUuid: string;
|
||||||
triggerName: string;
|
triggerName: string;
|
||||||
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
|
||||||
delay: number;
|
delay: number;
|
||||||
triggeredAsset: {
|
triggeredAsset: {
|
||||||
triggeredModel: { modelName: string; modelUuid: string };
|
triggeredModel: { modelName: string; modelUuid: string };
|
||||||
triggeredPoint: { pointName: string; pointUuid: string };
|
triggeredPoint: { pointName: string; pointUuid: string };
|
||||||
triggeredAction: { actionName: string; actionUuid: string };
|
triggeredAction: { actionName: string; actionUuid: string };
|
||||||
} | null;
|
} | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConveyorPointSchema {
|
interface ConveyorPointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "default" | "spawn" | "swap" | "despawn";
|
actionType: "default" | "spawn" | "swap" | "despawn";
|
||||||
material: string;
|
material: string;
|
||||||
delay: number | "inherit";
|
delay: number | "inherit";
|
||||||
spawnInterval: number | "inherit";
|
spawnInterval: number | "inherit";
|
||||||
spawnCount: number | "inherit";
|
spawnCount: number | "inherit";
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VehiclePointSchema {
|
interface VehiclePointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "travel";
|
actionType: "travel";
|
||||||
material: string | null;
|
material: string | null;
|
||||||
unLoadDuration: number;
|
unLoadDuration: number;
|
||||||
loadCapacity: number;
|
loadCapacity: number;
|
||||||
pickUpPoint: { x: number; y: number; z: number } | null;
|
pickUpPoint: { x: number; y: number; z: number } | null;
|
||||||
unLoadPoint: { x: number; y: number; z: number } | null;
|
unLoadPoint: { x: number; y: number; z: number } | null;
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RoboticArmPointSchema {
|
interface RoboticArmPointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
actions: {
|
actions: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "pickAndPlace";
|
actionType: "pickAndPlace";
|
||||||
process: {
|
process: {
|
||||||
startPoint: [number, number, number];
|
startPoint: [number, number, number];
|
||||||
endPoint: [number, number, number];
|
endPoint: [number, number, number];
|
||||||
};
|
};
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MachinePointSchema {
|
interface MachinePointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "process";
|
actionType: "process";
|
||||||
processTime: number;
|
processTime: number;
|
||||||
swapMaterial: string;
|
swapMaterial: string;
|
||||||
triggers: TriggerSchema[];
|
triggers: TriggerSchema[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StoragePointSchema {
|
interface StoragePointSchema {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
position: [number, number, number];
|
position: [number, number, number];
|
||||||
rotation: [number, number, number];
|
rotation: [number, number, number];
|
||||||
action: {
|
action: {
|
||||||
actionUuid: string;
|
actionUuid: string;
|
||||||
actionName: string;
|
actionName: string;
|
||||||
actionType: "storage";
|
actionType: "storage";
|
||||||
materials: { materialName: string; materialId: string }[];
|
materials: { materialName: string; materialId: string }[];
|
||||||
storageCapacity: number;
|
storageCapacity: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConveyorEventSchema extends AssetEventSchema {
|
interface ConveyorEventSchema extends AssetEventSchema {
|
||||||
type: "transfer";
|
type: "transfer";
|
||||||
speed: number;
|
speed: number;
|
||||||
points: ConveyorPointSchema[];
|
points: ConveyorPointSchema[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VehicleEventSchema extends AssetEventSchema {
|
interface VehicleEventSchema extends AssetEventSchema {
|
||||||
type: "vehicle";
|
type: "vehicle";
|
||||||
speed: number;
|
speed: number;
|
||||||
point: VehiclePointSchema;
|
point: VehiclePointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RoboticArmEventSchema extends AssetEventSchema {
|
interface RoboticArmEventSchema extends AssetEventSchema {
|
||||||
type: "roboticArm";
|
type: "roboticArm";
|
||||||
speed: number;
|
speed: number;
|
||||||
point: RoboticArmPointSchema;
|
point: RoboticArmPointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MachineEventSchema extends AssetEventSchema {
|
interface MachineEventSchema extends AssetEventSchema {
|
||||||
type: "machine";
|
type: "machine";
|
||||||
point: MachinePointSchema;
|
point: MachinePointSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StorageEventSchema extends AssetEventSchema {
|
interface StorageEventSchema extends AssetEventSchema {
|
||||||
type: "storageUnit";
|
type: "storageUnit";
|
||||||
point: StoragePointSchema;
|
point: StoragePointSchema;
|
||||||
}
|
}
|
||||||
interface IPointModel extends Document {
|
interface IPointModel extends Document {
|
||||||
modelUuid: string;
|
modelUuid: string;
|
||||||
modelName: string;
|
modelName: string;
|
||||||
position: [number];
|
position: [number];
|
||||||
rotation: [number];
|
rotation: [number];
|
||||||
state: string;
|
state: string;
|
||||||
productId: string;
|
productId: string;
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
type: "transfer" | "vehicle" | "roboticArm" | "machine" | "storageUnit";
|
||||||
speed: number;
|
speed: number;
|
||||||
point:
|
point:
|
||||||
| VehicleEventSchema
|
| VehicleEventSchema
|
||||||
| RoboticArmEventSchema
|
| RoboticArmEventSchema
|
||||||
| MachineEventSchema
|
| MachineEventSchema
|
||||||
| StorageEventSchema;
|
| StorageEventSchema;
|
||||||
points: ConveyorEventSchema[];
|
points: ConveyorEventSchema[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const BaseEventSchema = new Schema<IPointModel>(
|
const BaseEventSchema = new Schema<IPointModel>(
|
||||||
{
|
{
|
||||||
modelUuid: { type: String, required: true },
|
modelUuid: { type: String, required: true },
|
||||||
modelName: { type: String, required: true },
|
modelName: { type: String, required: true },
|
||||||
position: { type: [Number], required: true },
|
position: { type: [Number], required: true },
|
||||||
rotation: { type: [Number], required: true },
|
rotation: { type: [Number], required: true },
|
||||||
speed: { type: Number },
|
speed: { type: Number },
|
||||||
state: {
|
state: {
|
||||||
type: String,
|
type: String,
|
||||||
enum: ["idle", "running", "stopped", "disabled", "error"],
|
enum: ["idle", "running", "stopped", "disabled", "error"],
|
||||||
default: "idle",
|
default: "idle",
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"],
|
enum: ["transfer", "vehicle", "roboticArm", "machine", "storageUnit"],
|
||||||
},
|
},
|
||||||
point: {
|
point: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed,
|
||||||
},
|
},
|
||||||
points: {
|
points: {
|
||||||
type: Schema.Types.Mixed,
|
type: Schema.Types.Mixed,
|
||||||
},
|
},
|
||||||
productId: { type: String, required: true },
|
productId: { type: String, required: true },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
{ discriminatorKey: "type", timestamps: true }
|
{ discriminatorKey: "type", timestamps: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const EventsDataModel = (db: string) => {
|
const EventsDataModel = (db: string) => {
|
||||||
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
return MainModel(db, "EventDatas", BaseEventSchema, "EventDatas");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EventsDataModel;
|
export default EventsDataModel;
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { Schema, Document } from "mongoose";
|
import { Schema, Document } from "mongoose";
|
||||||
import MainModel from "../../connect/mongoose.ts";
|
import MainModel from "../../connect/mongoose.ts";
|
||||||
export interface Product extends Document {
|
export interface Product extends Document {
|
||||||
productName: string;
|
productName: string;
|
||||||
productId: string;
|
productId: string;
|
||||||
eventsData: [];
|
eventsData: [];
|
||||||
isArchive: boolean;
|
isArchive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProductSchema = new Schema({
|
const ProductSchema = new Schema({
|
||||||
productName: { type: String, required: true },
|
productName: { type: String, required: true },
|
||||||
productId: { type: String, required: true },
|
productId: { type: String, required: true },
|
||||||
isArchive: { type: Boolean, default: false },
|
isArchive: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const ProductModel = (db: string) => {
|
const ProductModel = (db: string) => {
|
||||||
return MainModel(db, "Product", ProductSchema, "Product");
|
return MainModel(db, "Product", ProductSchema, "Product");
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProductModel;
|
export default ProductModel;
|
||||||
|
|||||||
@@ -1,87 +1,87 @@
|
|||||||
import projectModel from "../../model/project/project-model.ts";
|
import projectModel from "../../model/project/project-model.ts";
|
||||||
import userModel from "../../model/user-Model.ts";
|
import userModel from "../../model/user-Model.ts";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
interface CreateProjectInput {
|
interface CreateProjectInput {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
projectUuid: string;
|
projectUuid: string;
|
||||||
createdBy: string;
|
createdBy: string;
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
sharedUsers?: string[];
|
sharedUsers?: string[];
|
||||||
organization: string;
|
organization: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createProject = async (data: CreateProjectInput) => {
|
export const createProject = async (data: CreateProjectInput) => {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
projectName,
|
projectName,
|
||||||
projectUuid,
|
projectUuid,
|
||||||
createdBy,
|
createdBy,
|
||||||
thumbnail,
|
thumbnail,
|
||||||
sharedUsers,
|
sharedUsers,
|
||||||
organization,
|
organization,
|
||||||
} = data;
|
} = data;
|
||||||
const userExisting = await existingUser(createdBy, organization);
|
const userExisting = await existingUser(createdBy, organization);
|
||||||
if (!userExisting) {
|
if (!userExisting) {
|
||||||
return {
|
return {
|
||||||
status: "user_not_found",
|
status: "user_not_found",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const projectExisting = await existingProject(projectUuid, organization);
|
const projectExisting = await existingProject(projectUuid, organization);
|
||||||
|
|
||||||
if (projectExisting) {
|
if (projectExisting) {
|
||||||
return {
|
return {
|
||||||
status: "project_exists",
|
status: "project_exists",
|
||||||
project: projectExisting,
|
project: projectExisting,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const project = await projectModel(organization).create({
|
const project = await projectModel(organization).create({
|
||||||
projectName: projectName,
|
projectName: projectName,
|
||||||
projectUuid: projectUuid,
|
projectUuid: projectUuid,
|
||||||
createdBy: createdBy,
|
createdBy: createdBy,
|
||||||
thumbnail: thumbnail || "",
|
thumbnail: thumbnail || "",
|
||||||
sharedUsers: sharedUsers || [],
|
sharedUsers: sharedUsers || [],
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
status: "success",
|
status: "success",
|
||||||
project: project,
|
project: project,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
exists: false,
|
exists: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const existingProject = async (
|
export const existingProject = async (
|
||||||
projectUuid: string,
|
projectUuid: string,
|
||||||
organization: string
|
organization: string
|
||||||
) => {
|
) => {
|
||||||
const projectData = await projectModel(organization).findOne({
|
const projectData = await projectModel(organization).findOne({
|
||||||
projectUuid: projectUuid,
|
projectUuid: projectUuid,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
return projectData;
|
return projectData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const existingUser = async (createdBy: string, organization: string) => {
|
export const existingUser = async (createdBy: string, organization: string) => {
|
||||||
if (!Types.ObjectId.isValid(createdBy)) {
|
if (!Types.ObjectId.isValid(createdBy)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const userData = await userModel(organization).findOne({
|
const userData = await userModel(organization).findOne({
|
||||||
_id: createdBy,
|
_id: createdBy,
|
||||||
});
|
});
|
||||||
return userData;
|
return userData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const archiveProject = async (
|
export const archiveProject = async (
|
||||||
projectId: string,
|
projectId: string,
|
||||||
organization: string
|
organization: string
|
||||||
) => {
|
) => {
|
||||||
return await projectModel(organization).findByIdAndUpdate(
|
return await projectModel(organization).findByIdAndUpdate(
|
||||||
projectId,
|
projectId,
|
||||||
{ isArchive: true },
|
{ isArchive: true },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,210 +1,210 @@
|
|||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
|
import widget3dModel from "../../../shared/model/vizualization/3dwidget.ts";
|
||||||
export const add3Dwidget = async (data: any,callback:any) => {
|
export const add3Dwidget = async (data: any,callback:any) => {
|
||||||
const { organization, widget, zoneId } = data;
|
const { organization, widget, zoneId } = data;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneId",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existing3Dwidget) {
|
if (existing3Dwidget) {
|
||||||
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{ position: widget.position },
|
{ position: widget.position },
|
||||||
{ upsert: true, new: true }
|
{ upsert: true, new: true }
|
||||||
);
|
);
|
||||||
if (update3dwidget){
|
if (update3dwidget){
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "widget update successfully",
|
message: "widget update successfully",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "widget update successfully",
|
message: "widget update successfully",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Widget not updated",
|
message: "Widget not updated",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const newWidget3d = await widget3dModel(organization).create({
|
const newWidget3d = await widget3dModel(organization).create({
|
||||||
type: widget.type,
|
type: widget.type,
|
||||||
widgetID: widget.id,
|
widgetID: widget.id,
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
zoneId,
|
zoneId,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements || {},
|
measurements: widget?.Data?.measurements || {},
|
||||||
duration: widget?.Data?.duration || "1h",
|
duration: widget?.Data?.duration || "1h",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (newWidget3d) {
|
if (newWidget3d) {
|
||||||
const widgemodel3D_Datas = {
|
const widgemodel3D_Datas = {
|
||||||
widget: {
|
widget: {
|
||||||
id: newWidget3d.widgetID,
|
id: newWidget3d.widgetID,
|
||||||
type: newWidget3d.type,
|
type: newWidget3d.type,
|
||||||
position: newWidget3d.position,
|
position: newWidget3d.position,
|
||||||
},
|
},
|
||||||
Data: newWidget3d.Data,
|
Data: newWidget3d.Data,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
};
|
};
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget created successfully",
|
message: "Widget created successfully",
|
||||||
})}
|
})}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget created successfully",
|
message: "Widget created successfully",
|
||||||
data: widgemodel3D_Datas,
|
data: widgemodel3D_Datas,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while 3Dwidget",
|
message: error?.message || "Error occurred while 3Dwidget",
|
||||||
error,
|
error,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const update3D = async (data: any) => {
|
export const update3D = async (data: any) => {
|
||||||
const { organization, id, position, rotation, zoneId } = data;
|
const { organization, id, position, rotation, zoneId } = data;
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Zone not found",
|
message: "Zone not found",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (existing3Dwidget) {
|
if (existing3Dwidget) {
|
||||||
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
const update3dwidget = await widget3dModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{ position: position, rotation: rotation },
|
{ position: position, rotation: rotation },
|
||||||
{ upsert: true, new: true }
|
{ upsert: true, new: true }
|
||||||
);
|
);
|
||||||
if (update3dwidget) {
|
if (update3dwidget) {
|
||||||
const updateDatas = {
|
const updateDatas = {
|
||||||
widget: {
|
widget: {
|
||||||
id: update3dwidget.widgetID,
|
id: update3dwidget.widgetID,
|
||||||
type: update3dwidget.type,
|
type: update3dwidget.type,
|
||||||
position: update3dwidget.position,
|
position: update3dwidget.position,
|
||||||
rotation: update3dwidget.rotation,
|
rotation: update3dwidget.rotation,
|
||||||
},
|
},
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "widget update successfully",
|
message: "widget update successfully",
|
||||||
data: updateDatas,
|
data: updateDatas,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "widget not found",
|
message: "widget not found",
|
||||||
|
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while 3Dwidget",
|
message: error?.message || "Error occurred while 3Dwidget",
|
||||||
error,
|
error,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const delete3Dwidget = async (data: any) => {
|
export const delete3Dwidget = async (data: any) => {
|
||||||
const { organization, id, zoneId } = data;
|
const { organization, id, zoneId } = data;
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Zone not found",
|
message: "Zone not found",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
const existing3Dwidget = await widget3dModel(organization).findOne({
|
const existing3Dwidget = await widget3dModel(organization).findOne({
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (!existing3Dwidget) {
|
if (!existing3Dwidget) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "3D widget not found for the ID",
|
message: "3D widget not found for the ID",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const updateWidget = await widget3dModel(organization).findOneAndUpdate(
|
const updateWidget = await widget3dModel(organization).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
widgetID: id,
|
widgetID: id,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{ isArchive: true },
|
{ isArchive: true },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
if (updateWidget) {
|
if (updateWidget) {
|
||||||
const delete_Datas = {
|
const delete_Datas = {
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
id: existing3Dwidget.widgetID,
|
id: existing3Dwidget.widgetID,
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: delete_Datas,
|
data: delete_Datas,
|
||||||
message: "3DWidget delete successfull",
|
message: "3DWidget delete successfull",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while 3Dwidget",
|
message: error?.message || "Error occurred while 3Dwidget",
|
||||||
error,
|
error,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,280 +1,280 @@
|
|||||||
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
import floatWidgetModel from "../../../shared/model/vizualization/floatWidget.ts";
|
||||||
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
import zoneSchema from "../../../shared/model/builder/lines/zone-Model.ts";
|
||||||
|
|
||||||
export const addfloat = async (data: any) => {
|
export const addfloat = async (data: any) => {
|
||||||
const { organization, widget, zoneId, index } = data;
|
const { organization, widget, zoneId, index } = data;
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneId",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
|
|
||||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
const updateFloatWidget = await floatWidgetModel(
|
||||||
organization
|
organization
|
||||||
).findOneAndUpdate(
|
).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements,
|
measurements: widget?.Data?.measurements,
|
||||||
duration: widget?.Data?.duration,
|
duration: widget?.Data?.duration,
|
||||||
},
|
},
|
||||||
header: widget?.header,
|
header: widget?.header,
|
||||||
position: widget?.position,
|
position: widget?.position,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
upsert: true,
|
upsert: true,
|
||||||
new: true,
|
new: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const floatUpdateDatas = {
|
const floatUpdateDatas = {
|
||||||
position: updateFloatWidget.position,
|
position: updateFloatWidget.position,
|
||||||
index: index,
|
index: index,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget updated successfully",
|
message: "Widget updated successfully",
|
||||||
data: floatUpdateDatas,
|
data: floatUpdateDatas,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const newFloadWidget = await floatWidgetModel(organization).create({
|
const newFloadWidget = await floatWidgetModel(organization).create({
|
||||||
className: widget.className,
|
className: widget.className,
|
||||||
iconName: widget.iconName,
|
iconName: widget.iconName,
|
||||||
header: widget.header,
|
header: widget.header,
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
per: widget.per,
|
per: widget.per,
|
||||||
value: widget.value,
|
value: widget.value,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (newFloadWidget) {
|
if (newFloadWidget) {
|
||||||
const floatDatas = {
|
const floatDatas = {
|
||||||
widget: {
|
widget: {
|
||||||
position: newFloadWidget.position,
|
position: newFloadWidget.position,
|
||||||
header: newFloadWidget.header,
|
header: newFloadWidget.header,
|
||||||
value: newFloadWidget.value,
|
value: newFloadWidget.value,
|
||||||
per: newFloadWidget.per,
|
per: newFloadWidget.per,
|
||||||
className: newFloadWidget.className,
|
className: newFloadWidget.className,
|
||||||
id: newFloadWidget.floatWidgetID,
|
id: newFloadWidget.floatWidgetID,
|
||||||
},
|
},
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "FloatWidget created successfully",
|
message: "FloatWidget created successfully",
|
||||||
data: floatDatas,
|
data: floatDatas,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while float",
|
message: error?.message || "Error occurred while float",
|
||||||
error,
|
error,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const duplicatefloat = async (data: any, callback: any) => {
|
export const duplicatefloat = async (data: any, callback: any) => {
|
||||||
const { organization, widget, zoneId, index } = data;
|
const { organization, widget, zoneId, index } = data;
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneId",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
|
|
||||||
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
const existingFloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
});
|
});
|
||||||
if (existingFloatWidget) {
|
if (existingFloatWidget) {
|
||||||
const updateFloatWidget = await floatWidgetModel(
|
const updateFloatWidget = await floatWidgetModel(
|
||||||
organization
|
organization
|
||||||
).findOneAndUpdate(
|
).findOneAndUpdate(
|
||||||
{
|
{
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements,
|
measurements: widget?.Data?.measurements,
|
||||||
duration: widget?.Data?.duration,
|
duration: widget?.Data?.duration,
|
||||||
},
|
},
|
||||||
header: widget?.header,
|
header: widget?.header,
|
||||||
position: widget?.position,
|
position: widget?.position,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
upsert: true,
|
upsert: true,
|
||||||
new: true,
|
new: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (!updateFloatWidget) {
|
if (!updateFloatWidget) {
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: "FloatWidget update unsuccessfull",
|
message: "FloatWidget update unsuccessfull",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "FloatWidget update unsuccessfull",
|
message: "FloatWidget update unsuccessfull",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const floatUpdateDatas = {
|
const floatUpdateDatas = {
|
||||||
position: updateFloatWidget.position,
|
position: updateFloatWidget.position,
|
||||||
index: index,
|
index: index,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget updated successfully",
|
message: "Widget updated successfully",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Widget updated successfully",
|
message: "Widget updated successfully",
|
||||||
data: floatUpdateDatas,
|
data: floatUpdateDatas,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const newFloadWidget = await floatWidgetModel(organization).create({
|
const newFloadWidget = await floatWidgetModel(organization).create({
|
||||||
className: widget.className,
|
className: widget.className,
|
||||||
header: widget.header,
|
header: widget.header,
|
||||||
floatWidgetID: widget.id,
|
floatWidgetID: widget.id,
|
||||||
position: widget.position,
|
position: widget.position,
|
||||||
per: widget.per,
|
per: widget.per,
|
||||||
value: widget.value,
|
value: widget.value,
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
Data: {
|
Data: {
|
||||||
measurements: widget?.Data?.measurements,
|
measurements: widget?.Data?.measurements,
|
||||||
duration: widget?.Data?.duration,
|
duration: widget?.Data?.duration,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (newFloadWidget) {
|
if (newFloadWidget) {
|
||||||
const floatDatas = {
|
const floatDatas = {
|
||||||
widget: {
|
widget: {
|
||||||
position: newFloadWidget.position,
|
position: newFloadWidget.position,
|
||||||
header: newFloadWidget.header,
|
header: newFloadWidget.header,
|
||||||
value: newFloadWidget.value,
|
value: newFloadWidget.value,
|
||||||
per: newFloadWidget.per,
|
per: newFloadWidget.per,
|
||||||
className: newFloadWidget.className,
|
className: newFloadWidget.className,
|
||||||
id: newFloadWidget.floatWidgetID,
|
id: newFloadWidget.floatWidgetID,
|
||||||
},
|
},
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
index: index,
|
index: index,
|
||||||
};
|
};
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback({
|
callback({
|
||||||
success: true,
|
success: true,
|
||||||
message: "duplicate FloatWidget created successfully",
|
message: "duplicate FloatWidget created successfully",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "duplicate FloatWidget created successfully",
|
message: "duplicate FloatWidget created successfully",
|
||||||
data: floatDatas,
|
data: floatDatas,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (callback !== undefined) {
|
if (callback !== undefined) {
|
||||||
callback({
|
callback({
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while float",
|
message: error?.message || "Error occurred while float",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while float",
|
message: error?.message || "Error occurred while float",
|
||||||
error,
|
error,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const deletefloat = async (data: any) => {
|
export const deletefloat = async (data: any) => {
|
||||||
const { floatWidgetID, zoneId, organization } = data;
|
const { floatWidgetID, zoneId, organization } = data;
|
||||||
try {
|
try {
|
||||||
const existingZone = await zoneSchema(organization).findOne({
|
const existingZone = await zoneSchema(organization).findOne({
|
||||||
zoneId: zoneId,
|
zoneId: zoneId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!existingZone)
|
if (!existingZone)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneId",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
|
|
||||||
const findfloatWidget = await floatWidgetModel(organization).findOne({
|
const findfloatWidget = await floatWidgetModel(organization).findOne({
|
||||||
floatWidgetID: floatWidgetID,
|
floatWidgetID: floatWidgetID,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
if (!findfloatWidget)
|
if (!findfloatWidget)
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Zone not found for the zoneId",
|
message: "Zone not found for the zoneId",
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
const widgetData = await floatWidgetModel(organization).findByIdAndUpdate(
|
const widgetData = await floatWidgetModel(organization).findByIdAndUpdate(
|
||||||
{ _id: findfloatWidget._id, isArchive: false },
|
{ _id: findfloatWidget._id, isArchive: false },
|
||||||
{ isArchive: true },
|
{ isArchive: true },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (widgetData) {
|
if (widgetData) {
|
||||||
const floatDeleteData = {
|
const floatDeleteData = {
|
||||||
floatWidgetID: findfloatWidget.floatWidgetID,
|
floatWidgetID: findfloatWidget.floatWidgetID,
|
||||||
zoneId: findfloatWidget.zoneId,
|
zoneId: findfloatWidget.zoneId,
|
||||||
zoneName: existingZone.zoneName,
|
zoneName: existingZone.zoneName,
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "FloatingWidget deleted successfully",
|
message: "FloatingWidget deleted successfully",
|
||||||
data: floatDeleteData,
|
data: floatDeleteData,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error?.message || "Error occurred while float",
|
message: error?.message || "Error occurred while float",
|
||||||
error,
|
error,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
1886
swagger-output.json
1886
swagger-output.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user